mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-19 02:12:58 +01:00
Compare commits
114 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7dbb61fad8 | ||
|
|
b1c2616b0e | ||
|
|
b9b91403dd | ||
|
|
7f9d5d0183 | ||
|
|
b878d29386 | ||
|
|
6c70f9e677 | ||
|
|
136debfee5 | ||
|
|
abe01a84e5 | ||
|
|
1b15828d08 | ||
|
|
45974d2a19 | ||
|
|
2bf1563b20 | ||
|
|
4965cb2b68 | ||
|
|
00fc5b93d2 | ||
|
|
b86d76fcd4 | ||
|
|
4f1ee03fe8 | ||
|
|
e3267f2e0c | ||
|
|
c265aad6d7 | ||
|
|
b512fe2003 | ||
|
|
46648e2547 | ||
|
|
54e945bf14 | ||
|
|
7c01fced68 | ||
|
|
64871b4c37 | ||
|
|
e3e2def809 | ||
|
|
ea7d1ce0e2 | ||
|
|
f5ddf1bc0e | ||
|
|
f6a6316b7a | ||
|
|
35f62d4e45 | ||
|
|
77efbe39a9 | ||
|
|
248f24d4b9 | ||
|
|
32422646e4 | ||
|
|
a90e4e9c8d | ||
|
|
74188415dd | ||
|
|
11a4fdfcd5 | ||
|
|
7a119facdf | ||
|
|
4e6cc5ffa0 | ||
|
|
5a37e3e275 | ||
|
|
1edc32c6b0 | ||
|
|
a01a5a737b | ||
|
|
0c22064a94 | ||
|
|
9ef68d226a | ||
|
|
bf361f6824 | ||
|
|
74ee210514 | ||
|
|
2b7f21fee4 | ||
|
|
6ad32e487f | ||
|
|
97fd3eaf64 | ||
|
|
d9b4647cf5 | ||
|
|
03e0c02640 | ||
|
|
398f8c4318 | ||
|
|
1c7709a18b | ||
|
|
06c3a588bf | ||
|
|
80526c0e06 | ||
|
|
86528334d1 | ||
|
|
1cc4f7eaaa | ||
|
|
af2a05d0b5 | ||
|
|
701daadff5 | ||
|
|
7442d1c4a5 | ||
|
|
f247545fc4 | ||
|
|
e8817ec9ea | ||
|
|
44d2466422 | ||
|
|
eb7a0143da | ||
|
|
069e656cde | ||
|
|
f1aa3f5c68 | ||
|
|
acc3d7610b | ||
|
|
b2565bedd3 | ||
|
|
80c36ca846 | ||
|
|
00e5e75092 | ||
|
|
c8b30b6714 | ||
|
|
2c4418e6e6 | ||
|
|
d0e7e1bbb5 | ||
|
|
70ce762b5a | ||
|
|
e879153df7 | ||
|
|
c9db9566cb | ||
|
|
a1283bfc0f | ||
|
|
378de09ccd | ||
|
|
20febbc3bc | ||
|
|
3b0ba43e94 | ||
|
|
c189a6b489 | ||
|
|
2082c479f1 | ||
|
|
b70e868b5c | ||
|
|
24a50346db | ||
|
|
b84a03082e | ||
|
|
e40e10da61 | ||
|
|
6a858dace7 | ||
|
|
b0fbaa71bf | ||
|
|
18a2b686c1 | ||
|
|
a2f23bd056 | ||
|
|
bb5a9826bc | ||
|
|
9904eb0b0d | ||
|
|
f89f215813 | ||
|
|
d01bd487f7 | ||
|
|
3be31dbf90 | ||
|
|
bb1bce879f | ||
|
|
dd6082c8a1 | ||
|
|
be6d208b8b | ||
|
|
f547523c3e | ||
|
|
7de19f8087 | ||
|
|
dfdf8b881e | ||
|
|
da6755f703 | ||
|
|
602bde7bc5 | ||
|
|
e9d1297c17 | ||
|
|
8bbee7fe06 | ||
|
|
8b4c86c8ba | ||
|
|
6c1ee24101 | ||
|
|
26ed6aa840 | ||
|
|
ef3802f7c2 | ||
|
|
3c9e38d7ad | ||
|
|
2e4aeca0df | ||
|
|
fd6bf931fc | ||
|
|
751b795417 | ||
|
|
8b07b189d4 | ||
|
|
6c6fb117ea | ||
|
|
6fffe10c32 | ||
|
|
a2d5b97467 | ||
|
|
1cda446063 |
@@ -6,8 +6,49 @@ Key:
|
||||
= Fix
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.04-dev
|
||||
|
||||
Version 1.3.06-dev
|
||||
+ Added permissions check to skill functions
|
||||
+ Added API functions for obtaining offline profiles & profiles via player names
|
||||
+ Added API functions for admin & party chat
|
||||
+ Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed.
|
||||
= Fixed bug where Herbalism required double drops permission to give XP
|
||||
= Fixed bug where {0} would be displayed in front of your power level in mcstats
|
||||
= Fixed mmoupdate not being useable from console
|
||||
= Fixed bug with repairing wooden tools
|
||||
= Fixed bug with Nether Wart not awarding XP
|
||||
= Fixed bug with fishing treasures when treasures list is empty
|
||||
= Fixed bug with only getting one level when there was enough XP for multiple levels.
|
||||
! Changed how the tree feller threshold worked for the better
|
||||
! Changed mcremove to no longer kick players when they are removed from database
|
||||
! Changed mcremove to work on offline users for FlatFile
|
||||
! Changed PlayerProfile constructor to always take a boolean
|
||||
! Changed getPlayerProfile function to work for online & offline users
|
||||
! Changed Archery's Daze to deal 4 DMG on proc (2 Hearts)
|
||||
! Changed /addlevel command to work for offline users
|
||||
! Changed party & admin chat handling to be nicer to developers
|
||||
! Changed UpdateXPBar function to hopefully avoid errors
|
||||
|
||||
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
|
||||
= Fixed dupe exploit with Blast Mining
|
||||
! 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
|
||||
@@ -21,7 +62,7 @@ Version 1.3.04-dev
|
||||
= 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
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.04</version>
|
||||
<version>1.3.06-dev</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
|
||||
68
src/main/java/com/gmail/nossr50/api/ChatAPI.java
Normal file
68
src/main/java/com/gmail/nossr50/api/ChatAPI.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class ChatAPI {
|
||||
/**
|
||||
* Send a message to all members of a party
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param party The name of the party to send to
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendPartyChat(String sender, String party, String message) {
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") ";
|
||||
|
||||
Bukkit.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(player).inParty()) {
|
||||
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
|
||||
player.sendMessage(pPrefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to administrators
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param sender The name of the sender to display in the chat
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendAdminChat(String sender, String message) {
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if (chatEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} ";
|
||||
|
||||
Bukkit.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (mcPermissions.getInstance().adminChat(player) || player.isOp())
|
||||
player.sendMessage(aPrefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
136
src/main/java/com/gmail/nossr50/api/ExperienceAPI.java
Normal file
136
src/main/java/com/gmail/nossr50/api/ExperienceAPI.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
125
src/main/java/com/gmail/nossr50/api/PartyAPI.java
Normal file
125
src/main/java/com/gmail/nossr50/api/PartyAPI.java
Normal 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.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
147
src/main/java/com/gmail/nossr50/commands/CommandHelper.java
Normal file
147
src/main/java/com/gmail/nossr50/commands/CommandHelper.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package com.gmail.nossr50.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static boolean noConsoleUsage(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(mcLocale.getString("Commands.NoConsole"));
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,81 +1,108 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.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;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
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) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile PP;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /addlevels [playername] <skill> <level>"; //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."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if (args.length < 2) {
|
||||
System.out.println("Usage is /addlevels playername skillname levels"); //TODO: Needs more locale.
|
||||
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"); //TODO: Needs more locale.
|
||||
}
|
||||
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]);
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PP.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"); //TODO: Needs more locale.
|
||||
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."); //TODO: Needs more locale.
|
||||
}
|
||||
} 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."); //TODO: Needs more locale.
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue"); //TODO: Needs more locale.
|
||||
}
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (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);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,78 +6,105 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.skills.Skills;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
//TODO: Any way we can make this work for offline use?
|
||||
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 [player] <skill> <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."); //TODO: Needs more locale.
|
||||
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!"); //TODO: Needs more locale.
|
||||
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"); //TODO: Needs more locale.
|
||||
}
|
||||
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"); //TODO: Needs more locale.
|
||||
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!"); //TODO: Needs more locale.
|
||||
player.sendMessage(ChatColor.RED + args[1] + " has been modified."); //TODO: Needs more locale.
|
||||
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"); //TODO: Needs more locale.
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
@@ -24,103 +23,72 @@ public class InspectCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer target;
|
||||
PlayerProfile PP;
|
||||
String usage = "Proper usage is /inspect <player>"; //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>"); //TODO: Needs more locale.
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
target = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
PP = Users.getProfile(target);
|
||||
|
||||
if (target.isOnline()) {
|
||||
Player player = (Player) target;
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !m.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0)) {
|
||||
sender.sendMessage(mcLocale.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(mcLocale.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(player, sender);
|
||||
CommandHelper.printCombatSkills(player, sender);
|
||||
CommandHelper.printMiscSkills(player, sender);
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (sender instanceof Player && !sender.isOp()) {
|
||||
sender.sendMessage(mcLocale.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
sender.sendMessage(mcLocale.getString("Commands.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!"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName()); //TODO: Needs more locale.
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-"); //TODO: Needs more locale.
|
||||
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=-"); //TODO: Needs more locale.
|
||||
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=-"); //TODO: Needs more locale.
|
||||
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!"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PPt = Users.getOfflineProfile(args[0]);
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for Offline Player " + ChatColor.YELLOW + args[0]); //TODO: Needs more locale.
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-"); //TODO: Needs more locale.
|
||||
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=-"); //TODO: Needs more locale.
|
||||
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=-"); //TODO: Needs more locale.
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,78 +1,35 @@
|
||||
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;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McstatsCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
|
||||
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
|
||||
CommandHelper.printGatheringSkills(player);
|
||||
CommandHelper.printCombatSkills(player);
|
||||
CommandHelper.printMiscSkills(player);
|
||||
|
||||
ChatColor header = ChatColor.GOLD;
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() }));
|
||||
|
||||
if (Skills.hasGatheringSkills(player)) {
|
||||
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))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING)));
|
||||
if (mcPermissions.getInstance().herbalism(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM)));
|
||||
if (mcPermissions.getInstance().mining(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING)));
|
||||
if (mcPermissions.getInstance().woodcutting(player))
|
||||
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=-"); //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))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY)));
|
||||
if (mcPermissions.getInstance().swords(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS)));
|
||||
if (mcPermissions.getInstance().taming(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING)));
|
||||
if (mcPermissions.getInstance().unarmed(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED)));
|
||||
}
|
||||
|
||||
if (Skills.hasMiscSkills(player)) {
|
||||
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)));
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +1,108 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
player = (Player) sender;
|
||||
public MmoeditCommand(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile PP;
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <level>"; //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."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
System.out.println("Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
|
||||
return true;
|
||||
} else if (args.length == 3)
|
||||
{
|
||||
PlayerProfile PPt = null;
|
||||
|
||||
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
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
||||
{
|
||||
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] + "."); //TODO: Needs more locale.
|
||||
}
|
||||
} else
|
||||
{
|
||||
System.out.println("Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
|
||||
}
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
if (sender instanceof Player) {
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
}
|
||||
else {
|
||||
skillName = m.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
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 /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
if (args.length == 3)
|
||||
{
|
||||
PlayerProfile PPt = null;
|
||||
|
||||
if(Users.players.containsKey(args[0].toLowerCase())) {
|
||||
PPt = Users.players.get(args[0].toLowerCase());
|
||||
PP.modifySkill(skill, newValue);
|
||||
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
if(PPt == null)
|
||||
Users.getOfflineProfile(args[0]); //Only grab offline profile if the above failed
|
||||
|
||||
if(!PPt.isLoaded())
|
||||
{
|
||||
sender.sendMessage("Player does not exist in the database!"); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
||||
{
|
||||
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]); //TODO: Needs more locale.
|
||||
}
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
if (m.isInt(args[1]) && Skills.isSkill(args[0]))
|
||||
{
|
||||
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."); //TODO: Needs more locale.
|
||||
}
|
||||
} else
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue"); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m.isInt(args[2]) && Skills.isSkill(args[1])) {
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
|
||||
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
|
||||
|
||||
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);
|
||||
|
||||
if (modifiedPlayer.isOnline()) {
|
||||
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,38 +7,33 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.runnables.SQLConversionTask;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcPermissions.getInstance().admin(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
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!"); //TODO: Needs more locale.
|
||||
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
||||
Users.clearUsers();
|
||||
convertToMySQL();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(x);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "Conversion finished!"); //TODO: Needs more locale.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert FlatFile data to MySQL data.
|
||||
*/
|
||||
private void convertToMySQL() {
|
||||
@@ -48,4 +43,4 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,124 +1,88 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private static int oldrate = LoadProperties.xpGainMultiplier;
|
||||
|
||||
public static boolean xpevent = false;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
private static int oldrate = LoadProperties.xpGainMultiplier;
|
||||
public static boolean xpevent = false;
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
if(args.length <= 0)
|
||||
{
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
||||
}
|
||||
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
if(xpevent)
|
||||
{
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
||||
xpevent = !xpevent;
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
} else
|
||||
{
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
}
|
||||
}
|
||||
|
||||
if(args.length >= 1 && m.isInt(args[0]))
|
||||
{
|
||||
oldrate = LoadProperties.xpGainMultiplier;
|
||||
|
||||
if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("true"))
|
||||
xpevent = true;
|
||||
else
|
||||
xpevent = false;
|
||||
} else
|
||||
{
|
||||
System.out.println(mcLocale.getString("Commands.xprate.proper3"));
|
||||
return true;
|
||||
}
|
||||
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
||||
if(xpevent = true)
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
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); //TODO: Needs more locale.
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(!mcPermissions.getInstance().admin(player))
|
||||
{
|
||||
player.sendMessage(ChatColor.YELLOW+"[mcMMO] "+ChatColor.DARK_RED +mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if(args.length <= 0)
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper", new Object[] {"xprate"}));
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper2", new Object[] {"xprate"}));
|
||||
}
|
||||
if(args.length == 1 && args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
if(xpevent)
|
||||
{
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
||||
xpevent = !xpevent;
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
} else
|
||||
{
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
}
|
||||
}
|
||||
if(args.length >= 1 && m.isInt(args[0]))
|
||||
{
|
||||
oldrate = LoadProperties.xpGainMultiplier;
|
||||
|
||||
if(args.length >= 2 && (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("true"))
|
||||
xpevent = true;
|
||||
else
|
||||
xpevent = false;
|
||||
} else
|
||||
{
|
||||
player.sendMessage(mcLocale.getString("Commands.xprate.proper3"));
|
||||
return true;
|
||||
}
|
||||
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
||||
if(xpevent = true)
|
||||
for(Player x : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.started"));
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage1 = mcLocale.getString("Commands.xprate.proper");
|
||||
String usage2 = mcLocale.getString("Commands.xprate.proper2");
|
||||
String usage3 = mcLocale.getString("Commands.xprate.proper3");
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpevent) {
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpevent = !xpevent;
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
}
|
||||
else {
|
||||
LoadProperties.xpGainMultiplier = oldrate;
|
||||
}
|
||||
}
|
||||
else if (m.isInt(args[0])) {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
if (m.isInt(args[0])) {
|
||||
oldrate = LoadProperties.xpGainMultiplier;
|
||||
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpevent = Boolean.valueOf(args[1]);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
}
|
||||
|
||||
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
|
||||
|
||||
if (xpevent) {
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.started"));
|
||||
x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("The XP RATE was modified to " + LoadProperties.xpGainMultiplier); //TODO: Locale
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage1);
|
||||
sender.sendMessage(usage2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage1);
|
||||
sender.sendMessage(usage2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@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) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player != null && !mcPermissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if (PP.getAbilityUse()) {
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
|
||||
}
|
||||
|
||||
if (PP.getAbilityUse()) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOff"));
|
||||
PP.toggleAbilityUse();
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesOn"));
|
||||
PP.toggleAbilityUse();
|
||||
}
|
||||
PP.toggleAbilityUse();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,58 +6,67 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
//TODO: Rework this whole thing. It's ugly.
|
||||
public class MccCommand 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.");
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale.
|
||||
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"));
|
||||
player.sendMessage("/party " + mcLocale.getString("m.mccParty"));
|
||||
player.sendMessage("/party q " + mcLocale.getString("m.mccPartyQ"));
|
||||
if (mcPermissions.getInstance().party(player)) {
|
||||
player.sendMessage(mcLocale.getString("m.mccPartyCommands"));
|
||||
player.sendMessage("/party " + mcLocale.getString("m.mccParty"));
|
||||
player.sendMessage("/party q " + mcLocale.getString("m.mccPartyQ"));
|
||||
|
||||
if (mcPermissions.getInstance().partyChat(player))
|
||||
player.sendMessage("/p " + mcLocale.getString("m.mccPartyToggle"));
|
||||
if (mcPermissions.getInstance().partyChat(player)) {
|
||||
player.sendMessage("/p " + mcLocale.getString("m.mccPartyToggle"));
|
||||
}
|
||||
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyInvite"));
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyAccept"));
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyInvite"));
|
||||
player.sendMessage("/invite " + mcLocale.getString("m.mccPartyAccept"));
|
||||
|
||||
if (mcPermissions.getInstance().partyTeleport(player))
|
||||
player.sendMessage("/ptp " + mcLocale.getString("m.mccPartyTeleport"));
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("m.mccOtherCommands"));
|
||||
player.sendMessage("/mcstats " + ChatColor.RED + mcLocale.getString("m.mccStats"));
|
||||
player.sendMessage("/mctop <skillname> <page> " + ChatColor.RED + mcLocale.getString("m.mccLeaderboards"));
|
||||
if (mcPermissions.getInstance().partyTeleport(player)) {
|
||||
player.sendMessage("/ptp " + mcLocale.getString("m.mccPartyTeleport"));
|
||||
}
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().mcAbility(player))
|
||||
player.sendMessage("/mcability " + ChatColor.RED + mcLocale.getString("m.mccToggleAbility"));
|
||||
player.sendMessage(mcLocale.getString("m.mccOtherCommands"));
|
||||
player.sendMessage("/mcstats " + ChatColor.RED + mcLocale.getString("m.mccStats"));
|
||||
player.sendMessage("/mctop <skillname> <page> " + ChatColor.RED + mcLocale.getString("m.mccLeaderboards"));
|
||||
|
||||
if (mcPermissions.getInstance().adminChat(player))
|
||||
player.sendMessage("/a " + ChatColor.RED + mcLocale.getString("m.mccAdminToggle"));
|
||||
if (mcPermissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + ChatColor.RED + mcLocale.getString("m.mccToggleAbility"));
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().inspect(player))
|
||||
player.sendMessage("/inspect " + mcLocale.getString("m.mccInspect"));
|
||||
if (mcPermissions.getInstance().adminChat(player)) {
|
||||
player.sendMessage("/a " + ChatColor.RED + mcLocale.getString("m.mccAdminToggle"));
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().mmoedit(player))
|
||||
player.sendMessage("/mmoedit " + mcLocale.getString("m.mccMmoedit"));
|
||||
if (mcPermissions.getInstance().inspect(player)) {
|
||||
player.sendMessage("/inspect " + mcLocale.getString("m.mccInspect"));
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().mcgod(player))
|
||||
player.sendMessage("/mcgod " + ChatColor.RED + mcLocale.getString("m.mccMcGod"));
|
||||
if (mcPermissions.getInstance().mmoedit(player)) {
|
||||
player.sendMessage("/mmoedit " + mcLocale.getString("m.mccMmoedit"));
|
||||
}
|
||||
|
||||
player.sendMessage(mcLocale.getString("m.mccSkillInfo"));
|
||||
player.sendMessage("/mcmmo " + mcLocale.getString("m.mccModDescription"));
|
||||
if (mcPermissions.getInstance().mcgod(player)) {
|
||||
player.sendMessage("/mcgod " + ChatColor.RED + mcLocale.getString("m.mccMcGod"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("m.mccSkillInfo"));
|
||||
player.sendMessage("/mcmmo " + mcLocale.getString("m.mccModDescription"));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,38 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McgodCommand 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."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcgod")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mcPermissions.getInstance().mcgod(player)) {
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
|
||||
if (mcPermissions.getInstance().mcgod(player)) {
|
||||
if (PP.getGodMode()) {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GodModeDisabled"));
|
||||
PP.toggleGodMode();
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.GodModeEnabled"));
|
||||
PP.toggleGodMode();
|
||||
}
|
||||
}
|
||||
if (PP.getGodMode()) {
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.GodModeDisabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.GodModeEnabled"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
PP.toggleGodMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
@@ -12,32 +12,26 @@ import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String description = mcLocale.getString("mcMMO.Description", new Object[] { "mcc" });
|
||||
String[] mcSplit = description.split(",");
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
for (String x : mcSplit) {
|
||||
sender.sendMessage(x);
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (LoadProperties.donateMessage) {
|
||||
if (LoadProperties.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer sPlayer = (SpoutPlayer) sender;
|
||||
|
||||
String description = mcLocale.getString("mcMMO.Description", new Object[] { "mcc" });
|
||||
String[] mcSplit = description.split(",");
|
||||
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "nossr50@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
for (String x : mcSplit) {
|
||||
player.sendMessage(x);
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
|
||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||
}
|
||||
|
||||
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"); //Where'd our notification go?
|
||||
} else {
|
||||
if (LoadProperties.donateMessage)
|
||||
player.sendMessage(ChatColor.YELLOW + "[mcMMO]"+ChatColor.GOLD+" Donate! Paypal "+ChatColor.GREEN+"theno1yeti@gmail.com");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class McrefreshCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.gmail.nossr50.commands.mc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -7,13 +11,15 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = null;
|
||||
@@ -68,42 +74,52 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
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.
|
||||
if(Bukkit.getServer().getPlayer(playerName) != null)
|
||||
{
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
if(targetPlayer.isOnline())
|
||||
{
|
||||
Users.getProfile(targetPlayer).resetAllData();
|
||||
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."); //TODO: Needs more locale.
|
||||
return true;
|
||||
}
|
||||
if(removeFlatFileUser(playerName)) {
|
||||
sender.sendMessage(ChatColor.GREEN+"[mcMMO] It worked! User was removed.");
|
||||
} else {
|
||||
sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online."); //TODO: Needs more locale.
|
||||
return true;
|
||||
sender.sendMessage(ChatColor.RED+"[mcMMO] Couldn't find the user, remember its case sensitive!");
|
||||
}
|
||||
}
|
||||
|
||||
//Force PlayerProfile stuff to update
|
||||
if(Bukkit.getServer().getPlayer(playerName) != null)
|
||||
if(Bukkit.getServer().getPlayer(playerName) != null && Users.players.containsKey(playerName.toLowerCase()))
|
||||
{
|
||||
Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
|
||||
if(targetPlayer.isOnline())
|
||||
{
|
||||
targetPlayer.kickPlayer("[mcMMO] Stats have been reset! Rejoin!"); //TODO: Needs more locale.
|
||||
Users.removeUserByName(playerName);
|
||||
} else {
|
||||
Users.removeUser(targetPlayer);
|
||||
}
|
||||
} else {
|
||||
Users.removeUserByName(playerName);
|
||||
Users.players.remove(playerName.toLowerCase());
|
||||
Users.addUser(Bukkit.getServer().getPlayer(playerName));
|
||||
}
|
||||
|
||||
sender.sendMessage("[mcMMO] mcremove operation completed."); //TODO: Needs more locale.
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
while ((line = in.readLine()) != null) {
|
||||
/* Write out the same file but when we get to the player we want to remove we skip his line */
|
||||
if(!line.split(":")[0].equalsIgnoreCase(playerName))
|
||||
{
|
||||
writer.append(line).append("\r\n");
|
||||
} else {
|
||||
System.out.println("User found, removing...");
|
||||
worked = true;
|
||||
continue; //Skip the player
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
FileWriter out = new FileWriter(location); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
return worked;
|
||||
} catch (Exception e) {
|
||||
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
return worked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,13 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.Leaderboard;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
|
||||
@@ -7,11 +7,11 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class ACommand implements CommandExecutor {
|
||||
|
||||
@@ -27,6 +27,13 @@ public class ACommand implements CommandExecutor {
|
||||
aMessage = aMessage + " " + args[i];
|
||||
}
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return true;
|
||||
|
||||
aMessage = chatEvent.getMessage();
|
||||
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
|
||||
|
||||
Bukkit.getLogger().info("[A]<*Console*> " + aMessage);
|
||||
@@ -55,14 +62,11 @@ public class ACommand implements CommandExecutor {
|
||||
for (int i = 1; i <= args.length - 1; i++) {
|
||||
aMessage = aMessage + " " + args[i];
|
||||
}
|
||||
|
||||
Users.getProfile(player).toggleAdminChat();
|
||||
player.chat(aMessage);
|
||||
Users.getProfile(player).toggleAdminChat();
|
||||
|
||||
String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName();
|
||||
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} ";
|
||||
Bukkit.getLogger().info("[A]<" + name + "> " + aMessage);
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
|
||||
herp.sendMessage(aPrefix + aMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
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.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class AcceptCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class AcceptCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
PP.acceptInvite();
|
||||
Pinstance.addToParty(player, PP, PP.getParty(), true);
|
||||
Pinstance.addToParty(player, PP, PP.getParty(), true, null);
|
||||
|
||||
} else {
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.NoInvites"));
|
||||
|
||||
@@ -6,12 +6,12 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class InviteCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@@ -7,12 +7,11 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class PCommand implements CommandExecutor {
|
||||
public PCommand() {}
|
||||
@@ -29,6 +28,13 @@ public class PCommand implements CommandExecutor {
|
||||
pMessage = pMessage + " " + args[i];
|
||||
}
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], pMessage);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return true;
|
||||
|
||||
pMessage = chatEvent.getMessage();
|
||||
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
|
||||
|
||||
Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
|
||||
@@ -63,17 +69,10 @@ public class PCommand implements CommandExecutor {
|
||||
for (int i = 1; i <= args.length - 1; i++) {
|
||||
pMessage = pMessage + " " + args[i];
|
||||
}
|
||||
|
||||
String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName();
|
||||
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") ";
|
||||
Bukkit.getLogger().info("[P](" + PP.getParty() + ")<" + name + "> " + pMessage);
|
||||
|
||||
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (Users.getProfile(herp).inParty()) {
|
||||
if (Party.getInstance().inSameParty(herp, player))
|
||||
herp.sendMessage(pPrefix + pMessage);
|
||||
}
|
||||
}
|
||||
|
||||
PP.togglePartyChat();
|
||||
player.chat(pMessage);
|
||||
PP.togglePartyChat();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
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.events.party.McMMOPartyChangeEvent;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class PartyCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -35,7 +35,7 @@ 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()) {
|
||||
@@ -48,7 +48,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
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++;
|
||||
@@ -57,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++;
|
||||
@@ -175,7 +175,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Pinstance.addToParty(player, PP, args[0], false);
|
||||
Pinstance.addToParty(player, PP, args[0], false, null);
|
||||
return true;
|
||||
}
|
||||
} else if (args.length == 2 && PP.inParty()) {
|
||||
|
||||
@@ -7,14 +7,14 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class PtpCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class AcrobaticsCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -21,6 +22,10 @@ public class AcrobaticsCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class ArcheryCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,23 +21,22 @@ public class ArcheryCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
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 +55,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);
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class AxesCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -19,6 +20,9 @@ public class AxesCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class ExcavationCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,9 @@ public class ExcavationCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class FishingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -21,6 +22,10 @@ public class FishingCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class HerbalismCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,10 @@ public class HerbalismCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class MiningCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,10 @@ public class MiningCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,14 +5,15 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.misc.Repair;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class RepairCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -22,6 +23,9 @@ public class RepairCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class SwordsCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,9 @@ public class SwordsCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class TamingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -21,6 +22,9 @@ public class TamingCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class UnarmedCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,10 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
@@ -32,7 +37,7 @@ public class UnarmedCommand implements CommandExecutor {
|
||||
percentage = "33.3";
|
||||
|
||||
if (PP.getSkillLevel(SkillType.UNARMED) < 1000)
|
||||
arrowpercentage = String.valueOf(((skillvalue / 1000) * 100) / 2);
|
||||
arrowpercentage = String.valueOf((skillvalue / 2000) * 100);
|
||||
else
|
||||
arrowpercentage = "50";
|
||||
|
||||
|
||||
@@ -5,12 +5,13 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.util.Page;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class WoodcuttingCommand implements CommandExecutor {
|
||||
@Override
|
||||
@@ -20,6 +21,9 @@ public class WoodcuttingCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) {
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MchudCommand implements CommandExecutor {
|
||||
@Override
|
||||
|
||||
@@ -6,14 +6,14 @@ import org.bukkit.command.CommandExecutor;
|
||||
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.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class XplockCommand implements CommandExecutor {
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,6 @@ public class LoadProperties extends ConfigLoader{
|
||||
mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable,
|
||||
mcremoveEnable, mcgodEnable, mcabilityEnable, mctopEnable,
|
||||
addlevelsEnable, mcrefreshEnable, aEnable, pEnable;
|
||||
public static Boolean aDisplayNames, pDisplayNames;
|
||||
public static int ptpCommandCooldown;
|
||||
public static Boolean donateMessage;
|
||||
|
||||
@@ -88,7 +87,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 +105,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 +131,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 +213,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 +331,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 +377,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);
|
||||
@@ -454,9 +459,6 @@ public class LoadProperties extends ConfigLoader{
|
||||
aEnable = config.getBoolean("Commands.a.Enabled", true);
|
||||
pEnable = config.getBoolean("Commands.p.Enabled", true);
|
||||
|
||||
aDisplayNames = config.getBoolean("Commands.a.Display_Names", true);
|
||||
pDisplayNames = config.getBoolean("Commands.p.Display_Names", true);
|
||||
|
||||
ptpCommandCooldown = config.getInt("Commands.ptp.Cooldown", 30);
|
||||
|
||||
animalXP = config.getDouble("Experience.Combat.Multiplier.Animals", 1.0);
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.gmail.nossr50.datatypes;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.skills.Excavation;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Mining;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(LoadProperties.berserkCooldown, mcLocale.getString("Skills.BerserkOn"), mcLocale.getString("Skills.BerserkOff"), "Skills.BerserkPlayer", mcLocale.getString("Skills.YourBerserk"), "Skills.BerserkPlayerOff"),
|
||||
|
||||
@@ -10,14 +10,14 @@ import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
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.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class HUDmmo {
|
||||
private int center_x = 427/2;
|
||||
private int center_x = 427 / 2;
|
||||
|
||||
private String playerName = null;
|
||||
|
||||
@@ -206,7 +206,7 @@ public class HUDmmo {
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
private void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
|
||||
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
|
||||
if (LoadProperties.xpbar) {
|
||||
xpbar = new GenericTexture();
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class PlayerProfile {
|
||||
@@ -63,38 +63,6 @@ public class PlayerProfile {
|
||||
private String playerName;
|
||||
private String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
|
||||
|
||||
public PlayerProfile(String name) {
|
||||
hud = LoadProperties.defaulthud;
|
||||
playerName = name;
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
skillsDATS.put(abilityType, 0);
|
||||
}
|
||||
|
||||
for (SkillType skillType : SkillType.values()) {
|
||||
if (skillType != SkillType.ALL) {
|
||||
skills.put(skillType, 0);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (LoadProperties.useMySQL) {
|
||||
if (!loadMySQL()) {
|
||||
addMySQLPlayer();
|
||||
loadMySQL(); //This is probably not needed anymore, could just delete. // So can we remove this whole function, or just this line?
|
||||
}
|
||||
}
|
||||
else if (!load()) {
|
||||
addPlayer();
|
||||
}
|
||||
|
||||
lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* Why do we even have this? The only time it's called, it's false.
|
||||
* Why not combine the two?
|
||||
*/
|
||||
public PlayerProfile(String name, boolean addNew) {
|
||||
hud = LoadProperties.defaulthud;
|
||||
playerName = name;
|
||||
@@ -113,7 +81,6 @@ public class PlayerProfile {
|
||||
if (LoadProperties.useMySQL) {
|
||||
if (!loadMySQL() && addNew) {
|
||||
addMySQLPlayer();
|
||||
loadMySQL(); //This is probably not needed anymore, could just delete. // So can we remove this whole function, or just this line?
|
||||
}
|
||||
}
|
||||
else if (!load() && addNew) {
|
||||
@@ -125,7 +92,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public boolean loadMySQL() {
|
||||
Integer id = 0;
|
||||
int id = 0;
|
||||
id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||
if(id == 0)
|
||||
return false;
|
||||
@@ -151,7 +118,7 @@ public class PlayerProfile {
|
||||
}
|
||||
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id);
|
||||
//lastlogin = Integer.parseInt(users.get(1).get(0));
|
||||
party = users.get(1).get(1);
|
||||
party = users.get(1).get(1);
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id);
|
||||
/*
|
||||
* I'm still learning MySQL, this is a fix for adding a new table
|
||||
@@ -207,7 +174,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void addMySQLPlayer() {
|
||||
Integer id = 0;
|
||||
int id = 0;
|
||||
mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
||||
id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
|
||||
mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
|
||||
@@ -989,21 +956,25 @@ public class PlayerProfile {
|
||||
* XP Functions
|
||||
*/
|
||||
|
||||
public Integer getSkillLevel(SkillType skillType) {
|
||||
public int getSkillLevel(SkillType skillType) {
|
||||
return skills.get(skillType);
|
||||
}
|
||||
|
||||
public Integer getSkillXpLevel(SkillType skillType) {
|
||||
public int getSkillXpLevel(SkillType skillType) {
|
||||
return skillsXp.get(skillType);
|
||||
}
|
||||
|
||||
public void skillUp(SkillType skillType, int newValue) {
|
||||
skills.put(skillType, skills.get(skillType) + newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverrideNoBonus(SkillType skillType, int newValue) {
|
||||
public void addXPOverride(SkillType skillType, int newValue) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
@@ -1029,26 +1000,9 @@ public class PlayerProfile {
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int newValue) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType x : SkillType.values()) {
|
||||
if (x.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int xp = newValue * LoadProperties.xpGainMultiplier;
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
lastgained = skillType;
|
||||
}
|
||||
public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
int xp = newValue * LoadProperties.xpGainMultiplier;
|
||||
addXPOverride(skillType, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1058,7 +1012,9 @@ public class PlayerProfile {
|
||||
* @param newvalue The amount of XP to add
|
||||
* @param player The player to add XP to
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue, Player player) {
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
|
||||
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
@@ -1067,20 +1023,7 @@ public class PlayerProfile {
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
for (Player x : Party.getInstance().getPartyMembers(player)) {
|
||||
if (x.isOnline() && !x.getName().equals(player.getName()) && Party.getInstance().isPartyLeader(x.getName(), this.getParty())) {
|
||||
if (m.isNear(player.getLocation(), x.getLocation(), 25)) {
|
||||
PlayerProfile PartyLeader = Users.getProfile(x);
|
||||
|
||||
if (PartyLeader.getSkillLevel(skillType) >= this.getSkillLevel(skillType)) {
|
||||
|
||||
int leaderLevel = PartyLeader.getSkillLevel(skillType);
|
||||
int difference = leaderLevel - this.getSkillLevel(skillType);
|
||||
bonusModifier = (difference * 0.75D) / 100D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bonusModifier = partyModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int) (newValue / skillType.getXpModifier()) * LoadProperties.xpGainMultiplier;
|
||||
@@ -1099,13 +1042,34 @@ public class PlayerProfile {
|
||||
lastgained = skillType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove XP from a skill.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param xp Amount of xp to remove
|
||||
*/
|
||||
public void removeXP(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
skillsXp.put(skill, skillsXp.get(skill) - xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a skill level.
|
||||
*
|
||||
* @param skillType Type of skill to modify
|
||||
* @param newValue New level value for the skill
|
||||
*/
|
||||
public void modifyskill(SkillType skillType, int newValue) {
|
||||
public void modifySkill(SkillType skillType, int newValue) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
@@ -1155,10 +1119,56 @@ public class PlayerProfile {
|
||||
* @param skillType Type of skill to check
|
||||
* @return the XP remaining until next level
|
||||
*/
|
||||
public Integer getXpToLevel(SkillType skillType) {
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return (int) (1020 + (skills.get(skillType) * 20)); //Do we REALLY need to cast to int here?
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
private double partyModifier(SkillType skillType) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player x : Party.getInstance().getPartyMembers(player)) {
|
||||
if (x.isOnline() && !x.getName().equals(player.getName()) && Party.getInstance().isPartyLeader(x.getName(), this.getParty())) {
|
||||
if (m.isNear(player.getLocation(), x.getLocation(), 25.0)) {
|
||||
PlayerProfile PartyLeader = Users.getProfile(x);
|
||||
|
||||
if (PartyLeader.getSkillLevel(skillType) >= this.getSkillLevel(skillType)) {
|
||||
|
||||
int leaderLevel = PartyLeader.getSkillLevel(skillType);
|
||||
int difference = leaderLevel - this.getSkillLevel(skillType);
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
|
||||
/*
|
||||
* Party Stuff
|
||||
*/
|
||||
|
||||
@@ -2,105 +2,129 @@ 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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
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 this.ability;
|
||||
}
|
||||
|
||||
public int getMaxLevel()
|
||||
{
|
||||
if(maxLevel > 0)
|
||||
return maxLevel;
|
||||
else
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public ToolType getTool() {
|
||||
return 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);
|
||||
}
|
||||
|
||||
7
src/main/java/com/gmail/nossr50/datatypes/StaffType.java
Normal file
7
src/main/java/com/gmail/nossr50/datatypes/StaffType.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum StaffType {
|
||||
BLAZE_ROD,
|
||||
STICK,
|
||||
BONE;
|
||||
}
|
||||
@@ -3,55 +3,61 @@ package com.gmail.nossr50.datatypes;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to the admin chat channel
|
||||
*/
|
||||
public class McMMOAdminChatEvent extends McMMOChatEvent{
|
||||
|
||||
public McMMOAdminChatEvent(String sender, String message) {
|
||||
super(sender, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class McMMOChatEvent extends Event implements Cancellable{
|
||||
private boolean cancelled;
|
||||
private String sender;
|
||||
private String message;
|
||||
|
||||
public McMMOChatEvent(String sender, String message) {
|
||||
this.sender = sender;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the player who sent the chat, or "Console"
|
||||
*/
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String message that will be sent
|
||||
*/
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message String message to be sent in chat
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/** 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gmail.nossr50.events.chat;
|
||||
|
||||
/**
|
||||
* Called when a chat is sent to a party channel
|
||||
*/
|
||||
public class McMMOPartyChatEvent extends McMMOChatEvent{
|
||||
private String party;
|
||||
|
||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||
super(sender, message);
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String name of the party the message will be sent to
|
||||
*/
|
||||
public String getParty() {
|
||||
return party;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ 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;
|
||||
|
||||
@@ -17,22 +19,28 @@ public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,18 +4,21 @@ 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 number experience gained in this event
|
||||
*/
|
||||
public int getXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
//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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
// public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
// super(theBlock, player, new ArrayList<ItemStack>(theBlock.getDrops()));
|
||||
// }
|
||||
}
|
||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||
super(theBlock, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ 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);
|
||||
}
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.gmail.nossr50.events.fake;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent{
|
||||
/**
|
||||
* Called when handling extra drops to avoid issues with NoCheat.
|
||||
*/
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
||||
|
||||
public FakePlayerAnimationEvent(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,66 +7,66 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Called when mcMMO is preparing to drop an item
|
||||
* 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;
|
||||
}
|
||||
private Location location;
|
||||
private ItemStack itemStack;
|
||||
private boolean 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@ 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;
|
||||
@@ -25,18 +28,57 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
||||
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();
|
||||
|
||||
@@ -59,11 +101,4 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public enum EventReason{
|
||||
JOINED_PARTY,
|
||||
LEFT_PARTY,
|
||||
KICKED_FROM_PARTY,
|
||||
CHANGED_PARTIES;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ 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;
|
||||
|
||||
@@ -15,10 +17,16 @@ public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,16 @@ 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 int repairAmount;
|
||||
private short repairAmount;
|
||||
private ItemStack repairMaterial;
|
||||
private ItemStack repairedObject;
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPlayerRepairCheckEvent(Player player, int repairAmount, ItemStack repairMaterial, ItemStack repairedObject) {
|
||||
public McMMOPlayerRepairCheckEvent(Player player, short repairAmount, ItemStack repairMaterial, ItemStack repairedObject) {
|
||||
super(player, SkillType.REPAIR);
|
||||
this.repairAmount = repairAmount;
|
||||
this.repairMaterial = repairMaterial;
|
||||
@@ -21,14 +23,23 @@ public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implement
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
public int getRepairAmount() {
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.gmail.nossr50.events.skills;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerRepairEvent extends McMMOPlayerSkillEvent{
|
||||
|
||||
private ItemStack item;
|
||||
private short repairAmount;
|
||||
|
||||
public McMMOPlayerRepairEvent(Player player, ItemStack item, short repairAmount) {
|
||||
super(player, SkillType.REPAIR);
|
||||
this.item = item;
|
||||
this.repairAmount = repairAmount;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getRepairAmount() {
|
||||
return repairAmount;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerSkillEvent extends PlayerEvent{
|
||||
|
||||
/**
|
||||
* Generic event for mcMMO skill handling.
|
||||
*/
|
||||
public class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
@@ -17,10 +19,16 @@ public class McMMOPlayerSkillEvent extends PlayerEvent{
|
||||
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;
|
||||
}
|
||||
@@ -37,4 +45,3 @@ public class McMMOPlayerSkillEvent extends PlayerEvent{
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,23 +2,23 @@ package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.Users;
|
||||
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.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
import com.gmail.nossr50.skills.gathering.WoodCutting;
|
||||
import com.gmail.nossr50.skills.misc.Repair;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
@@ -41,10 +41,10 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
public class mcBlockListener implements Listener {
|
||||
public class BlockListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcBlockListener(final mcMMO plugin) {
|
||||
public BlockListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class mcBlockListener implements Listener {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
if (mcPermissions.getInstance().herbalismDoubleDrops(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
if (mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
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.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@@ -34,16 +30,21 @@ 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;
|
||||
import com.gmail.nossr50.skills.Archery;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Archery;
|
||||
import com.gmail.nossr50.skills.combat.Staves;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.misc.Acrobatics;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class mcEntityListener implements Listener {
|
||||
public class EntityListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public mcEntityListener(final mcMMO plugin) {
|
||||
public EntityListener(final mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -78,6 +79,7 @@ public class mcEntityListener implements Listener {
|
||||
|
||||
if (!m.isInvincible(livingDefender, event)) {
|
||||
Combat.combatChecks(event, plugin);
|
||||
Staves.altFireCheck(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,7 +165,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 +177,7 @@ public class mcEntityListener implements Listener {
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
@@ -195,7 +199,7 @@ public class mcEntityListener implements Listener {
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
@EventHandler (priority = EventPriority.LOW)
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
@@ -307,7 +311,7 @@ public class mcEntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.TAMING, xp, player);
|
||||
PP.addXP(SkillType.TAMING, xp);
|
||||
Skills.XpCheckSkill(SkillType.TAMING, player);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -13,6 +16,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@@ -22,13 +26,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Item;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
|
||||
@@ -36,19 +34,28 @@ 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.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.skills.BlastMining;
|
||||
import com.gmail.nossr50.skills.Fishing;
|
||||
import com.gmail.nossr50.skills.Herbalism;
|
||||
import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Staves;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.misc.Repair;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class mcPlayerListener implements Listener {
|
||||
public class PlayerListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public mcPlayerListener(mcMMO instance) {
|
||||
public PlayerListener(mcMMO instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
@@ -235,6 +242,9 @@ public class mcPlayerListener implements Listener {
|
||||
BlastMining.remoteDetonation(player, plugin);
|
||||
}
|
||||
|
||||
/* STAFF CHECKS */
|
||||
Staves.altFire(is.getType(), player, plugin);
|
||||
|
||||
break;
|
||||
|
||||
case RIGHT_CLICK_AIR:
|
||||
@@ -258,6 +268,9 @@ public class mcPlayerListener implements Listener {
|
||||
BlastMining.remoteDetonation(player, plugin);
|
||||
}
|
||||
|
||||
/* STAFF CHECKS */
|
||||
Staves.altFire(is.getType(), player, plugin);
|
||||
|
||||
break;
|
||||
|
||||
case LEFT_CLICK_AIR:
|
||||
@@ -291,51 +304,56 @@ public class mcPlayerListener implements Listener {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
boolean partyChat = PP.getPartyChatMode();
|
||||
boolean adminChat = PP.getAdminChatMode();
|
||||
Set<Player> recipients = event.getRecipients();
|
||||
|
||||
Set<Player> intendedRecipients = new HashSet<Player>();
|
||||
ChatColor color = null;
|
||||
|
||||
if (partyChat || adminChat) {
|
||||
event.setCancelled(true);
|
||||
|
||||
String name = "";
|
||||
boolean displayNames = false;
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
String logHeader = "";
|
||||
|
||||
/* Set the pChat & aChat specific stuff */
|
||||
if (partyChat) {
|
||||
if (!PP.inParty()) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
|
||||
displayNames = LoadProperties.pDisplayNames;
|
||||
color = ChatColor.GREEN;
|
||||
logHeader = "[P](" + PP.getParty() + ")<";
|
||||
}
|
||||
else if (adminChat) {
|
||||
displayNames = LoadProperties.aDisplayNames;
|
||||
color = ChatColor.AQUA;
|
||||
logHeader = "[A]<";
|
||||
}
|
||||
|
||||
/* Format & display */
|
||||
if (displayNames) {
|
||||
name = player.getDisplayName();
|
||||
}
|
||||
else {
|
||||
name = player.getName();
|
||||
}
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
String format = color + "(" + ChatColor.WHITE + name + color + ") " + event.getMessage();
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (partyChat && Party.getInstance().inSameParty(player, x))
|
||||
x.sendMessage(format);
|
||||
else if (adminChat && (x.isOp() || mcPermissions.getInstance().adminChat(x))) {
|
||||
x.sendMessage(format);
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Party.getInstance().inSameParty(player, x)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
}
|
||||
|
||||
event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s");
|
||||
}
|
||||
|
||||
Bukkit.getLogger().info(logHeader + name + ">" + event.getMessage());
|
||||
if (adminChat) {
|
||||
color = ChatColor.AQUA;
|
||||
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(chatEvent.isCancelled()) return;
|
||||
|
||||
event.setMessage(chatEvent.getMessage());
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
if (x.isOp() || mcPermissions.getInstance().adminChat(x)) {
|
||||
intendedRecipients.add(x);
|
||||
}
|
||||
}
|
||||
|
||||
event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s");
|
||||
}
|
||||
|
||||
recipients.retainAll(intendedRecipients);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,10 +376,17 @@ 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)));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
if (event.getEgg().hasMetadata("mcmmoFiredFromStaff") && event.isHatching()) {
|
||||
event.setHatching(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
/**
|
||||
* Listener for listening to our own events, only really useful for catching errors
|
||||
*/
|
||||
public class mcSelfListener implements Listener {
|
||||
public class SelfListener implements Listener {
|
||||
|
||||
/**
|
||||
* Monitor internal XP gain events.
|
||||
@@ -6,15 +6,15 @@ import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcSpoutInputListener implements Listener {
|
||||
public class SpoutInputListener implements Listener {
|
||||
private mcMMO plugin;
|
||||
|
||||
public mcSpoutInputListener(mcMMO plugin) {
|
||||
public SpoutInputListener(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
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;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcSpoutListener implements Listener {
|
||||
public class SpoutListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutListener(mcMMO pluginx) {
|
||||
|
||||
public SpoutListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Monitor SpoutCraftEnable events.
|
||||
*
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
@@ -16,12 +15,13 @@ import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcSpoutScreenListener implements Listener {
|
||||
public class SpoutScreenListener implements Listener {
|
||||
//Why do we have this here? We never use it...
|
||||
mcMMO plugin = null;
|
||||
|
||||
public mcSpoutScreenListener(mcMMO pluginx) {
|
||||
public SpoutScreenListener(mcMMO pluginx) {
|
||||
plugin = pluginx;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,28 +8,28 @@ 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;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
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;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -40,8 +39,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 {
|
||||
|
||||
@@ -49,12 +46,14 @@ public class mcMMO extends JavaPlugin {
|
||||
public static File file = new File(maindirectory + File.separator + "config.yml");
|
||||
public static File versionFile = new File(maindirectory + File.separator + "VERSION");
|
||||
|
||||
private final mcPlayerListener playerListener = new mcPlayerListener(this);
|
||||
private final mcBlockListener blockListener = new mcBlockListener(this);
|
||||
private final mcEntityListener entityListener = new mcEntityListener(this);
|
||||
private final PlayerListener playerListener = new PlayerListener(this);
|
||||
private final BlockListener blockListener = new BlockListener(this);
|
||||
private final EntityListener entityListener = new EntityListener(this);
|
||||
|
||||
//Alias - Command
|
||||
public HashMap<String, String> aliasMap = new HashMap<String, String>();
|
||||
|
||||
//Various trackers
|
||||
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
|
||||
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
||||
|
||||
@@ -109,12 +108,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 +143,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() {
|
||||
@@ -186,113 +170,32 @@ public class mcMMO extends JavaPlugin {
|
||||
* @param player Player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public static PlayerProfile getPlayerProfile(Player player) {
|
||||
public PlayerProfile getPlayerProfile(Player player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the XP of a player.
|
||||
* Get profile of the player by name.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player
|
||||
* @param skillType
|
||||
* @param player Name of player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public static void checkXp(Player player, SkillType skillType) {
|
||||
if (skillType == SkillType.ALL) {
|
||||
Skills.XpCheckAll(player);
|
||||
}
|
||||
else {
|
||||
Skills.XpCheckSkill(skillType, player);
|
||||
}
|
||||
public PlayerProfile getPlayerProfileByName(String playerName) {
|
||||
return Users.getProfileByName(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two players are in the same party.
|
||||
* Get profile of the offline player.
|
||||
* </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
|
||||
* @param player Offline player whose profile to get
|
||||
* @return the PlayerProfile object
|
||||
*/
|
||||
public static 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 static 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();
|
||||
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
|
||||
return Users.getProfile(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,7 +315,7 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (LoadProperties.mmoeditEnable) {
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand());
|
||||
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||
}
|
||||
|
||||
if (LoadProperties.inspectEnable) {
|
||||
|
||||
@@ -10,250 +10,243 @@ 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;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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))
|
||||
{
|
||||
p.sendMessage(newOwner.getName()+" is the new party owner."); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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(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) {
|
||||
@@ -261,175 +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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete a party.
|
||||
*
|
||||
* @param partyName The party to delete
|
||||
*/
|
||||
private void deleteParty(String partyName) {
|
||||
this.partyPlayers.remove(partyName);
|
||||
this.partyLocks.remove(partyName);
|
||||
this.partyPasswords.remove(partyName);
|
||||
saveParties();
|
||||
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);
|
||||
plugin.getServer().getPlayer(playerName).sendMessage("You are now the party owner."); //TODO: Needs more locale.
|
||||
continue;
|
||||
}
|
||||
if(partyPlayers.get(partyName).get(playerKey)) {
|
||||
plugin.getServer().getPlayer(playerKey).sendMessage("You are no longer party owner."); //TODO: Needs more locale.
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,22 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.util.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() {
|
||||
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
|
||||
if(Users.players.containsKey(player.getName().toLowerCase())) {
|
||||
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.getProfileByName(playerName).save(); //We save here so players don't quit/reconnect to cause lag
|
||||
Users.removeUserByName(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,11 @@ import java.io.FileReader;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
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) {
|
||||
|
||||
37
src/main/java/com/gmail/nossr50/runnables/SpoutStart.java
Normal file
37
src/main/java/com/gmail/nossr50/runnables/SpoutStart.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import java.util.HashSet;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class mcBleedTimer implements Runnable {
|
||||
private final mcMMO plugin;
|
||||
@@ -52,7 +52,7 @@ public class mcBleedTimer implements Runnable {
|
||||
}
|
||||
|
||||
PP.decreaseBleedTicks();
|
||||
|
||||
|
||||
if (PP.getBleedTicks() == 0) {
|
||||
player.sendMessage(mcLocale.getString("Swords.StoppedBleeding"));
|
||||
}
|
||||
|
||||
@@ -2,24 +2,21 @@ package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,58 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -8,14 +8,14 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class Archery {
|
||||
|
||||
@@ -41,50 +41,6 @@ public class Archery {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 (random.nextInt(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.
|
||||
*
|
||||
@@ -107,6 +63,7 @@ public class Archery {
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
|
||||
defender.teleport(loc);
|
||||
Combat.dealDamage(defender, 4);
|
||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
|
||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -11,12 +11,12 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class Axes {
|
||||
|
||||
372
src/main/java/com/gmail/nossr50/skills/combat/Staves.java
Normal file
372
src/main/java/com/gmail/nossr50/skills/combat/Staves.java
Normal file
@@ -0,0 +1,372 @@
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
|
||||
public class Staves {
|
||||
|
||||
/**
|
||||
* Handle the projectile effects from the staves.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void altFireCheck(EntityDamageByEntityEvent event) {
|
||||
LivingEntity defender = (LivingEntity) event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (attacker.hasMetadata("mcmmoFiredFromStaff")) {
|
||||
event.setDamage(0);
|
||||
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
Player shooter = (Player) projectile.getShooter();
|
||||
EntityType type = attacker.getType();
|
||||
|
||||
projectileEffects(defender, shooter, type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire a projectile on alt-fire from a staff.
|
||||
*
|
||||
* @param type The type of staff
|
||||
* @param attacker The attacking player
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void altFire(Material type, Player attacker, mcMMO plugin) {
|
||||
Projectile projectile;
|
||||
|
||||
if (attacker.getItemInHand().getAmount() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case BLAZE_ROD:
|
||||
projectile = attacker.launchProjectile(SmallFireball.class);
|
||||
((SmallFireball) projectile).setIsIncendiary(false);
|
||||
((SmallFireball) projectile).setYield(0f);
|
||||
break;
|
||||
|
||||
case BONE:
|
||||
projectile = attacker.launchProjectile(Snowball.class);
|
||||
break;
|
||||
|
||||
case STICK:
|
||||
projectile = attacker.launchProjectile(Egg.class);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
projectile.setMetadata("mcmmoFiredFromStaff", new FixedMetadataValue(plugin, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Bone's direct hit.
|
||||
*
|
||||
* @param defender The defending player
|
||||
* @param attacker The attacking player
|
||||
*/
|
||||
public static void boneEffect(Player defender, Player attacker) {
|
||||
float xpLost = expLossCalculate();
|
||||
float xpGained = expGainCalculate();
|
||||
|
||||
float attackerXP = attacker.getExp();
|
||||
float defenderXP = defender.getExp();
|
||||
int attackerLevel = attacker.getLevel();
|
||||
int defenderLevel = defender.getLevel();
|
||||
|
||||
if (Party.getInstance().inSameParty(defender, attacker)) {
|
||||
|
||||
//Drain XP
|
||||
if (attackerXP - xpLost < 0f) {
|
||||
if (attackerLevel != 0) {
|
||||
attacker.setLevel(attackerLevel - 1);
|
||||
attacker.setExp(1f - xpLost);
|
||||
attacker.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
||||
}
|
||||
else {
|
||||
attacker.sendMessage("You don't have enough XP to transfer!"); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
attacker.setExp(attackerXP - xpLost);
|
||||
attacker.sendMessage("You transfered some XP to your ally!"); //TODO: Use mcLocale
|
||||
}
|
||||
|
||||
//Reward XP
|
||||
if (defenderXP + xpGained >= 1f) {
|
||||
defender.setLevel(defenderLevel + 1);
|
||||
defender.setExp(0f + xpGained);
|
||||
defender.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
||||
}
|
||||
else {
|
||||
defender.setExp(defenderXP + xpGained);
|
||||
defender.sendMessage("You were given XP from your ally!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
//Drain XP
|
||||
if (defenderXP - xpLost < 0f) {
|
||||
if (defenderLevel != 0) {
|
||||
defender.setLevel(defenderLevel - 1);
|
||||
defender.setExp(1f - xpLost);
|
||||
defender.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
||||
}
|
||||
else {
|
||||
attacker.sendMessage("Your enemy doesn't have enough XP to drain!"); //TODO: Use mcLocale
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
defender.setExp(defenderXP - xpLost);
|
||||
defender.sendMessage("You were drained of XP!"); //TODO: Use mcLocale
|
||||
}
|
||||
|
||||
//Reward XP
|
||||
if (attackerXP + xpGained >= 1f) {
|
||||
attacker.setLevel(attackerLevel + 1);
|
||||
attacker.setExp(0f + xpGained);
|
||||
attacker.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
||||
}
|
||||
else {
|
||||
attacker.setExp(attackerXP + xpGained);
|
||||
attacker.sendMessage("You gained XP from your enemy!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Blaze Rod's direct hit.
|
||||
*
|
||||
* @param target The defending entity
|
||||
* @param attacker The attacking player
|
||||
*/
|
||||
public static void blazeRodEffect(LivingEntity target, Player attacker) {
|
||||
if (target instanceof Player && Party.getInstance().inSameParty((Player) target, attacker)) {
|
||||
target.setFireTicks(0);
|
||||
mcBleedTimer.remove(target);
|
||||
|
||||
for (PotionEffect effect : target.getActivePotionEffects()) {
|
||||
if (effect.getType().equals(PotionEffectType.POISON) || effect.getType().equals(PotionEffectType.WEAKNESS) || effect.getType().equals(PotionEffectType.SLOW)) {
|
||||
target.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
|
||||
attacker.sendMessage("Your ally was cured of all status effects!"); //TODO: Use locale
|
||||
((Player) target).sendMessage("You were cured of all status effects!"); //TODO: Use locale
|
||||
}
|
||||
else {
|
||||
if (target.getFireTicks() + fireTicksCalculate() > target.getMaxFireTicks()) {
|
||||
target.setFireTicks(target.getMaxFireTicks());
|
||||
}
|
||||
else {
|
||||
target.setFireTicks(target.getFireTicks() + fireTicksCalculate());
|
||||
}
|
||||
|
||||
attacker.sendMessage("You set your enemy on fire!"); //TODO: Use locale
|
||||
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage("You were set on fire!"); //TODO: Use locale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the effects of the Stick's direct hit.
|
||||
*
|
||||
* @param target The defending entity
|
||||
* @param attacker The attacking player
|
||||
*/
|
||||
public static void stickEffect(LivingEntity target, Player attacker) {
|
||||
if (target instanceof Player && Party.getInstance().inSameParty((Player) target, attacker)) {
|
||||
Player defender = (Player) target;
|
||||
defender.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, amplifierCalulate()));
|
||||
|
||||
/* Do we WANT to heal food along with health? */
|
||||
if (defender.getFoodLevel() + amplifierCalulate() > 20) {
|
||||
defender.setFoodLevel(20);
|
||||
}
|
||||
else {
|
||||
defender.setFoodLevel(defender.getFoodLevel() + amplifierCalulate());
|
||||
}
|
||||
|
||||
attacker.sendMessage("Your ally was healed!"); //TODO: Use locale
|
||||
defender.sendMessage("You were healed!"); //TODO: Use locale
|
||||
}
|
||||
else {
|
||||
target.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 1, amplifierCalulate()));
|
||||
|
||||
attacker.sendMessage("Your enemy was harmed!"); //TODO: Use locale
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage("You were harmed!"); //TODO: Use locale
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the special effects from the staff projectiles.
|
||||
*
|
||||
* @param defender The defending entity
|
||||
* @param shooter The attacking player
|
||||
* @param type The type of projectile
|
||||
*/
|
||||
private static void projectileEffects(LivingEntity target, Player shooter, EntityType projectile) {
|
||||
final int TICKS_PER_SECOND = 20;
|
||||
final int MAX_SLOW_DURATION_SECONDS = 240;
|
||||
final int MAX_SPEED_DURATION_SECONDS = 480;
|
||||
final int MAX_WEAKNESS_DURATION_SECONDS = 240;
|
||||
final int MAX_STRENGTH_DURATION_SECONDS = 480;
|
||||
final int MAX_POISON_DURATION_SECONDS = 120;
|
||||
final int MAX_REGEN_DURATION_SECONDS = 120;
|
||||
|
||||
Collection<PotionEffect> potionEffects = target.getActivePotionEffects();
|
||||
|
||||
int duration = durationCalulate();
|
||||
int amplifier = amplifierCalulate();
|
||||
PotionEffectType potionType = null;
|
||||
|
||||
if (target instanceof Player && Party.getInstance().inSameParty((Player) target, shooter)) {
|
||||
switch (projectile) {
|
||||
case EGG:
|
||||
potionType = PotionEffectType.REGENERATION;
|
||||
break;
|
||||
|
||||
case SMALL_FIREBALL:
|
||||
potionType = PotionEffectType.SPEED;
|
||||
break;
|
||||
|
||||
case SNOWBALL:
|
||||
potionType = PotionEffectType.INCREASE_DAMAGE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (projectile) {
|
||||
case EGG:
|
||||
potionType = PotionEffectType.POISON;
|
||||
break;
|
||||
|
||||
case SMALL_FIREBALL:
|
||||
potionType = PotionEffectType.SLOW;
|
||||
break;
|
||||
|
||||
case SNOWBALL:
|
||||
potionType = PotionEffectType.WEAKNESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (PotionEffect effect : potionEffects) {
|
||||
if (effect.getType().equals(potionType)) {
|
||||
duration = duration + effect.getDuration();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (potionType.equals(PotionEffectType.SLOW) && duration > (TICKS_PER_SECOND * MAX_SLOW_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_SLOW_DURATION_SECONDS);
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.SPEED) && duration > (TICKS_PER_SECOND * MAX_SPEED_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_SPEED_DURATION_SECONDS);
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.WEAKNESS) && duration > (TICKS_PER_SECOND * MAX_WEAKNESS_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_WEAKNESS_DURATION_SECONDS);
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.INCREASE_DAMAGE) && duration > (TICKS_PER_SECOND * MAX_STRENGTH_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_STRENGTH_DURATION_SECONDS);
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.POISON) && duration > (TICKS_PER_SECOND * MAX_POISON_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_POISON_DURATION_SECONDS);
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.REGENERATION) && duration > (TICKS_PER_SECOND * MAX_REGEN_DURATION_SECONDS)) {
|
||||
duration = (TICKS_PER_SECOND * MAX_REGEN_DURATION_SECONDS);
|
||||
}
|
||||
|
||||
target.addPotionEffect(new PotionEffect(potionType, duration, amplifier));
|
||||
|
||||
if (potionType.equals(PotionEffectType.SLOW)) {
|
||||
shooter.sendMessage("Your enemy was slowed!"); //TODO: Use mcLocale
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage("You were slowed!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.SPEED)) {
|
||||
shooter.sendMessage("Your ally's speed was boosted!"); //TODO: Use mcLocale
|
||||
((Player) target).sendMessage("Your speed was boosted!"); //TODO: Use mcLocale
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.WEAKNESS)) {
|
||||
shooter.sendMessage("Your enemy was weakened!"); //TODO: Use mcLocale
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage("You were weakened!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.INCREASE_DAMAGE)) {
|
||||
shooter.sendMessage("Your ally was strengthened!"); //TODO: Use mcLocale
|
||||
((Player) target).sendMessage("You were strengthened!"); //TODO: Use mcLocale
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.POISON)) {
|
||||
shooter.sendMessage("Your enemy was poisoned!"); //TODO: Use mcLocale
|
||||
if (target instanceof Player) {
|
||||
((Player) target).sendMessage("You were poisoned!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
else if (potionType.equals(PotionEffectType.REGENERATION)) {
|
||||
shooter.sendMessage("Your ally's began regaining health!"); //TODO: Use mcLocale
|
||||
((Player) target).sendMessage("You began regaining health!"); //TODO: Use mcLocale
|
||||
}
|
||||
}
|
||||
|
||||
private static int durationCalulate() {
|
||||
//TODO: Calculate duration based off time held
|
||||
return 80;
|
||||
}
|
||||
|
||||
|
||||
private static int amplifierCalulate() {
|
||||
//TODO: Calculate amplifier based off skill level
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
private static float expLossCalculate() {
|
||||
//TODO: Calculate exp lost based on skill level
|
||||
return 0.25f;
|
||||
}
|
||||
|
||||
|
||||
private static float expGainCalculate() {
|
||||
//TODO: Calculate exp gained based on skill level
|
||||
return 0.10f;
|
||||
}
|
||||
|
||||
private static int fireTicksCalculate() {
|
||||
//TODO: Calculate based on skill level
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -9,17 +9,17 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
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.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class Swords {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -18,15 +18,15 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class Taming {
|
||||
|
||||
@@ -243,7 +243,8 @@ public class Taming {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
|
||||
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(plugin, true));
|
||||
((Tameable) entity).setOwner(player);
|
||||
@@ -252,6 +253,10 @@ public class Taming {
|
||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + random.nextInt(3)));
|
||||
}
|
||||
|
||||
if (entity.getType().equals(EntityType.WOLF)) {
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
}
|
||||
|
||||
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
|
||||
player.sendMessage(mcLocale.getString("m.TamingSummon"));
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class Unarmed {
|
||||
|
||||
@@ -43,16 +44,17 @@ public class Unarmed {
|
||||
* @param PPa Profile of the attacking player
|
||||
* @param defender The defending player
|
||||
*/
|
||||
public static void disarmProcCheck(PlayerProfile PPa, Player defender) {
|
||||
public static void disarmProcCheck(Player attacker, Player defender) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
|
||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
ItemStack inHand = defender.getItemInHand();
|
||||
|
||||
if (!inHand.getType().equals(Material.AIR)) {
|
||||
if (random.nextInt(3000) <= skillCheck) {
|
||||
if (random.nextInt(3000) <= skillCheck && ironGrip(defender, attacker)) {
|
||||
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
|
||||
|
||||
m.mcDropItem(defender.getLocation(), inHand);
|
||||
@@ -78,4 +80,21 @@ public class Unarmed {
|
||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect"));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean ironGrip(Player defender, Player attacker) {
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
int skillLevel = PPd.getSkillLevel(SkillType.UNARMED);
|
||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck) {
|
||||
defender.sendMessage(ChatColor.GREEN + "Your iron grip kept you from being disarmed!"); //TODO: Use locale
|
||||
attacker.sendMessage(ChatColor.RED + "Your opponent has an iron grip!"); //TODO: Use locale
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -15,14 +15,15 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
import com.gmail.nossr50.BlockChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class BlastMining {
|
||||
|
||||
@@ -257,18 +258,18 @@ 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 */
|
||||
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
|
||||
if (!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
|
||||
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Send message to nearby players */
|
||||
for(Player y : player.getWorld().getPlayers()) {
|
||||
if(y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -12,9 +12,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
@@ -104,7 +105,7 @@ public class Excavation {
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()) {
|
||||
if (random.nextInt(100) <= treasure.getDropChance()) {
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
}
|
||||
@@ -120,7 +121,7 @@ public class Excavation {
|
||||
}
|
||||
|
||||
//Handle XP related tasks
|
||||
PP.addXP(SkillType.EXCAVATION, xp, player);
|
||||
PP.addXP(SkillType.EXCAVATION, xp);
|
||||
Skills.XpCheckSkill(SkillType.EXCAVATION, player);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -17,16 +17,17 @@ import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
import com.gmail.nossr50.ItemChecks;
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
|
||||
public class Fishing {
|
||||
|
||||
@@ -98,11 +99,13 @@ public class Fishing {
|
||||
}
|
||||
|
||||
if (LoadProperties.fishingDrops) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
if (rewards.size() > 0) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
|
||||
if (random.nextInt(100) <= treasure.getDropChance()) {
|
||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -115,8 +118,7 @@ public class Fishing {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills;
|
||||
package com.gmail.nossr50.skills.gathering;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -12,16 +12,17 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
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;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.m;
|
||||
import com.gmail.nossr50.util.mcPermissions;
|
||||
|
||||
public class Herbalism {
|
||||
|
||||
@@ -90,6 +91,7 @@ public class Herbalism {
|
||||
case CROPS:
|
||||
case JACK_O_LANTERN:
|
||||
case MELON_BLOCK:
|
||||
case NETHER_WARTS:
|
||||
case PUMPKIN:
|
||||
case RED_MUSHROOM:
|
||||
case RED_ROSE:
|
||||
@@ -227,8 +229,7 @@ public class Herbalism {
|
||||
|
||||
if (mat == null) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else if (mcPermissions.getInstance().herbalismDoubleDrops(player)) {
|
||||
ItemStack is = new ItemStack(mat);
|
||||
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
@@ -250,10 +251,10 @@ public class Herbalism {
|
||||
m.mcDropItem(loc, is);
|
||||
}
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.HERBALISM, xp, player);
|
||||
Skills.XpCheckSkill(SkillType.HERBALISM, player);
|
||||
}
|
||||
|
||||
PP.addXP(SkillType.HERBALISM, xp);
|
||||
Skills.XpCheckSkill(SkillType.HERBALISM, player);
|
||||
}
|
||||
|
||||
/**
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user