mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Major cleanup
This commit is contained in:
parent
f1075f800f
commit
bff7919c21
@ -5,7 +5,8 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.skills.AbilityType;
|
import com.gmail.nossr50.skills.AbilityType;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class AbilityAPI {
|
public final class AbilityAPI {
|
||||||
|
private AbilityAPI() {}
|
||||||
|
|
||||||
public static boolean berserkEnabled(Player player) {
|
public static boolean berserkEnabled(Player player) {
|
||||||
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.ChatManager;
|
import com.gmail.nossr50.util.ChatManager;
|
||||||
|
|
||||||
public final class ChatAPI {
|
public final class ChatAPI {
|
||||||
|
|
||||||
private ChatAPI() {}
|
private ChatAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,8 +16,7 @@ public final class ChatAPI {
|
|||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(String sender, String party, String message) {
|
public static void sendPartyChat(String sender, String party, String message) {
|
||||||
ChatManager chatManager = new ChatManager(mcMMO.p, sender, message);
|
ChatManager.handlePartyChat(PartyManager.getParty(party), sender, message);
|
||||||
chatManager.handlePartyChat(PartyManager.getInstance().getParty(party));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +28,6 @@ public final class ChatAPI {
|
|||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendAdminChat(String sender, String message) {
|
public static void sendAdminChat(String sender, String message) {
|
||||||
ChatManager chatManager = new ChatManager(mcMMO.p, sender, message);
|
ChatManager.handleAdminChat(sender, message);
|
||||||
chatManager.handleAdminChat();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,10 @@ package com.gmail.nossr50.api;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public final class ExperienceAPI {
|
public final class ExperienceAPI {
|
||||||
|
|
||||||
private ExperienceAPI() {}
|
private ExperienceAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,10 +17,10 @@ public final class ExperienceAPI {
|
|||||||
*/
|
*/
|
||||||
private static void checkXP(Player player, SkillType skillType) {
|
private static void checkXP(Player player, SkillType skillType) {
|
||||||
if (skillType.equals(SkillType.ALL)) {
|
if (skillType.equals(SkillType.ALL)) {
|
||||||
Skills.xpCheckAll(player, Users.getProfile(player));
|
SkillTools.xpCheckAll(player, Users.getProfile(player));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
|
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.party.PartyManager;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public final class PartyAPI {
|
public final class PartyAPI {
|
||||||
|
|
||||||
private PartyAPI() {}
|
private PartyAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +45,7 @@ public final class PartyAPI {
|
|||||||
* @return true if the two players are in the same party, false otherwise
|
* @return true if the two players are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player playera, Player playerb) {
|
public static boolean inSameParty(Player playera, Player playerb) {
|
||||||
return PartyManager.getInstance().inSameParty(playera, playerb);
|
return PartyManager.inSameParty(playera, playerb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +56,7 @@ public final class PartyAPI {
|
|||||||
* @return the list of parties.
|
* @return the list of parties.
|
||||||
*/
|
*/
|
||||||
public static List<Party> getParties() {
|
public static List<Party> getParties() {
|
||||||
return PartyManager.getInstance().getParties();
|
return PartyManager.getParties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +68,7 @@ public final class PartyAPI {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
Party party = PartyManager.getInstance().getParty(partyName);
|
Party party = PartyManager.getParty(partyName);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@ -78,7 +77,7 @@ public final class PartyAPI {
|
|||||||
party.setLeader(playerName);
|
party.setLeader(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.getInstance().addToParty(playerName, Users.getProfile(player), party);
|
PartyManager.addToParty(playerName, Users.getProfile(player), party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +88,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(Player player) {
|
public static void removeFromParty(Player player) {
|
||||||
PartyManager.getInstance().removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
PartyManager.removeFromParty(player.getName(), Users.getProfile(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +100,7 @@ public final class PartyAPI {
|
|||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public static String getPartyLeader(String partyName) {
|
public static String getPartyLeader(String partyName) {
|
||||||
return PartyManager.getInstance().getPartyLeader(partyName);
|
return PartyManager.getPartyLeader(partyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +112,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to set as leader
|
* @param player The player to set as leader
|
||||||
*/
|
*/
|
||||||
public static void setPartyLeader(String partyName, String player) {
|
public static void setPartyLeader(String partyName, String player) {
|
||||||
PartyManager.getInstance().setPartyLeader(player, PartyManager.getInstance().getParty(partyName));
|
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +124,7 @@ public final class PartyAPI {
|
|||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
public static List<String> getAllMembers(Player player) {
|
public static List<String> getAllMembers(Player player) {
|
||||||
return PartyManager.getInstance().getAllMembers(player);
|
return PartyManager.getAllMembers(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +136,7 @@ public final class PartyAPI {
|
|||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(String partyName) {
|
public static List<Player> getOnlineMembers(String partyName) {
|
||||||
return PartyManager.getInstance().getOnlineMembers(partyName);
|
return PartyManager.getOnlineMembers(partyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,6 +148,6 @@ public final class PartyAPI {
|
|||||||
* @return all online players in the player's party
|
* @return all online players in the player's party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(Player player) {
|
public static List<Player> getOnlineMembers(Player player) {
|
||||||
return PartyManager.getInstance().getOnlineMembers(player);
|
return PartyManager.getOnlineMembers(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,14 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.skills.ToolType;
|
import com.gmail.nossr50.skills.ToolType;
|
||||||
|
|
||||||
public final class SpoutToolsAPI {
|
public final class SpoutToolsAPI {
|
||||||
|
|
||||||
private SpoutToolsAPI() {}
|
|
||||||
|
|
||||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||||
|
|
||||||
|
private SpoutToolsAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||||
* </br>
|
* </br>
|
||||||
|
@ -6,11 +6,12 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class CommandHelper {
|
public final class CommandHelper {
|
||||||
|
private CommandHelper() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for command permissions.
|
* Checks for command permissions.
|
||||||
@ -48,7 +49,7 @@ public class CommandHelper {
|
|||||||
* @param display The sender to display stats to
|
* @param display The sender to display stats to
|
||||||
*/
|
*/
|
||||||
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
||||||
if (Skills.hasGatheringSkills(inspect)) {
|
if (SkillTools.hasGatheringSkills(inspect)) {
|
||||||
PlayerProfile profile = Users.getProfile(inspect);
|
PlayerProfile profile = Users.getProfile(inspect);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
@ -91,7 +92,7 @@ public class CommandHelper {
|
|||||||
* @param display The sender to display stats to
|
* @param display The sender to display stats to
|
||||||
*/
|
*/
|
||||||
public static void printCombatSkills(Player inspect, CommandSender display) {
|
public static void printCombatSkills(Player inspect, CommandSender display) {
|
||||||
if (Skills.hasCombatSkills(inspect)) {
|
if (SkillTools.hasCombatSkills(inspect)) {
|
||||||
PlayerProfile profile = Users.getProfile(inspect);
|
PlayerProfile profile = Users.getProfile(inspect);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
@ -134,7 +135,7 @@ public class CommandHelper {
|
|||||||
* @param display The sender to display stats to
|
* @param display The sender to display stats to
|
||||||
*/
|
*/
|
||||||
public static void printMiscSkills(Player inspect, CommandSender display) {
|
public static void printMiscSkills(Player inspect, CommandSender display) {
|
||||||
if (Skills.hasMiscSkills(inspect)) {
|
if (SkillTools.hasMiscSkills(inspect)) {
|
||||||
PlayerProfile profile = Users.getProfile(inspect);
|
PlayerProfile profile = Users.getProfile(inspect);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
@ -11,17 +11,11 @@ import com.gmail.nossr50.commands.CommandHelper;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class AddlevelsCommand implements CommandExecutor{
|
public class AddlevelsCommand implements CommandExecutor{
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public AddlevelsCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
OfflinePlayer modifiedPlayer;
|
OfflinePlayer modifiedPlayer;
|
||||||
@ -37,7 +31,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!Skills.isSkill(args[0])) {
|
if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -45,7 +39,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
if (Misc.isInt(args[1])) {
|
if (Misc.isInt(args[1])) {
|
||||||
modifiedPlayer = (Player) sender;
|
modifiedPlayer = (Player) sender;
|
||||||
levels = Integer.valueOf(args[1]);
|
levels = Integer.valueOf(args[1]);
|
||||||
skill = Skills.getSkillType(args[0]);
|
skill = SkillTools.getSkillType(args[0]);
|
||||||
profile = Users.getProfile(modifiedPlayer);
|
profile = Users.getProfile(modifiedPlayer);
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
@ -65,7 +59,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||||
String playerName = modifiedPlayer.getName();
|
String playerName = modifiedPlayer.getName();
|
||||||
profile = Users.getProfile(modifiedPlayer);
|
profile = Users.getProfile(modifiedPlayer);
|
||||||
|
|
||||||
@ -79,14 +73,14 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Skills.isSkill(args[1])) {
|
if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.isInt(args[2])) {
|
if (Misc.isInt(args[2])) {
|
||||||
levels = Integer.valueOf(args[2]);
|
levels = Integer.valueOf(args[2]);
|
||||||
skill = Skills.getSkillType(args[1]);
|
skill = SkillTools.getSkillType(args[1]);
|
||||||
|
|
||||||
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
Users.getProfile(modifiedPlayer).addLevels(skill, levels);
|
||||||
|
|
||||||
|
@ -11,18 +11,12 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
//TODO: Any way we can make this work for offline use?
|
//TODO: Any way we can make this work for offline use?
|
||||||
public class AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public AddxpCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Player modifiedPlayer;
|
Player modifiedPlayer;
|
||||||
@ -37,7 +31,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!Skills.isSkill(args[1])) {
|
if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -45,7 +39,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
if (Misc.isInt(args[1])) {
|
if (Misc.isInt(args[1])) {
|
||||||
modifiedPlayer = (Player) sender;
|
modifiedPlayer = (Player) sender;
|
||||||
xp = Integer.valueOf(args[1]);
|
xp = Integer.valueOf(args[1]);
|
||||||
skill = Skills.getSkillType(args[0]);
|
skill = SkillTools.getSkillType(args[0]);
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||||
@ -59,10 +53,10 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -76,7 +70,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
modifiedPlayer = mcMMO.p.getServer().getPlayer(args[0]);
|
||||||
String playerName = modifiedPlayer.getName();
|
String playerName = modifiedPlayer.getName();
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||||
@ -91,14 +85,14 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Skills.isSkill(args[1])) {
|
if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Misc.isInt(args[2])) {
|
if (Misc.isInt(args[2])) {
|
||||||
xp = Integer.valueOf(args[2]);
|
xp = Integer.valueOf(args[2]);
|
||||||
skill = Skills.getSkillType(args[1]);
|
skill = SkillTools.getSkillType(args[1]);
|
||||||
|
|
||||||
mcMMOPlayer.addXPOverride(skill, xp);
|
mcMMOPlayer.addXPOverride(skill, xp);
|
||||||
|
|
||||||
@ -111,11 +105,11 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", new Object[] {xp}));
|
||||||
Skills.xpCheckAll(modifiedPlayer, profile);
|
SkillTools.xpCheckAll(modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", new Object[] {xp, Misc.getCapitalized(skill.toString())}));
|
||||||
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
|
SkillTools.xpCheckSkill(skill, modifiedPlayer, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McstatsCommand implements CommandExecutor {
|
public class McstatsCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
@ -10,7 +10,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!Skills.isSkill(args[0])) {
|
if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
if (Misc.isInt(args[1])) {
|
if (Misc.isInt(args[1])) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
newValue = Integer.valueOf(args[1]);
|
newValue = Integer.valueOf(args[1]);
|
||||||
skill = Skills.getSkillType(args[0]);
|
skill = SkillTools.getSkillType(args[0]);
|
||||||
profile = Users.getProfile(player);
|
profile = Users.getProfile(player);
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (skill.equals(SkillType.ALL)) {
|
||||||
@ -67,7 +67,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = Skills.getSkillType(args[1]);
|
skill = SkillTools.getSkillType(args[1]);
|
||||||
|
|
||||||
if (skill == null) {
|
if (skill == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
|
@ -12,7 +12,6 @@ import com.gmail.nossr50.skills.SkillType;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SkillResetCommand implements CommandExecutor {
|
public class SkillResetCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
@ -12,14 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class XprateCommand implements CommandExecutor {
|
public class XprateCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
|
||||||
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
|
||||||
private boolean xpEvent;
|
|
||||||
|
|
||||||
public XprateCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.xpEvent = plugin.isXPEventEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@ -31,20 +24,21 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean xpEventEnabled = mcMMO.p.isXPEventEnabled();
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (args[0].equalsIgnoreCase("reset")) {
|
if (args[0].equalsIgnoreCase("reset")) {
|
||||||
if (xpEvent) {
|
if (xpEventEnabled) {
|
||||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||||
}
|
}
|
||||||
|
|
||||||
xpEvent = !xpEvent;
|
mcMMO.p.setXPEventEnabled(!xpEventEnabled);
|
||||||
plugin.setXPEventEnabled(xpEvent);
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||||
Config.getInstance().xpGainMultiplier = oldRate;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Config.getInstance().xpGainMultiplier = oldRate;
|
Config.getInstance().setExperienceGainsGlobalMultiplier(originalRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Misc.isInt(args[0])) {
|
else if (Misc.isInt(args[0])) {
|
||||||
@ -58,26 +52,24 @@ public class XprateCommand implements CommandExecutor {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (Misc.isInt(args[0])) {
|
if (Misc.isInt(args[0])) {
|
||||||
oldRate = Config.getInstance().xpGainMultiplier;
|
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||||
xpEvent = Boolean.valueOf(args[1]);
|
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
|
||||||
plugin.setXPEventEnabled(xpEvent);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(usage3);
|
sender.sendMessage(usage3);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
int newRate = Misc.getInt(args[0]);
|
||||||
|
Config.getInstance().setExperienceGainsGlobalMultiplier(newRate);
|
||||||
|
|
||||||
if (xpEvent) {
|
if (xpEventEnabled) {
|
||||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
|
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {newRate}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {Config.getInstance().xpGainMultiplier}));
|
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", new Object[] {newRate}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McabilityCommand implements CommandExecutor {
|
public class McabilityCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
@ -12,7 +12,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
|
|
||||||
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
|
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
|
||||||
public class MccCommand implements CommandExecutor {
|
public class MccCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McgodCommand implements CommandExecutor {
|
public class McgodCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
|
@ -31,8 +31,7 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {mcMMO.p.getDescription().getVersion()}));
|
sender.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {mcMMO.p.getDescription().getVersion()}));
|
||||||
|
|
||||||
Anniversary anniversary = new Anniversary();
|
Anniversary.anniversaryCheck(sender);
|
||||||
anniversary.anniversaryCheck(sender);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.McRankAsync;
|
import com.gmail.nossr50.runnables.McRankAsync;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Leaderboard;
|
import com.gmail.nossr50.util.Leaderboard;
|
||||||
|
|
||||||
public class McrankCommand implements CommandExecutor {
|
public class McrankCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
//TODO: Better input handling, add usage string
|
//TODO: Better input handling, add usage string
|
||||||
@ -67,10 +66,10 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} )); //Don't bother showing ranking for players without skills
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class McrefreshCommand implements CommandExecutor {
|
public class McrefreshCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public McrefreshCommand(mcMMO instance) {
|
|
||||||
this.plugin = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
OfflinePlayer player;
|
OfflinePlayer player;
|
||||||
@ -42,7 +36,7 @@ public class McrefreshCommand implements CommandExecutor {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
player = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||||
profile = Users.getProfile(player);
|
profile = Users.getProfile(player);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
|
@ -8,17 +8,15 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Leaderboard;
|
import com.gmail.nossr50.util.Leaderboard;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class MctopCommand implements CommandExecutor {
|
public class MctopCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"});
|
String usage = LocaleLoader.getString("Commands.Usage.2", new Object[] {"mctop", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"});
|
||||||
@ -34,11 +32,11 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
if (Misc.isInt(args[0])) {
|
if (Misc.isInt(args[0])) {
|
||||||
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
|
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isSkill(args[0])) {
|
else if (SkillTools.isSkill(args[0])) {
|
||||||
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
flatfileDisplay(1, args[0].toUpperCase(), sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
flatfileDisplay(1, Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
flatfileDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -48,11 +46,11 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (Misc.isInt(args[1])) {
|
if (Misc.isInt(args[1])) {
|
||||||
if (Skills.isSkill(args[0])) {
|
if (SkillTools.isSkill(args[0])) {
|
||||||
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
flatfileDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
flatfileDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toUpperCase(), sender);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -81,11 +79,11 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
if (Misc.isInt(args[0])) {
|
if (Misc.isInt(args[0])) {
|
||||||
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
|
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isSkill(args[0])) {
|
else if (SkillTools.isSkill(args[0])) {
|
||||||
sqlDisplay(1, args[0].toLowerCase(), sender);
|
sqlDisplay(1, args[0].toLowerCase(), sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
sqlDisplay(1, Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
sqlDisplay(1, SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -95,11 +93,11 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (Misc.isInt(args[1])) {
|
if (Misc.isInt(args[1])) {
|
||||||
if (Skills.isSkill(args[0])) {
|
if (SkillTools.isSkill(args[0])) {
|
||||||
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
|
||||||
}
|
}
|
||||||
else if (Skills.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
sqlDisplay(Integer.valueOf(args[1]), Skills.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
sqlDisplay(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]).toLowerCase(), sender);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -151,9 +149,7 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
|
|
||||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
HashMap<Integer, ArrayList<String>> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
|
|
||||||
|
|
||||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
|
@ -7,10 +7,12 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
super("advanced.yml");
|
super("advanced.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdvancedConfig getInstance() {
|
public static AdvancedConfig getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new AdvancedConfig();
|
instance = new AdvancedConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
|
|
||||||
public class Config extends ConfigLoader {
|
public class Config extends ConfigLoader {
|
||||||
private static Config instance;
|
private static Config instance;
|
||||||
public double xpGainMultiplier = 1;
|
|
||||||
|
|
||||||
private Config() {
|
private Config() {
|
||||||
super("config.yml");
|
super("config.yml");
|
||||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
|
||||||
loadKeys();
|
loadKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +361,7 @@ public class Config extends ConfigLoader {
|
|||||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||||
|
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
|
||||||
|
|
||||||
/* Combat XP Multipliers */
|
/* Combat XP Multipliers */
|
||||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||||
|
@ -16,7 +16,7 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||||
|
|
||||||
public class TreasuresConfig extends ConfigLoader{
|
public class TreasuresConfig extends ConfigLoader {
|
||||||
private static TreasuresConfig instance;
|
private static TreasuresConfig instance;
|
||||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||||
|
@ -22,12 +22,12 @@ import com.gmail.nossr50.spout.SpoutStuff;
|
|||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Database {
|
public final class Database {
|
||||||
|
private Database() {}
|
||||||
|
|
||||||
private static Config configInstance = Config.getInstance();
|
|
||||||
private static String connectionString;
|
private static String connectionString;
|
||||||
|
|
||||||
private static String tablePrefix = configInstance.getMySQLTablePrefix();
|
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
private static Connection connection = null;
|
private static Connection connection = null;
|
||||||
private static mcMMO plugin = null;
|
private static mcMMO plugin = null;
|
||||||
|
|
||||||
@ -49,16 +49,13 @@ public class Database {
|
|||||||
// How many connection attemtps have failed
|
// How many connection attemtps have failed
|
||||||
private static int reconnectAttempt = 0;
|
private static int reconnectAttempt = 0;
|
||||||
|
|
||||||
public Database(mcMMO instance) {
|
|
||||||
plugin = instance;
|
|
||||||
checkConnected(); //Connect to MySQL
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to connect to the mySQL database.
|
* Attempt to connect to the mySQL database.
|
||||||
*/
|
*/
|
||||||
public static void connect() {
|
public static void connect() {
|
||||||
|
Config configInstance = Config.getInstance();
|
||||||
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ public class Database {
|
|||||||
/**
|
/**
|
||||||
* Attempt to create the database structure.
|
* Attempt to create the database structure.
|
||||||
*/
|
*/
|
||||||
public void createStructure() {
|
public static void createStructure() {
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||||
+ "`user` varchar(40) NOT NULL,"
|
+ "`user` varchar(40) NOT NULL,"
|
||||||
@ -158,7 +155,7 @@ public class Database {
|
|||||||
*
|
*
|
||||||
* @param update Type of data to check updates for
|
* @param update Type of data to check updates for
|
||||||
*/
|
*/
|
||||||
public void checkDatabaseStructure(DatabaseUpdate update) {
|
private static void checkDatabaseStructure(DatabaseUpdate update) {
|
||||||
String sql = null;
|
String sql = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
@ -256,7 +253,7 @@ public class Database {
|
|||||||
* @param sql Query to write.
|
* @param sql Query to write.
|
||||||
* @return true if the query was successfully written, false otherwise.
|
* @return true if the query was successfully written, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean write(String sql) {
|
public static boolean write(String sql) {
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
@ -288,7 +285,7 @@ public class Database {
|
|||||||
* @param sql SQL query to execute
|
* @param sql SQL query to execute
|
||||||
* @return the number of rows affected
|
* @return the number of rows affected
|
||||||
*/
|
*/
|
||||||
public int update(String sql) {
|
public static int update(String sql) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
@ -320,7 +317,7 @@ public class Database {
|
|||||||
* @param sql SQL query to execute
|
* @param sql SQL query to execute
|
||||||
* @return the value in the first row / first field
|
* @return the value in the first row / first field
|
||||||
*/
|
*/
|
||||||
public int getInt(String sql) {
|
public static int getInt(String sql) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
@ -416,7 +413,7 @@ public class Database {
|
|||||||
if (connection != null && !connection.isClosed()) {
|
if (connection != null && !connection.isClosed()) {
|
||||||
// Schedule a database save if we really had an outage
|
// Schedule a database save if we really had an outage
|
||||||
if (reconnectAttempt > 1) {
|
if (reconnectAttempt > 1) {
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(), 5);
|
||||||
}
|
}
|
||||||
nextReconnectTimestamp = 0;
|
nextReconnectTimestamp = 0;
|
||||||
reconnectAttempt = 0;
|
reconnectAttempt = 0;
|
||||||
@ -441,7 +438,7 @@ public class Database {
|
|||||||
* @param sql SQL query to read
|
* @param sql SQL query to read
|
||||||
* @return the rows in this SQL query
|
* @return the rows in this SQL query
|
||||||
*/
|
*/
|
||||||
public HashMap<Integer, ArrayList<String>> read(String sql) {
|
public static HashMap<Integer, ArrayList<String>> read(String sql) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
HashMap<Integer, ArrayList<String>> rows = new HashMap<Integer, ArrayList<String>>();
|
||||||
|
|
||||||
@ -470,7 +467,7 @@ public class Database {
|
|||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Integer> readSQLRank(String playerName) {
|
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
@ -512,7 +509,7 @@ public class Database {
|
|||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgePowerlessSQL() {
|
public static void purgePowerlessSQL() {
|
||||||
plugin.getLogger().info("Purging powerless users...");
|
plugin.getLogger().info("Purging powerless users...");
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
||||||
@ -532,7 +529,7 @@ public class Database {
|
|||||||
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
plugin.getLogger().info("Purged " + purgedUsers + " users from the database.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void purgeOldSQL() {
|
public static void purgeOldSQL() {
|
||||||
plugin.getLogger().info("Purging old users...");
|
plugin.getLogger().info("Purging old users...");
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
long purgeTime = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||||
|
@ -4,15 +4,12 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
public class McpurgeCommand implements CommandExecutor{
|
public class McpurgeCommand implements CommandExecutor{
|
||||||
private Database database = mcMMO.getPlayerDatabase();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {
|
||||||
@ -20,10 +17,10 @@ public class McpurgeCommand implements CommandExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
database.purgePowerlessSQL();
|
Database.purgePowerlessSQL();
|
||||||
|
|
||||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||||
database.purgeOldSQL();
|
Database.purgeOldSQL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -16,14 +16,6 @@ import com.gmail.nossr50.database.Database;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
public class McremoveCommand implements CommandExecutor {
|
public class McremoveCommand implements CommandExecutor {
|
||||||
private final String location;
|
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public McremoveCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.location = mcMMO.getUsersFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String playerName;
|
String playerName;
|
||||||
@ -49,9 +41,8 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
|
|
||||||
/* MySQL */
|
/* MySQL */
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
affected = database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
affected = Database.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'");
|
||||||
|
|
||||||
if (affected > 0) {
|
if (affected > 0) {
|
||||||
sender.sendMessage(success);
|
sender.sendMessage(success);
|
||||||
@ -78,9 +69,10 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
FileWriter out = null;
|
FileWriter out = null;
|
||||||
|
String usersFilePath = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileReader file = new FileReader(location);
|
FileReader file = new FileReader(usersFilePath);
|
||||||
in = new BufferedReader(file);
|
in = new BufferedReader(file);
|
||||||
StringBuilder writer = new StringBuilder();
|
StringBuilder writer = new StringBuilder();
|
||||||
String line = "";
|
String line = "";
|
||||||
@ -98,11 +90,11 @@ public class McremoveCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out = new FileWriter(location); //Write out the new file
|
out = new FileWriter(usersFilePath); //Write out the new file
|
||||||
out.write(writer.toString());
|
out.write(writer.toString());
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (in != null) {
|
if (in != null) {
|
||||||
|
@ -13,12 +13,6 @@ import com.gmail.nossr50.runnables.SQLConversionTask;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class MmoupdateCommand implements CommandExecutor {
|
public class MmoupdateCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public MmoupdateCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
|
||||||
@ -29,7 +23,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
|||||||
Users.clearAll();
|
Users.clearAll();
|
||||||
convertToMySQL();
|
convertToMySQL();
|
||||||
|
|
||||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
for (Player x : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
Users.addUser(x);
|
Users.addUser(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +40,6 @@ public class MmoupdateCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new SQLConversionTask(plugin), 1);
|
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class McMMOPlayer {
|
|||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.profile = new PlayerProfile(playerName, true);
|
this.profile = new PlayerProfile(playerName, true);
|
||||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
this.party = PartyManager.getPlayerParty(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -112,7 +112,7 @@ public class McMMOPlayer {
|
|||||||
* @param newValue The amount of XP to add
|
* @param newValue The amount of XP to add
|
||||||
*/
|
*/
|
||||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||||
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
int modifiedXp = (int)Math.floor(xp * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||||
addXPOverride(skillType, modifiedXp);
|
addXPOverride(skillType, modifiedXp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class McMMOPlayer {
|
|||||||
bonusModifier = calculatePartyXPModifier(skillType);
|
bonusModifier = calculatePartyXPModifier(skillType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().getExperienceGainsGlobalMultiplier());
|
||||||
|
|
||||||
if (bonusModifier > 0) {
|
if (bonusModifier > 0) {
|
||||||
if (bonusModifier >= 2) {
|
if (bonusModifier >= 2) {
|
||||||
|
@ -59,11 +59,11 @@ public class PlayerProfile {
|
|||||||
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||||
|
|
||||||
private final static String location = mcMMO.getUsersFile();
|
private final static String location = mcMMO.getUsersFilePath();
|
||||||
|
|
||||||
public PlayerProfile(String playerName, boolean addNew) {
|
public PlayerProfile(String playerName, boolean addNew) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
party = PartyManager.getInstance().getPlayerParty(playerName);
|
party = PartyManager.getPlayerParty(playerName);
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
@ -93,19 +93,18 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadMySQL() {
|
public boolean loadMySQL() {
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
userId = Database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||||
|
|
||||||
if (userId == 0) {
|
if (userId == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
HashMap<Integer, ArrayList<String>> huds = Database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||||
|
|
||||||
if (huds.get(1) == null) {
|
if (huds.get(1) == null) {
|
||||||
database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (HudType type : HudType.values()) {
|
for (HudType type : HudType.values()) {
|
||||||
@ -119,11 +118,11 @@ public class PlayerProfile {
|
|||||||
* I'm still learning MySQL, this is a fix for adding a new table
|
* I'm still learning MySQL, this is a fix for adding a new table
|
||||||
* its not pretty but it works
|
* its not pretty but it works
|
||||||
*/
|
*/
|
||||||
HashMap<Integer, ArrayList<String>> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
HashMap<Integer, ArrayList<String>> cooldowns = Database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||||
ArrayList<String> cooldownValues = cooldowns.get(1);
|
ArrayList<String> cooldownValues = cooldowns.get(1);
|
||||||
|
|
||||||
if (cooldownValues == null) {
|
if (cooldownValues == null) {
|
||||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -137,11 +136,11 @@ public class PlayerProfile {
|
|||||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
HashMap<Integer, ArrayList<String>> stats = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||||
ArrayList<String> statValues = stats.get(1);
|
ArrayList<String> statValues = stats.get(1);
|
||||||
|
|
||||||
if (statValues == null) {
|
if (statValues == null) {
|
||||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -159,11 +158,11 @@ public class PlayerProfile {
|
|||||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
HashMap<Integer, ArrayList<String>> experience = Database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||||
ArrayList<String> experienceValues = experience.get(1);
|
ArrayList<String> experienceValues = experience.get(1);
|
||||||
|
|
||||||
if (experienceValues == null) {
|
if (experienceValues == null) {
|
||||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -186,14 +185,13 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addMySQLPlayer() {
|
public void addMySQLPlayer() {
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
Database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||||
userId = database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
userId = Database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
Database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean load() {
|
public boolean load() {
|
||||||
@ -307,12 +305,11 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
// if we are using mysql save to database
|
// if we are using mysql save to database
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
Database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||||
database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId);
|
Database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + ((int) (timestamp / Misc.TIME_CONVERSION_FACTOR)) + " WHERE id = " + userId);
|
||||||
database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
Database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||||
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
||||||
@ -322,7 +319,7 @@ public class PlayerProfile {
|
|||||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||||
+ " WHERE user_id = " + userId);
|
+ " WHERE user_id = " + userId);
|
||||||
database.write("UPDATE " + tablePrefix + "skills SET "
|
Database.write("UPDATE " + tablePrefix + "skills SET "
|
||||||
+ " taming = " + skills.get(SkillType.TAMING)
|
+ " taming = " + skills.get(SkillType.TAMING)
|
||||||
+ ", mining = " + skills.get(SkillType.MINING)
|
+ ", mining = " + skills.get(SkillType.MINING)
|
||||||
+ ", repair = " + skills.get(SkillType.REPAIR)
|
+ ", repair = " + skills.get(SkillType.REPAIR)
|
||||||
@ -336,7 +333,7 @@ public class PlayerProfile {
|
|||||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||||
+ " WHERE user_id = " + userId);
|
+ " WHERE user_id = " + userId);
|
||||||
database.write("UPDATE " + tablePrefix + "experience SET "
|
Database.write("UPDATE " + tablePrefix + "experience SET "
|
||||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||||
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
||||||
|
@ -4,8 +4,6 @@ public class PlayerStat {
|
|||||||
public String name;
|
public String name;
|
||||||
public int statVal = 0;
|
public int statVal = 0;
|
||||||
|
|
||||||
public PlayerStat() {};
|
|
||||||
|
|
||||||
public PlayerStat(String name, int value) {
|
public PlayerStat(String name, int value) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.statVal = value;
|
this.statVal = value;
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.datatypes.treasure;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class ExcavationTreasure extends Treasure {
|
public class ExcavationTreasure extends Treasure {
|
||||||
|
|
||||||
// dirt | grass | sand | gravel | clay | mycel | soulsand
|
// dirt | grass | sand | gravel | clay | mycel | soulsand
|
||||||
// 00000001 - dirt 1
|
// 00000001 - dirt 1
|
||||||
// 00000010 - grass 2
|
// 00000010 - grass 2
|
||||||
|
@ -3,8 +3,7 @@ package com.gmail.nossr50.events.chat;
|
|||||||
/**
|
/**
|
||||||
* Called when a chat is sent to the admin chat channel
|
* Called when a chat is sent to the admin chat channel
|
||||||
*/
|
*/
|
||||||
public class McMMOAdminChatEvent extends McMMOChatEvent{
|
public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||||
|
|
||||||
public McMMOAdminChatEvent(String sender, String message) {
|
public McMMOAdminChatEvent(String sender, String message) {
|
||||||
super(sender, message);
|
super(sender, message);
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class McMMOChatEvent extends Event implements Cancellable{
|
public class McMMOChatEvent extends Event implements Cancellable {
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private String sender;
|
private String sender;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
public McMMOChatEvent(String sender, String message) {
|
protected McMMOChatEvent(String sender, String message) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.events.chat;
|
|||||||
/**
|
/**
|
||||||
* Called when a chat is sent to a party channel
|
* Called when a chat is sent to a party channel
|
||||||
*/
|
*/
|
||||||
public class McMMOPartyChatEvent extends McMMOChatEvent{
|
public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||||
private String party;
|
private String party;
|
||||||
|
|
||||||
public McMMOPartyChatEvent(String sender, String party, String message) {
|
public McMMOPartyChatEvent(String sender, String party, String message) {
|
||||||
|
@ -9,11 +9,11 @@ import com.gmail.nossr50.skills.SkillType;
|
|||||||
/**
|
/**
|
||||||
* Generic event for mcMMO experience events.
|
* Generic event for mcMMO experience events.
|
||||||
*/
|
*/
|
||||||
public class McMMOPlayerExperienceEvent extends PlayerEvent {
|
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent {
|
||||||
protected SkillType skill;
|
protected SkillType skill;
|
||||||
protected int skillLevel;
|
protected int skillLevel;
|
||||||
|
|
||||||
public McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||||
super(player);
|
super(player);
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.skillLevel = skill.getSkillLevel(player);
|
this.skillLevel = skill.getSkillLevel(player);
|
||||||
|
@ -8,7 +8,6 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
* Called when mcMMO breaks a block due to a special ability.
|
* Called when mcMMO breaks a block due to a special ability.
|
||||||
*/
|
*/
|
||||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
||||||
|
|
||||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||||
super(theBlock, player);
|
super(theBlock, player);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
* Called when mcMMO damages a block due to a special ability.
|
* Called when mcMMO damages a block due to a special ability.
|
||||||
*/
|
*/
|
||||||
public class FakeBlockDamageEvent extends BlockDamageEvent {
|
public class FakeBlockDamageEvent extends BlockDamageEvent {
|
||||||
|
|
||||||
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
||||||
super(player, block, itemInHand, instaBreak);
|
super(player, block, itemInHand, instaBreak);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||||
|
|
||||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||||
super(damager, damagee, cause, damage);
|
super(damager, damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
* Called when mcMMO applies damage due to special abilities.
|
* Called when mcMMO applies damage due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
||||||
|
|
||||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||||
super(damagee, cause, damage);
|
super(damagee, cause, damage);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
|||||||
* Called when handling extra drops to avoid issues with NoCheat.
|
* Called when handling extra drops to avoid issues with NoCheat.
|
||||||
*/
|
*/
|
||||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
||||||
|
|
||||||
public FakePlayerAnimationEvent(Player player) {
|
public FakePlayerAnimationEvent(Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,11 @@ import org.bukkit.event.player.PlayerEvent;
|
|||||||
/**
|
/**
|
||||||
* Called when a player attempts to join, leave, or change parties.
|
* Called when a player attempts to join, leave, or change parties.
|
||||||
*/
|
*/
|
||||||
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable{
|
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
|
||||||
|
private String oldParty;
|
||||||
protected String oldParty;
|
private String newParty;
|
||||||
protected String newParty;
|
private EventReason reason;
|
||||||
protected EventReason reason;
|
private boolean cancelled;
|
||||||
protected boolean cancelled;
|
|
||||||
|
|
||||||
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
public McMMOPartyChangeEvent(Player player, String oldParty, String newParty, EventReason reason) {
|
||||||
super(player);
|
super(player);
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
/**
|
/**
|
||||||
* Called just before a player teleports using the /ptp command.
|
* Called just before a player teleports using the /ptp command.
|
||||||
*/
|
*/
|
||||||
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent{
|
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
|
||||||
private String party;
|
private String party;
|
||||||
private Player target;
|
private Player target;
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@ import com.gmail.nossr50.skills.SkillType;
|
|||||||
/**
|
/**
|
||||||
* Generic event for mcMMO skill handling.
|
* Generic event for mcMMO skill handling.
|
||||||
*/
|
*/
|
||||||
public class McMMOPlayerSkillEvent extends PlayerEvent {
|
public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
|
||||||
protected SkillType skill;
|
protected SkillType skill;
|
||||||
protected int skillLevel;
|
protected int skillLevel;
|
||||||
|
|
||||||
public McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||||
super(player);
|
super(player);
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.skillLevel = skill.getSkillLevel(player);
|
this.skillLevel = skill.getSkillLevel(player);
|
||||||
|
@ -27,7 +27,7 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|||||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
import com.gmail.nossr50.skills.AbilityType;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.skills.ToolType;
|
import com.gmail.nossr50.skills.ToolType;
|
||||||
import com.gmail.nossr50.skills.excavation.Excavation;
|
import com.gmail.nossr50.skills.excavation.Excavation;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
@ -149,7 +149,7 @@ public class BlockListener implements Listener {
|
|||||||
if (BlockChecks.canBeGreenTerra(block)) {
|
if (BlockChecks.canBeGreenTerra(block)) {
|
||||||
/* Green Terra */
|
/* Green Terra */
|
||||||
if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) {
|
if (profile.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -272,19 +272,19 @@ public class BlockListener implements Listener {
|
|||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
|
||||||
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) {
|
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
SkillTools.abilityCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) {
|
else if (profile.getToolPreparationMode(ToolType.AXE) && ItemChecks.isAxe(heldItem) && BlockChecks.isLog(block) && Permissions.treeFeller(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
SkillTools.abilityCheck(player, SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && Permissions.superBreaker(player)) {
|
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && ItemChecks.isPickaxe(heldItem) && BlockChecks.canBeSuperBroken(block) && Permissions.superBreaker(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.MINING);
|
SkillTools.abilityCheck(player, SkillType.MINING);
|
||||||
}
|
}
|
||||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) {
|
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
SkillTools.abilityCheck(player, SkillType.EXCAVATION);
|
||||||
}
|
}
|
||||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)) && Permissions.berserk(player)) {
|
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)) && Permissions.berserk(player)) {
|
||||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ public class BlockListener implements Listener {
|
|||||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) {
|
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) {
|
||||||
Herbalism.greenTerra(player, block);
|
Herbalism.greenTerra(player, block);
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||||
if (Excavation.requiresTool) {
|
if (Excavation.requiresTool) {
|
||||||
if (ItemChecks.isShovel(heldItem)) {
|
if (ItemChecks.isShovel(heldItem)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
@ -339,7 +339,7 @@ public class BlockListener implements Listener {
|
|||||||
Excavation.gigaDrillBreaker(player, block);
|
Excavation.gigaDrillBreaker(player, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||||
if (heldItem.getType().equals(Material.AIR)) {
|
if (heldItem.getType().equals(Material.AIR)) {
|
||||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||||
@ -351,7 +351,7 @@ public class BlockListener implements Listener {
|
|||||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||||
MiningManager miningManager = new MiningManager(player);
|
MiningManager miningManager = new MiningManager(player);
|
||||||
|
|
||||||
if (Mining.requiresTool) {
|
if (Mining.requiresTool) {
|
||||||
@ -366,7 +366,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= Woodcutting.LEAF_BLOWER_UNLOCK_LEVEL) && BlockChecks.isLeaves(block)) {
|
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= Woodcutting.LEAF_BLOWER_UNLOCK_LEVEL) && BlockChecks.isLeaves(block)) {
|
||||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||||
if (Woodcutting.REQUIRES_TOOL) {
|
if (Woodcutting.REQUIRES_TOOL) {
|
||||||
if (ItemChecks.isAxe(heldItem)) {
|
if (ItemChecks.isAxe(heldItem)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
|
@ -110,7 +110,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker instanceof Player && PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
|
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
public class HardcoreListener implements Listener {
|
public class HardcoreListener implements Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor PlayerDeath events.
|
* Monitor PlayerDeath events.
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@ -26,7 +25,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.runnables.BleedTimer;
|
import com.gmail.nossr50.runnables.BleedTimer;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.skills.fishing.Fishing;
|
||||||
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
import com.gmail.nossr50.skills.herbalism.Herbalism;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
import com.gmail.nossr50.skills.mining.BlastMining;
|
||||||
@ -36,14 +35,13 @@ import com.gmail.nossr50.skills.repair.Salvage;
|
|||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
import com.gmail.nossr50.util.ChatManager;
|
import com.gmail.nossr50.util.ChatManager;
|
||||||
import com.gmail.nossr50.util.Item;
|
import com.gmail.nossr50.util.ChimaeraWing;
|
||||||
import com.gmail.nossr50.util.MOTD;
|
import com.gmail.nossr50.util.Motd;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public PlayerListener(final mcMMO plugin) {
|
public PlayerListener(final mcMMO plugin) {
|
||||||
@ -154,20 +152,11 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
|
||||||
PluginDescriptionFile pluginDescription = plugin.getDescription();
|
Motd.displayAll(player);
|
||||||
MOTD motd = new MOTD(player);
|
|
||||||
|
|
||||||
motd.displayVersion(pluginDescription.getVersion());
|
|
||||||
motd.displayHardcoreSettings();
|
|
||||||
motd.displayXpPerks();
|
|
||||||
motd.displayCooldownPerks();
|
|
||||||
motd.displayActivationPerks();
|
|
||||||
motd.displayLuckyPerks();
|
|
||||||
motd.displayWebsite(pluginDescription.getWebsite());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.isXPEventEnabled()) {
|
if (plugin.isXPEventEnabled()) {
|
||||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().getExperienceGainsGlobalMultiplier()}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,20 +254,20 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* ACTIVATION & ITEM CHECKS */
|
/* ACTIVATION & ITEM CHECKS */
|
||||||
if (BlockChecks.canActivateAbilities(block)) {
|
if (BlockChecks.canActivateAbilities(block)) {
|
||||||
if (Skills.abilitiesEnabled) {
|
if (SkillTools.abilitiesEnabled) {
|
||||||
if (BlockChecks.canActivateHerbalism(block)) {
|
if (BlockChecks.canActivateHerbalism(block)) {
|
||||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.activationCheck(player, SkillType.AXES);
|
SkillTools.activationCheck(player, SkillType.AXES);
|
||||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||||
Skills.activationCheck(player, SkillType.MINING);
|
SkillTools.activationCheck(player, SkillType.MINING);
|
||||||
Skills.activationCheck(player, SkillType.SWORDS);
|
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||||
Skills.activationCheck(player, SkillType.UNARMED);
|
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item.itemChecks(player);
|
ChimaeraWing.activationCheck(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GREEN THUMB CHECK */
|
/* GREEN THUMB CHECK */
|
||||||
@ -291,18 +280,18 @@ public class PlayerListener implements Listener {
|
|||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
|
|
||||||
/* ACTIVATION CHECKS */
|
/* ACTIVATION CHECKS */
|
||||||
if (Skills.abilitiesEnabled) {
|
if (SkillTools.abilitiesEnabled) {
|
||||||
Skills.activationCheck(player, SkillType.AXES);
|
SkillTools.activationCheck(player, SkillType.AXES);
|
||||||
Skills.activationCheck(player, SkillType.EXCAVATION);
|
SkillTools.activationCheck(player, SkillType.EXCAVATION);
|
||||||
Skills.activationCheck(player, SkillType.HERBALISM);
|
SkillTools.activationCheck(player, SkillType.HERBALISM);
|
||||||
Skills.activationCheck(player, SkillType.MINING);
|
SkillTools.activationCheck(player, SkillType.MINING);
|
||||||
Skills.activationCheck(player, SkillType.SWORDS);
|
SkillTools.activationCheck(player, SkillType.SWORDS);
|
||||||
Skills.activationCheck(player, SkillType.UNARMED);
|
SkillTools.activationCheck(player, SkillType.UNARMED);
|
||||||
Skills.activationCheck(player, SkillType.WOODCUTTING);
|
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ITEM CHECKS */
|
/* ITEM CHECKS */
|
||||||
Item.itemChecks(player);
|
ChimaeraWing.activationCheck(player);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -352,13 +341,11 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatManager chatManager = new ChatManager(plugin, player.getName(), event.getMessage());
|
ChatManager.handlePartyChat(party, player.getName(), event.getMessage());
|
||||||
chatManager.handlePartyChat(party);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else if (profile.getAdminChatMode()) {
|
else if (profile.getAdminChatMode()) {
|
||||||
ChatManager chatManager = new ChatManager(plugin, player.getName(), event.getMessage());
|
ChatManager.handleAdminChat(player.getName(), event.getMessage());
|
||||||
chatManager.handleAdminChat();
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
|||||||
* Listener for listening to our own events, only really useful for catching errors
|
* Listener for listening to our own events, only really useful for catching errors
|
||||||
*/
|
*/
|
||||||
public class SelfListener implements Listener {
|
public class SelfListener implements Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor internal XP gain events.
|
* Monitor internal XP gain events.
|
||||||
*
|
*
|
||||||
|
@ -9,10 +9,12 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
|
|
||||||
public class LocaleLoader {
|
public final class LocaleLoader {
|
||||||
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
|
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
|
||||||
private static ResourceBundle RESOURCE_BUNDLE = null;
|
private static ResourceBundle RESOURCE_BUNDLE = null;
|
||||||
|
|
||||||
|
private LocaleLoader() {};
|
||||||
|
|
||||||
public static String getString(String key) {
|
public static String getString(String key) {
|
||||||
return getString(key, null);
|
return getString(key, null);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||||
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
||||||
|
|
||||||
private static Database database;
|
|
||||||
public static mcMMO p;
|
public static mcMMO p;
|
||||||
|
|
||||||
public static ChunkManager placeStore;
|
public static ChunkManager placeStore;
|
||||||
@ -181,8 +180,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Setup the leader boards
|
//Setup the leader boards
|
||||||
if (configInstance.getUseMySQL()) {
|
if (configInstance.getUseMySQL()) {
|
||||||
database = new Database(this);
|
Database.connect();
|
||||||
database.createStructure();
|
Database.createStructure();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Leaderboard.updateLeaderboards();
|
Leaderboard.updateLeaderboards();
|
||||||
@ -199,9 +198,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
//Schedule Spout Activation 1 second after start-up
|
//Schedule Spout Activation 1 second after start-up
|
||||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||||
//Periodic save timer (Saves every 10 minutes by default)
|
//Periodic save timer (Saves every 10 minutes by default)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), 0, configInstance.getSaveInterval() * 1200);
|
||||||
//Regen & Cooldown timer (Runs every second)
|
//Regen & Cooldown timer (Runs every second)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 0, 20);
|
||||||
//Bleed timer (Runs every two seconds)
|
//Bleed timer (Runs every two seconds)
|
||||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||||
|
|
||||||
@ -253,8 +252,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
new MobStoreCleaner();
|
new MobStoreCleaner();
|
||||||
|
|
||||||
// Create Anniversary files
|
// Create Anniversary files
|
||||||
Anniversary anniversary = new Anniversary();
|
Anniversary.createAnniversaryFile();
|
||||||
anniversary.createAnniversaryFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -311,7 +309,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Users.saveAll(); //Make sure to save player information if the server shuts down
|
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||||
PartyManager.getInstance().saveParties();
|
PartyManager.saveParties();
|
||||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||||
placeStore.saveAll(); //Save our metadata
|
placeStore.saveAll(); //Save our metadata
|
||||||
placeStore.cleanUp(); //Cleanup empty metadata stores
|
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||||
@ -323,9 +321,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
getLogger().severe(e.toString());
|
getLogger().severe(e.toString());
|
||||||
}
|
}
|
||||||
Anniversary anniversary = new Anniversary();
|
|
||||||
anniversary.saveAnniversaryFiles();
|
|
||||||
|
|
||||||
|
Anniversary.saveAnniversaryFiles();
|
||||||
getLogger().info("Was disabled."); //How informative!
|
getLogger().info("Was disabled."); //How informative!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +369,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
||||||
}
|
}
|
||||||
if (configInstance.getCommandMCRemoveEnabled()) {
|
if (configInstance.getCommandMCRemoveEnabled()) {
|
||||||
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandMCAbilityEnabled()) {
|
if (configInstance.getCommandMCAbilityEnabled()) {
|
||||||
@ -392,7 +389,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandMCRefreshEnabled()) {
|
if (configInstance.getCommandMCRefreshEnabled()) {
|
||||||
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
getCommand("mcrefresh").setExecutor(new McrefreshCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandMCTopEnabled()) {
|
if (configInstance.getCommandMCTopEnabled()) {
|
||||||
@ -413,11 +410,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Party commands
|
//Party commands
|
||||||
if (configInstance.getCommandAdminChatAEnabled()) {
|
if (configInstance.getCommandAdminChatAEnabled()) {
|
||||||
getCommand("a").setExecutor(new ACommand(this));
|
getCommand("a").setExecutor(new ACommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandPartyEnabled()) {
|
if (configInstance.getCommandPartyEnabled()) {
|
||||||
getCommand("party").setExecutor(new PartyCommand(this));
|
getCommand("party").setExecutor(new PartyCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandPartyChatPEnabled()) {
|
if (configInstance.getCommandPartyChatPEnabled()) {
|
||||||
@ -430,11 +427,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Other commands
|
//Other commands
|
||||||
if (configInstance.getCommandAddXPEnabled()) {
|
if (configInstance.getCommandAddXPEnabled()) {
|
||||||
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
getCommand("addxp").setExecutor(new AddxpCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandAddLevelsEnabled()) {
|
if (configInstance.getCommandAddLevelsEnabled()) {
|
||||||
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
getCommand("addlevels").setExecutor(new AddlevelsCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandMmoeditEnabled()) {
|
if (configInstance.getCommandMmoeditEnabled()) {
|
||||||
@ -446,10 +443,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (configInstance.getCommandXPRateEnabled()) {
|
if (configInstance.getCommandXPRateEnabled()) {
|
||||||
getCommand("xprate").setExecutor(new XprateCommand(this));
|
getCommand("xprate").setExecutor(new XprateCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||||
|
|
||||||
//Spout commands
|
//Spout commands
|
||||||
if (configInstance.getCommandXPLockEnabled()) {
|
if (configInstance.getCommandXPLockEnabled()) {
|
||||||
@ -542,7 +539,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return flatFileDirectory;
|
return flatFileDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUsersFile() {
|
public static String getUsersFilePath() {
|
||||||
return usersFile;
|
return usersFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,10 +547,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return modDirectory;
|
return modDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Database getPlayerDatabase() {
|
|
||||||
return database;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isXPEventEnabled() {
|
public boolean isXPEventEnabled() {
|
||||||
return xpEventEnabled;
|
return xpEventEnabled;
|
||||||
}
|
}
|
||||||
|
@ -12,26 +12,9 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyManager {
|
public final class PartyManager {
|
||||||
private static String partiesFilePath;
|
private static String partiesFilePath = mcMMO.p.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
|
||||||
private static List<Party> parties = new ArrayList<Party>();
|
private static List<Party> parties = new ArrayList<Party>();
|
||||||
private static mcMMO plugin;
|
|
||||||
private static PartyManager instance;
|
|
||||||
|
|
||||||
private PartyManager() {
|
|
||||||
plugin = mcMMO.p;
|
|
||||||
partiesFilePath = plugin.getDataFolder().getPath() + File.separator + "FlatFileStuff" + File.separator + "parties.yml";
|
|
||||||
|
|
||||||
loadParties();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PartyManager getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new PartyManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if two players are in the same party.
|
* Check if two players are in the same party.
|
||||||
@ -40,7 +23,7 @@ public class PartyManager {
|
|||||||
* @param secondPlayer The second player
|
* @param secondPlayer The second player
|
||||||
* @return true if they are in the same party, false otherwise
|
* @return true if they are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
||||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
||||||
|
|
||||||
@ -64,7 +47,7 @@ public class PartyManager {
|
|||||||
* @param playerName The name of the player that joins
|
* @param playerName The name of the player that joins
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private void informPartyMembersJoin(String playerName, Party party) {
|
private static void informPartyMembersJoin(String playerName, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.getName().equals(playerName)) {
|
if (!member.getName().equals(playerName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
|
||||||
@ -78,7 +61,7 @@ public class PartyManager {
|
|||||||
* @param playerName The name of the player that quits
|
* @param playerName The name of the player that quits
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private void informPartyMembersQuit(String playerName, Party party) {
|
private static void informPartyMembersQuit(String playerName, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.getName().equals(playerName)) {
|
if (!member.getName().equals(playerName)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
|
||||||
@ -92,7 +75,7 @@ public class PartyManager {
|
|||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
public List<String> getAllMembers(Player player) {
|
public static List<String> getAllMembers(Player player) {
|
||||||
Party party = Users.getProfile(player).getParty();
|
Party party = Users.getProfile(player).getParty();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@ -108,7 +91,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party to check
|
* @param partyName The party to check
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public List<Player> getOnlineMembers(String partyName) {
|
public static List<Player> getOnlineMembers(String partyName) {
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@ -124,7 +107,7 @@ public class PartyManager {
|
|||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public List<Player> getOnlineMembers(Player player) {
|
public static List<Player> getOnlineMembers(Player player) {
|
||||||
return getOnlineMembers(player.getName());
|
return getOnlineMembers(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +117,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public Party getParty(String partyName) {
|
public static Party getParty(String partyName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
if (party.getName().equals(partyName)) {
|
if (party.getName().equals(partyName)) {
|
||||||
return party;
|
return party;
|
||||||
@ -150,7 +133,7 @@ public class PartyManager {
|
|||||||
* @param playerName The member name
|
* @param playerName The member name
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public Party getPlayerParty(String playerName) {
|
public static Party getPlayerParty(String playerName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
if (party.getMembers().contains(playerName)) {
|
if (party.getMembers().contains(playerName)) {
|
||||||
return party;
|
return party;
|
||||||
@ -164,7 +147,7 @@ public class PartyManager {
|
|||||||
*
|
*
|
||||||
* @return the list of parties.
|
* @return the list of parties.
|
||||||
*/
|
*/
|
||||||
public List<Party> getParties() {
|
public static List<Party> getParties() {
|
||||||
return parties;
|
return parties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +157,7 @@ public class PartyManager {
|
|||||||
* @param playerName The name of the player to remove
|
* @param playerName The name of the player to remove
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public void removeFromParty(String playerName, Party party) {
|
public static void removeFromParty(String playerName, Party party) {
|
||||||
List<String> members = party.getMembers();
|
List<String> members = party.getMembers();
|
||||||
|
|
||||||
members.remove(playerName);
|
members.remove(playerName);
|
||||||
@ -204,7 +187,7 @@ public class PartyManager {
|
|||||||
*
|
*
|
||||||
* @param party The party to remove
|
* @param party The party to remove
|
||||||
*/
|
*/
|
||||||
public void disbandParty(Party party) {
|
public static void disbandParty(Party party) {
|
||||||
List<String> members = party.getMembers();
|
List<String> members = party.getMembers();
|
||||||
|
|
||||||
for (String member : party.getMembers()) {
|
for (String member : party.getMembers()) {
|
||||||
@ -229,7 +212,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
* @param password the password for this party, null if there was no password
|
* @param password the password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public void createParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
public static void createParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
@ -264,7 +247,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
* @param password the password for this party, null if there was no password
|
* @param password the password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
public static void joinParty(Player player, PlayerProfile playerProfile, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
@ -299,7 +282,7 @@ public class PartyManager {
|
|||||||
* @param password The password provided by the player
|
* @param password The password provided by the player
|
||||||
* @return true if the player can join the party
|
* @return true if the player can join the party
|
||||||
*/
|
*/
|
||||||
public boolean checkJoinability(Player player, Party party, String password) {
|
public static boolean checkJoinability(Player player, Party party, String password) {
|
||||||
//Don't care about passwords if it isn't locked
|
//Don't care about passwords if it isn't locked
|
||||||
if (party.isLocked()) {
|
if (party.isLocked()) {
|
||||||
String partyPassword = party.getPassword();
|
String partyPassword = party.getPassword();
|
||||||
@ -330,7 +313,7 @@ public class PartyManager {
|
|||||||
* @param player The player to add to the party
|
* @param player The player to add to the party
|
||||||
* @param playerProfile The profile of the player
|
* @param playerProfile The profile of the player
|
||||||
*/
|
*/
|
||||||
public void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
public static void joinInvitedParty(Player player, PlayerProfile playerProfile) {
|
||||||
Party invite = playerProfile.getInvite();
|
Party invite = playerProfile.getInvite();
|
||||||
|
|
||||||
if (!parties.contains(invite)) {
|
if (!parties.contains(invite)) {
|
||||||
@ -349,7 +332,7 @@ public class PartyManager {
|
|||||||
* @param playerProfile The profile of the player
|
* @param playerProfile The profile of the player
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
public static void addToParty(String playerName, PlayerProfile playerProfile, Party party) {
|
||||||
informPartyMembersJoin(playerName, party);
|
informPartyMembersJoin(playerName, party);
|
||||||
playerProfile.setParty(party);
|
playerProfile.setParty(party);
|
||||||
party.getMembers().add(playerName);
|
party.getMembers().add(playerName);
|
||||||
@ -361,7 +344,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public String getPartyLeader(String partyName) {
|
public static String getPartyLeader(String partyName) {
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@ -377,7 +360,7 @@ public class PartyManager {
|
|||||||
* @param playerName The name of the player to set as leader
|
* @param playerName The name of the player to set as leader
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public void setPartyLeader(String playerName, Party party) {
|
public static void setPartyLeader(String playerName, Party party) {
|
||||||
String leaderName = party.getLeader();
|
String leaderName = party.getLeader();
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
@ -402,7 +385,7 @@ public class PartyManager {
|
|||||||
* @param playerProfile The profile of the given player
|
* @param playerProfile The profile of the given player
|
||||||
* @return true if the player can invite
|
* @return true if the player can invite
|
||||||
*/
|
*/
|
||||||
public boolean canInvite(Player player, PlayerProfile playerProfile) {
|
public static boolean canInvite(Player player, PlayerProfile playerProfile) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
|
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
|
||||||
@ -418,7 +401,7 @@ public class PartyManager {
|
|||||||
* @param partyName The party name to check
|
* @param partyName The party name to check
|
||||||
* @return true if this is a valid party, false otherwise
|
* @return true if this is a valid party, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean isParty(String partyName) {
|
public static boolean isParty(String partyName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
if (party.getName().equals(partyName)) {
|
if (party.getName().equals(partyName)) {
|
||||||
return true;
|
return true;
|
||||||
@ -431,7 +414,7 @@ public class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Load party file.
|
* Load party file.
|
||||||
*/
|
*/
|
||||||
private void loadParties() {
|
private static void loadParties() {
|
||||||
File file = new File(partiesFilePath);
|
File file = new File(partiesFilePath);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
@ -462,7 +445,7 @@ public class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Save party file.
|
* Save party file.
|
||||||
*/
|
*/
|
||||||
public void saveParties() {
|
public static void saveParties() {
|
||||||
File file = new File(partiesFilePath);
|
File file = new File(partiesFilePath);
|
||||||
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -14,12 +14,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class ACommand implements CommandExecutor {
|
public class ACommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public ACommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
@ -68,7 +62,7 @@ public class ACommand implements CommandExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
@ -77,9 +71,9 @@ public class ACommand implements CommandExecutor {
|
|||||||
message = chatEvent.getMessage();
|
message = chatEvent.getMessage();
|
||||||
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {player.getName()} );
|
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {player.getName()} );
|
||||||
|
|
||||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
mcMMO.p.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||||
|
|
||||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
for (Player otherPlayer : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||||
otherPlayer.sendMessage(prefix + message);
|
otherPlayer.sendMessage(prefix + message);
|
||||||
}
|
}
|
||||||
@ -87,7 +81,7 @@ public class ACommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message);
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
@ -96,9 +90,9 @@ public class ACommand implements CommandExecutor {
|
|||||||
message = chatEvent.getMessage();
|
message = chatEvent.getMessage();
|
||||||
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
String prefix = LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {LocaleLoader.getString("Commands.Chat.Console")} );
|
||||||
|
|
||||||
plugin.getLogger().info("[A]<*Console*> " + message);
|
mcMMO.p.getLogger().info("[A]<*Console*> " + message);
|
||||||
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
if (Permissions.adminChat(player) || player.isOp()) {
|
if (Permissions.adminChat(player) || player.isOp()) {
|
||||||
player.sendMessage(prefix + message);
|
player.sendMessage(prefix + message);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class PCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PartyManager.getInstance().isParty(args[0])) {
|
if (!PartyManager.isParty(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class PCommand implements CommandExecutor {
|
|||||||
|
|
||||||
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
|
||||||
|
|
||||||
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
|
for (Player member : PartyManager.getOnlineMembers(args[0])) {
|
||||||
member.sendMessage(prefix + message);
|
member.sendMessage(prefix + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,6 @@ import com.gmail.nossr50.party.PartyManager;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PartyCommand implements CommandExecutor {
|
public class PartyCommand implements CommandExecutor {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public PartyCommand (mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
@ -38,51 +32,71 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
if(args.length < 1)
|
if (args.length < 1) {
|
||||||
return party(sender);
|
return party(sender);
|
||||||
|
}
|
||||||
|
|
||||||
if(args[0].equalsIgnoreCase("join"))
|
if (args[0].equalsIgnoreCase("join")) {
|
||||||
return join(sender, args);
|
return join(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("accept"))
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("accept")) {
|
||||||
return accept(sender, args);
|
return accept(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("create"))
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("create")) {
|
||||||
return create(sender, args);
|
return create(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("info"))
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("info")) {
|
||||||
return party(sender);
|
return party(sender);
|
||||||
else if(args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help"))
|
}
|
||||||
return help(sender, args);
|
else if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) {
|
||||||
|
return printHelp(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
if (playerProfile.inParty()) {
|
if (playerProfile.inParty()) {
|
||||||
if(args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave"))
|
if(args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) {
|
||||||
return quit(sender, args);
|
return quit(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("expshare"))
|
}
|
||||||
return expshare(sender, args);
|
else if(args[0].equalsIgnoreCase("expshare")) {
|
||||||
else if(args[0].equalsIgnoreCase("itemshare"))
|
return shareExp(sender, args);
|
||||||
return itemshare(sender, args);
|
}
|
||||||
else if(args[0].equalsIgnoreCase("invite"))
|
else if(args[0].equalsIgnoreCase("itemshare")) {
|
||||||
|
return shareItem(sender, args);
|
||||||
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("invite")) {
|
||||||
return invite(sender, args);
|
return invite(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("kick"))
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("kick")) {
|
||||||
return kick(sender, args);
|
return kick(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("disband"))
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("disband")) {
|
||||||
return disband(sender, args);
|
return disband(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("owner"))
|
}
|
||||||
return owner(sender, args);
|
else if(args[0].equalsIgnoreCase("owner")) {
|
||||||
else if(args[0].equalsIgnoreCase("lock"))
|
return changeOwner(sender, args);
|
||||||
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("lock")) {
|
||||||
return lock(sender, args);
|
return lock(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("unlock"))
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("unlock")) {
|
||||||
return unlock(sender, args);
|
return unlock(sender, args);
|
||||||
else if(args[0].equalsIgnoreCase("password"))
|
}
|
||||||
return password(sender, args);
|
else if(args[0].equalsIgnoreCase("password")) {
|
||||||
else if(args[0].equalsIgnoreCase("rename"))
|
return changePassword(sender, args);
|
||||||
|
}
|
||||||
|
else if(args[0].equalsIgnoreCase("rename")) {
|
||||||
return rename(sender, args);
|
return rename(sender, args);
|
||||||
else
|
}
|
||||||
return usage(sender);
|
else {
|
||||||
} else {
|
return printUsage(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
return usage(sender);
|
return printUsage(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean usage(CommandSender sender) {
|
private boolean printUsage(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||||
@ -97,7 +111,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
if (playerProfile.inParty()) {
|
if (playerProfile.inParty()) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
Server server = plugin.getServer();
|
Server server = mcMMO.p.getServer();
|
||||||
String leader = party.getLeader();
|
String leader = party.getLeader();
|
||||||
StringBuffer tempList = new StringBuffer();
|
StringBuffer tempList = new StringBuffer();
|
||||||
|
|
||||||
@ -123,127 +137,137 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
// player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode", new Object[] { "NONE", "NONE" })); Party share modes will get implemented later
|
// player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode", new Object[] { "NONE", "NONE" })); Party share modes will get implemented later
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
|
||||||
} else {
|
}
|
||||||
return usage(sender);
|
else {
|
||||||
|
return printUsage(sender);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean join(CommandSender sender, String[] args) {
|
private boolean join(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.join"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.join")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if(args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Player target = Bukkit.getServer().getPlayer(args[1]);
|
Player target = Bukkit.getServer().getPlayer(args[1]);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOnline", new Object[] {args[1]}));
|
player.sendMessage(LocaleLoader.getString("Party.NotOnline", new Object[] {args[1]}));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Users.getProfile(target).inParty()) {
|
if (!Users.getProfile(target).inParty()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", new Object[] {args[1]}));
|
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", new Object[] {args[1]}));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String password = null;
|
|
||||||
if(args.length > 2) password = args[2];
|
|
||||||
|
|
||||||
String partyTarget = partyManagerInstance.getPlayerParty(target.getName()).getName();
|
String password = null;
|
||||||
Party newParty = partyManagerInstance.getParty(args[0]);
|
|
||||||
|
if(args.length > 2) {
|
||||||
|
password = args[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
String partyTarget = PartyManager.getPlayerParty(target.getName()).getName();
|
||||||
|
Party newParty = PartyManager.getParty(args[0]);
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does, can the player join it?
|
// Check to see if the party exists, and if it does, can the player join it?
|
||||||
if (newParty != null && !partyManagerInstance.checkJoinability(player, newParty, null)) {
|
if (newParty != null && !PartyManager.checkJoinability(player, newParty, null)) {
|
||||||
return true; // End before any event is fired.
|
return true; // End before any event is fired.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), partyTarget, EventReason.CHANGED_PARTIES);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), partyTarget, EventReason.CHANGED_PARTIES);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
partyManagerInstance.removeFromParty(playerName, party);
|
|
||||||
|
PartyManager.removeFromParty(playerName, party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyTarget, EventReason.JOINED_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyTarget, EventReason.JOINED_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.joinParty(player, playerProfile, partyTarget, password);
|
PartyManager.joinParty(player, playerProfile, partyTarget, password);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean accept(CommandSender sender, String[] args) {
|
private boolean accept(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.accept"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.accept")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
if (playerProfile.hasPartyInvite()) {
|
if (playerProfile.hasPartyInvite()) {
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
|
|
||||||
if (playerProfile.inParty()) {
|
if (playerProfile.inParty()) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), playerProfile.getInvite().getName(), EventReason.CHANGED_PARTIES);
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(player.getName(), party);
|
PartyManager.removeFromParty(player.getName(), party);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, playerProfile.getInvite().getName(), EventReason.JOINED_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
partyManagerInstance.joinInvitedParty(player, playerProfile);
|
|
||||||
|
PartyManager.joinInvitedParty(player, playerProfile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean create(CommandSender sender, String[] args) {
|
private boolean create(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.create"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.create")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if(args.length < 2) {
|
if(args.length < 2) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
String partyname = args[1];
|
String partyname = args[1];
|
||||||
String password = null;
|
String password = null;
|
||||||
if(args.length > 2) password = args[2];
|
if(args.length > 2) password = args[2];
|
||||||
|
|
||||||
Party newParty = partyManagerInstance.getParty(partyname);
|
Party newParty = PartyManager.getParty(partyname);
|
||||||
// Check to see if the party exists, and if it does cancel creating a new party
|
// Check to see if the party exists, and if it does cancel creating a new party
|
||||||
if (newParty != null) {
|
if (newParty != null) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {partyname}));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {partyname}));
|
||||||
@ -253,68 +277,67 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
if (playerProfile.inParty()) {
|
if (playerProfile.inParty()) {
|
||||||
String oldPartyName = party.getName();
|
String oldPartyName = party.getName();
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, partyname, EventReason.CHANGED_PARTIES);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, partyname, EventReason.CHANGED_PARTIES);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.removeFromParty(playerName, party);
|
PartyManager.removeFromParty(playerName, party);
|
||||||
partyManagerInstance.createParty(player, playerProfile, partyname, password);
|
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyname, EventReason.JOINED_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, partyname, EventReason.JOINED_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
partyManagerInstance.createParty(player, playerProfile, partyname, password);
|
PartyManager.createParty(player, playerProfile, partyname, password);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean quit(CommandSender sender, String[] args) {
|
private boolean quit(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.quit"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.quit")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
partyManagerInstance.removeFromParty(playerName, party);
|
PartyManager.removeFromParty(playerName, party);
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean expshare(CommandSender sender, String[] args) {
|
private boolean shareExp(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.expshare"))
|
return (!CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.expshare"));
|
||||||
return true;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean itemshare(CommandSender sender, String[] args) {
|
private boolean shareItem(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.itemshare"))
|
return (!CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.itemshare"));
|
||||||
return true;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean help(CommandSender sender, String[] args) {
|
private boolean printHelp(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
|
||||||
@ -327,8 +350,9 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean invite(CommandSender sender, String[] args) {
|
private boolean invite(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.invite"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.invite")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -340,14 +364,14 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = plugin.getServer().getPlayer(args[1]);
|
Player target = mcMMO.p.getServer().getPlayer(args[1]);
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
if (PartyManager.inSameParty(player, target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty"));
|
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
|
if (PartyManager.canInvite(player, playerProfile)) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
Users.getProfile(target).setInvite(party);
|
Users.getProfile(target).setInvite(party);
|
||||||
@ -360,6 +384,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -373,13 +398,13 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
* Kick a party member
|
* Kick a party member
|
||||||
*/
|
*/
|
||||||
private boolean kick(CommandSender sender, String[] args) {
|
private boolean kick(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.kick"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.kick")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
@ -388,22 +413,27 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player target = plugin.getServer().getOfflinePlayer(args[1]).getPlayer();
|
Player target = mcMMO.p.getServer().getOfflinePlayer(args[1]).getPlayer();
|
||||||
|
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
String partyName = party.getName();
|
String partyName = party.getName();
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
|
||||||
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] {partyName}));
|
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] {partyName}));
|
||||||
}
|
}
|
||||||
partyManagerInstance.removeFromParty(args[1], party);
|
|
||||||
|
PartyManager.removeFromParty(args[1], party);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,59 +441,63 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
* Disband the current party, kicks out all party members.
|
* Disband the current party, kicks out all party members.
|
||||||
*/
|
*/
|
||||||
private boolean disband(CommandSender sender, String[] args) {
|
private boolean disband(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.disband"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.disband")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
|
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||||
}
|
}
|
||||||
partyManagerInstance.disbandParty(party);
|
|
||||||
|
PartyManager.disbandParty(party);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the owner of the current party
|
* Change the owner of the current party
|
||||||
*/
|
*/
|
||||||
private boolean owner(CommandSender sender, String[] args) {
|
private boolean changeOwner(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.owner"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.owner")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
|
|
||||||
if(args.length < 2) {
|
if(args.length < 2) {
|
||||||
player.sendMessage("Usage: /party owner [player]");
|
player.sendMessage("Usage: /party owner [player]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
if (!party.getMembers().contains(args[1])) {
|
if (!party.getMembers().contains(args[1])) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
partyManagerInstance.setPartyLeader(args[1], party);
|
|
||||||
|
PartyManager.setPartyLeader(args[1], party);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,8 +505,9 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
* Lock the current party
|
* Lock the current party
|
||||||
*/
|
*/
|
||||||
private boolean lock(CommandSender sender, String[] args) {
|
private boolean lock(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.lock"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.lock")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
@ -489,11 +524,14 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
player.sendMessage("Commands.Party.None");
|
player.sendMessage("Commands.Party.None");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,8 +539,9 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
* Unlock the current party
|
* Unlock the current party
|
||||||
*/
|
*/
|
||||||
private boolean unlock(CommandSender sender, String[] args) {
|
private boolean unlock(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.unlock"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.unlock")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
@ -519,24 +558,28 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
player.sendMessage("Commands.Party.None");
|
player.sendMessage("Commands.Party.None");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean password(CommandSender sender, String[] args) {
|
private boolean changePassword(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.password"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.password")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
if(args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"}));
|
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"}));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -546,8 +589,10 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
party.setPassword(args[1]);
|
party.setPassword(args[1]);
|
||||||
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
|
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,25 +600,28 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
* Rename the current party
|
* Rename the current party
|
||||||
*/
|
*/
|
||||||
private boolean rename(CommandSender sender, String[] args) {
|
private boolean rename(CommandSender sender, String[] args) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.rename"))
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party.rename")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
PlayerProfile playerProfile = Users.getProfile(player);
|
PlayerProfile playerProfile = Users.getProfile(player);
|
||||||
|
|
||||||
PartyManager partyManagerInstance = PartyManager.getInstance();
|
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
String leader = party.getLeader();
|
String leader = party.getLeader();
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
if (party.getLeader().equals(playerName)) {
|
||||||
if(args.length < 2) {
|
if (args.length < 2) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"}));
|
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", new Object[] {"party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"}));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
String newPartyName = args[1];
|
String newPartyName = args[1];
|
||||||
if (!party.getName().equals(newPartyName)) {//This is to prevent party leaders from spamming other players with the rename message
|
|
||||||
Party newParty = partyManagerInstance.getParty(newPartyName);
|
// This is to prevent party leaders from spamming other players with the rename message
|
||||||
|
if (!party.getName().equals(newPartyName)) {
|
||||||
|
Party newParty = PartyManager.getParty(newPartyName);
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel renaming the party
|
// Check to see if the party exists, and if it does cancel renaming the party
|
||||||
if (newParty != null) {
|
if (newParty != null) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {newPartyName}));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", new Object[] {newPartyName}));
|
||||||
@ -582,7 +630,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
|
|
||||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), newPartyName, EventReason.CHANGED_PARTIES);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), newPartyName, EventReason.CHANGED_PARTIES);
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return true;
|
return true;
|
||||||
@ -592,13 +640,17 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
onlineMembers.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", new Object[] {leader, newPartyName}));
|
onlineMembers.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", new Object[] {leader, newPartyName}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
party.setName(newPartyName);
|
party.setName(newPartyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Rename", new Object[] {newPartyName}));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Rename", new Object[] {newPartyName}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
if (PartyManager.inSameParty(player, target)) {
|
||||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
@ -15,11 +15,9 @@ import com.gmail.nossr50.skills.Combat;
|
|||||||
|
|
||||||
public class BleedTimer implements Runnable {
|
public class BleedTimer implements Runnable {
|
||||||
private final static int MAX_BLEED_TICKS = 10;
|
private final static int MAX_BLEED_TICKS = 10;
|
||||||
|
|
||||||
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
|
||||||
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
|
||||||
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
|
||||||
|
|
||||||
private static boolean lock = false;
|
private static boolean lock = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,15 +5,15 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
|
|
||||||
public class GainXp implements Runnable {
|
public class GainXp implements Runnable {
|
||||||
private Player player = null;
|
private Player player;
|
||||||
private PlayerProfile profile = null;
|
private PlayerProfile profile;
|
||||||
private double baseXp = 0;
|
private double baseXp;
|
||||||
private SkillType skillType = null;
|
private SkillType skillType;
|
||||||
private LivingEntity target = null;
|
private LivingEntity target;
|
||||||
private int baseHealth = 0;
|
private int baseHealth;
|
||||||
|
|
||||||
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
@ -39,6 +39,6 @@ public class GainXp implements Runnable {
|
|||||||
damage += health;
|
damage += health;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
SkillTools.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import com.gmail.nossr50.skills.AbilityType;
|
|||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
|
|
||||||
public class GreenThumbTimer implements Runnable {
|
public class GreenThumbTimer implements Runnable {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
|
||||||
private Block block;
|
private Block block;
|
||||||
private PlayerProfile profile;
|
private PlayerProfile profile;
|
||||||
private Material type;
|
private Material type;
|
||||||
@ -23,15 +22,16 @@ public class GreenThumbTimer implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (this.block.getType() != this.type)
|
if (this.block.getType() != this.type) {
|
||||||
this.block.setType(this.type);
|
this.block.setType(this.type);
|
||||||
|
}
|
||||||
|
|
||||||
int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
|
int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
|
||||||
|
int greenThumbStage = (int) ((double) skillLevel / (double) AdvancedConfig.getInstance().getGreenThumbStageChange());
|
||||||
|
|
||||||
final int STAGE_CHANGE = advancedConfig.getGreenThumbStageChange();
|
if (greenThumbStage > 4) {
|
||||||
|
greenThumbStage = 4;
|
||||||
int greenThumbStage = (int) ((double) skillLevel / (double) STAGE_CHANGE);
|
}
|
||||||
if (greenThumbStage > 4) greenThumbStage = 4;
|
|
||||||
|
|
||||||
switch(this.type) {
|
switch(this.type) {
|
||||||
case CROPS:
|
case CROPS:
|
||||||
|
@ -5,14 +5,12 @@ import java.util.Map;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
|
|
||||||
public class McRankAsync implements Runnable {
|
public class McRankAsync implements Runnable {
|
||||||
private Database database = mcMMO.getPlayerDatabase();
|
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
|
||||||
@ -23,23 +21,26 @@ public class McRankAsync implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Map<String, Integer> skills = database.readSQLRank(playerName);
|
final Map<String, Integer> skills = Database.readSQLRank(playerName);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", new Object[] {playerName}));
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (skillType.isChildSkill()) continue;
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL))
|
if (skillType.equals(SkillType.ALL))
|
||||||
continue; // We want the overall ranking to be at the bottom
|
continue; // We want the overall ranking to be at the bottom
|
||||||
|
|
||||||
if (skills.get(skillType.name()) == null) {
|
if (skills.get(skillType.name()) == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")} ));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {Skills.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", new Object[] {SkillTools.localizeSkillName(skillType), skills.get(skillType.name())} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,37 +5,34 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class MobStoreCleaner implements Runnable
|
public class MobStoreCleaner implements Runnable {
|
||||||
{
|
|
||||||
private int taskID;
|
private int taskID;
|
||||||
|
|
||||||
public MobStoreCleaner()
|
public MobStoreCleaner() {
|
||||||
{
|
|
||||||
taskID = -1;
|
taskID = -1;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start()
|
public void start() {
|
||||||
{
|
if (taskID >= 0) {
|
||||||
if (taskID >= 0)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
|
||||||
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop()
|
public void stop() {
|
||||||
{
|
if (taskID < 0) {
|
||||||
if(taskID < 0)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
Bukkit.getServer().getScheduler().cancelTask(taskID);
|
||||||
taskID = -1;
|
taskID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run() {
|
||||||
{
|
|
||||||
mcMMO.placeStore.cleanMobLists();
|
mcMMO.placeStore.cleanMobLists();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,17 +9,11 @@ import com.gmail.nossr50.database.Database;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class SQLConversionTask implements Runnable {
|
public class SQLConversionTask implements Runnable {
|
||||||
private final mcMMO plugin;
|
|
||||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
public SQLConversionTask(mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Database database = mcMMO.getPlayerDatabase();
|
String location = mcMMO.getUsersFilePath();
|
||||||
String location = mcMMO.getUsersFile();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileReader file = new FileReader(location);
|
FileReader file = new FileReader(location);
|
||||||
@ -166,7 +160,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Check to see if the user is in the DB
|
//Check to see if the user is in the DB
|
||||||
id = database.getInt("SELECT id FROM "
|
id = Database.getInt("SELECT id FROM "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users WHERE user = '" + playerName + "'");
|
+ "users WHERE user = '" + playerName + "'");
|
||||||
|
|
||||||
@ -174,11 +168,11 @@ public class SQLConversionTask implements Runnable {
|
|||||||
theCount++;
|
theCount++;
|
||||||
|
|
||||||
//Update the skill values
|
//Update the skill values
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users SET lastlogin = " + 0
|
+ "users SET lastlogin = " + 0
|
||||||
+ " WHERE id = " + id);
|
+ " WHERE id = " + id);
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills SET "
|
+ "skills SET "
|
||||||
+ " taming = taming+" + Misc.getInt(taming)
|
+ " taming = taming+" + Misc.getInt(taming)
|
||||||
@ -194,7 +188,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "experience SET "
|
+ "experience SET "
|
||||||
+ " taming = " + Misc.getInt(tamingXP)
|
+ " taming = " + Misc.getInt(tamingXP)
|
||||||
@ -215,32 +209,32 @@ public class SQLConversionTask implements Runnable {
|
|||||||
theCount++;
|
theCount++;
|
||||||
|
|
||||||
//Create the user in the DB
|
//Create the user in the DB
|
||||||
database.write("INSERT INTO "
|
Database.write("INSERT INTO "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users (user, lastlogin) VALUES ('"
|
+ "users (user, lastlogin) VALUES ('"
|
||||||
+ playerName + "',"
|
+ playerName + "',"
|
||||||
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
+ System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR + ")");
|
||||||
id = database.getInt("SELECT id FROM "
|
id = Database.getInt("SELECT id FROM "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users WHERE user = '"
|
+ "users WHERE user = '"
|
||||||
+ playerName + "'");
|
+ playerName + "'");
|
||||||
database.write("INSERT INTO "
|
Database.write("INSERT INTO "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills (user_id) VALUES (" + id + ")");
|
+ "skills (user_id) VALUES (" + id + ")");
|
||||||
database.write("INSERT INTO "
|
Database.write("INSERT INTO "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "experience (user_id) VALUES (" + id
|
+ "experience (user_id) VALUES (" + id
|
||||||
+ ")");
|
+ ")");
|
||||||
//Update the skill values
|
//Update the skill values
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users SET lastlogin = " + 0
|
+ "users SET lastlogin = " + 0
|
||||||
+ " WHERE id = " + id);
|
+ " WHERE id = " + id);
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users SET party = '" + party
|
+ "users SET party = '" + party
|
||||||
+ "' WHERE id = " + id);
|
+ "' WHERE id = " + id);
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills SET "
|
+ "skills SET "
|
||||||
+ " taming = taming+" + Misc.getInt(taming)
|
+ " taming = taming+" + Misc.getInt(taming)
|
||||||
@ -256,7 +250,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||||
+ " WHERE user_id = " + id);
|
+ " WHERE user_id = " + id);
|
||||||
database.write("UPDATE "
|
Database.write("UPDATE "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "experience SET "
|
+ "experience SET "
|
||||||
+ " taming = " + Misc.getInt(tamingXP)
|
+ " taming = " + Misc.getInt(tamingXP)
|
||||||
@ -279,7 +273,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,13 @@ import com.gmail.nossr50.database.Database;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SQLReconnect implements Runnable {
|
public class SQLReconnect implements Runnable {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public SQLReconnect(mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Database.checkConnected()) {
|
if (Database.checkConnected()) {
|
||||||
Users.saveAll(); //Save all profiles
|
Users.saveAll(); //Save all profiles
|
||||||
Users.clearAll(); //Clear the profiles
|
Users.clearAll(); //Clear the profiles
|
||||||
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,23 +8,17 @@ import com.gmail.nossr50.party.PartyManager;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SaveTimer implements Runnable {
|
public class SaveTimer implements Runnable {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public SaveTimer(final mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
//All player data will be saved periodically through this
|
//All player data will be saved periodically through this
|
||||||
int count = 1;
|
int count = 1;
|
||||||
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
|
BukkitScheduler bukkitScheduler = mcMMO.p.getServer().getScheduler();
|
||||||
|
|
||||||
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
||||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(mcMMOPlayer), count);
|
bukkitScheduler.scheduleSyncDelayedTask(mcMMO.p, new ProfileSaveTask(mcMMOPlayer), count);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.getInstance().saveParties();
|
PartyManager.saveParties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,22 +6,15 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
import com.gmail.nossr50.skills.AbilityType;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class SkillMonitor implements Runnable {
|
public class SkillMonitor implements Runnable {
|
||||||
private final mcMMO plugin;
|
|
||||||
|
|
||||||
public SkillMonitor(final mcMMO plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
|
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -29,7 +22,7 @@ public class SkillMonitor implements Runnable {
|
|||||||
*/
|
*/
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (skill.getTool() != null && skill.getAbility() != null) {
|
if (skill.getTool() != null && skill.getAbility() != null) {
|
||||||
Skills.monitorSkill(player, profile, curTime, skill);
|
SkillTools.monitorSkill(player, profile, curTime, skill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +30,8 @@ public class SkillMonitor implements Runnable {
|
|||||||
* COOLDOWN MONITORING
|
* COOLDOWN MONITORING
|
||||||
*/
|
*/
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (AbilityType ability : AbilityType.values()) {
|
||||||
if (ability.getCooldown() > 0 ) {
|
if (ability.getCooldown() > 0) {
|
||||||
Skills.watchCooldown(player, profile, ability);
|
SkillTools.watchCooldown(player, profile, ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,13 @@ public class StickyPistonTracker implements Runnable {
|
|||||||
Block newBlock = event.getBlock().getRelative(event.getDirection());
|
Block newBlock = event.getBlock().getRelative(event.getDirection());
|
||||||
Block originalBlock = newBlock.getRelative(event.getDirection());
|
Block originalBlock = newBlock.getRelative(event.getDirection());
|
||||||
|
|
||||||
if (originalBlock.getType() != Material.AIR)
|
if (originalBlock.getType() != Material.AIR) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mcMMO.placeStore.isTrue(originalBlock))
|
if (!mcMMO.placeStore.isTrue(originalBlock)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mcMMO.placeStore.setFalse(originalBlock);
|
mcMMO.placeStore.setFalse(originalBlock);
|
||||||
mcMMO.placeStore.setTrue(newBlock);
|
mcMMO.placeStore.setTrue(newBlock);
|
||||||
|
@ -1,23 +1,16 @@
|
|||||||
package com.gmail.nossr50.runnables;
|
package com.gmail.nossr50.runnables;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
|
|
||||||
public class UserPurgeTask implements Runnable {
|
public class UserPurgeTask implements Runnable {
|
||||||
private Database database = mcMMO.getPlayerDatabase();
|
|
||||||
|
|
||||||
public UserPurgeTask() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
database.purgePowerlessSQL();
|
Database.purgePowerlessSQL();
|
||||||
|
|
||||||
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
if (Config.getInstance().getOldUsersCutoff() != -1) {
|
||||||
database.purgeOldSQL();
|
Database.purgeOldSQL();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -53,8 +53,9 @@ public class BlockStoreConversionMain implements Runnable {
|
|||||||
this.xDirs = this.dataDir.listFiles();
|
this.xDirs = this.dataDir.listFiles();
|
||||||
|
|
||||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
|
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
|
||||||
if (this.converters[this.i] == null)
|
if (this.converters[this.i] == null) {
|
||||||
this.converters[this.i] = new BlockStoreConversionXDirectory();
|
this.converters[this.i] = new BlockStoreConversionXDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
this.converters[this.i].start(this.world, this.xDirs[this.i]);
|
this.converters[this.i].start(this.world, this.xDirs[this.i]);
|
||||||
}
|
}
|
||||||
@ -63,8 +64,9 @@ public class BlockStoreConversionMain implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (this.taskID < 0)
|
if (this.taskID < 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.scheduler.cancelTask(this.taskID);
|
this.scheduler.cancelTask(this.taskID);
|
||||||
this.taskID = -1;
|
this.taskID = -1;
|
||||||
|
@ -25,8 +25,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()];
|
this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()];
|
||||||
this.dataDir = dataDir;
|
this.dataDir = dataDir;
|
||||||
|
|
||||||
if (this.taskID >= 0)
|
if (this.taskID >= 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||||
return;
|
return;
|
||||||
@ -54,8 +55,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
this.zDirs = this.dataDir.listFiles();
|
this.zDirs = this.dataDir.listFiles();
|
||||||
|
|
||||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
|
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
|
||||||
if (this.converters[this.i] == null)
|
if (this.converters[this.i] == null) {
|
||||||
this.converters[this.i] = new BlockStoreConversionZDirectory();
|
this.converters[this.i] = new BlockStoreConversionZDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
this.converters[this.i].start(this.world, this.dataDir, this.zDirs[this.i]);
|
this.converters[this.i].start(this.world, this.dataDir, this.zDirs[this.i]);
|
||||||
}
|
}
|
||||||
@ -64,8 +66,9 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
if (this.taskID < 0)
|
if (this.taskID < 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.scheduler.cancelTask(this.taskID);
|
this.scheduler.cancelTask(this.taskID);
|
||||||
this.taskID = -1;
|
this.taskID = -1;
|
||||||
|
@ -38,8 +38,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
this.dataDir = dataDir;
|
this.dataDir = dataDir;
|
||||||
this.xDir = xDir;
|
this.xDir = xDir;
|
||||||
|
|
||||||
if (this.taskID >= 0)
|
if (this.taskID >= 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||||
return;
|
return;
|
||||||
@ -110,8 +111,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
|
|
||||||
for (this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) {
|
for (this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) {
|
||||||
try {
|
try {
|
||||||
if (!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world))
|
if (!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
|
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
|
||||||
}
|
}
|
||||||
@ -119,6 +121,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,17 +131,26 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
|
|
||||||
for (this.x = 0; this.x < 16; this.x++) {
|
for (this.x = 0; this.x < 16; this.x++) {
|
||||||
for (this.z = 0; this.z < 16; this.z++) {
|
for (this.z = 0; this.z < 16; this.z++) {
|
||||||
if (this.primitiveChunklet != null)
|
if (this.primitiveChunklet != null) {
|
||||||
this.oldArray = this.primitiveChunklet.store[x][z];
|
this.oldArray = this.primitiveChunklet.store[x][z];
|
||||||
if (this.primitiveExChunklet != null)
|
}
|
||||||
|
|
||||||
|
if (this.primitiveExChunklet != null) {
|
||||||
this.oldArray = this.primitiveExChunklet.store[x][z];
|
this.oldArray = this.primitiveExChunklet.store[x][z];
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.newArray = this.currentChunk.store[x][z];
|
this.newArray = this.currentChunk.store[x][z];
|
||||||
if (this.oldArray.length < 64)
|
|
||||||
|
if (this.oldArray.length < 64) {
|
||||||
return;
|
return;
|
||||||
else if (this.newArray.length < ((this.y * 64) + 64))
|
}
|
||||||
|
else if (this.newArray.length < ((this.y * 64) + 64)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64);
|
System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,8 +160,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
this.newManager.unloadChunk(this.cx, this.cz, this.world);
|
this.newManager.unloadChunk(this.cx, this.cz, this.world);
|
||||||
|
|
||||||
for (File yFile : dataDir.listFiles()) {
|
for (File yFile : dataDir.listFiles()) {
|
||||||
if (!yFile.exists())
|
if (!yFile.exists()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
yFile.delete();
|
yFile.delete();
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,11 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Combat {
|
public final class Combat {
|
||||||
private static Config configInstance = Config.getInstance();
|
private static Config configInstance = Config.getInstance();
|
||||||
|
|
||||||
|
private Combat() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply combat modifiers and process and XP gain.
|
* Apply combat modifiers and process and XP gain.
|
||||||
*
|
*
|
||||||
@ -83,7 +85,7 @@ public class Combat {
|
|||||||
boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice
|
boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
|
||||||
Skills.abilityCheck(player, SkillType.SWORDS);
|
SkillTools.abilityCheck(player, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.swordsBleed(player) && shouldBeAffected(player, target)) {
|
if (Permissions.swordsBleed(player) && shouldBeAffected(player, target)) {
|
||||||
@ -112,7 +114,7 @@ public class Combat {
|
|||||||
PlayerProfile profile = axeManager.getProfile();
|
PlayerProfile profile = axeManager.getProfile();
|
||||||
boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice
|
boolean canSkullSplit = Permissions.skullSplitter(player); //So we don't have to check the same permission twice
|
||||||
if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) {
|
if (profile.getToolPreparationMode(ToolType.AXE) && canSkullSplit) {
|
||||||
Skills.abilityCheck(player, SkillType.AXES);
|
SkillTools.abilityCheck(player, SkillType.AXES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.axeBonus(player)) {
|
if (Permissions.axeBonus(player)) {
|
||||||
@ -150,7 +152,7 @@ public class Combat {
|
|||||||
boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice
|
boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice
|
||||||
|
|
||||||
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
|
||||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
SkillTools.abilityCheck(player, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.unarmedBonus(player)) {
|
if (Permissions.unarmedBonus(player)) {
|
||||||
@ -558,7 +560,7 @@ public class Combat {
|
|||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player defender = (Player) entity;
|
Player defender = (Player) entity;
|
||||||
|
|
||||||
if (!defender.getWorld().getPVP() || defender == player || PartyManager.getInstance().inSameParty(player, defender) || Users.getProfile(defender).getGodMode()) {
|
if (!defender.getWorld().getPVP() || defender == player || PartyManager.inSameParty(player, defender) || Users.getProfile(defender).getGodMode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,24 +7,24 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class Page {
|
public final class Page {
|
||||||
|
private Page() {}
|
||||||
|
|
||||||
public static int getTotalPageNumber(String address)
|
public static int getTotalPageNumber(String address) {
|
||||||
{
|
|
||||||
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
||||||
if (addressSplit.length <= 8)
|
|
||||||
|
if (addressSplit.length <= 8) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return (addressSplit.length/8)+1;
|
return (addressSplit.length/8)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<String> grabPageContents(String header, String address, int pagenum)
|
public static ArrayList<String> grabPageContents(String header, String address, int pagenum) {
|
||||||
{
|
|
||||||
int pageIndexStart = 0;
|
int pageIndexStart = 0;
|
||||||
|
|
||||||
//Determine what string to start at
|
//Determine what string to start at
|
||||||
if (pagenum > 1)
|
if (pagenum > 1) {
|
||||||
{
|
|
||||||
pageIndexStart = 8*(pagenum-1);
|
pageIndexStart = 8*(pagenum-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,23 +34,21 @@ public class Page {
|
|||||||
allStrings.add(LocaleLoader.getString("Guides.Header", new Object[] {header} ));
|
allStrings.add(LocaleLoader.getString("Guides.Header", new Object[] {header} ));
|
||||||
|
|
||||||
//Add targeted strings
|
//Add targeted strings
|
||||||
|
while (allStrings.size() < 9) {
|
||||||
while (allStrings.size() < 9)
|
if (pageIndexStart+allStrings.size() > split.length) {
|
||||||
{
|
|
||||||
if (pageIndexStart+allStrings.size() > split.length)
|
|
||||||
allStrings.add("");
|
allStrings.add("");
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
|
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
|
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
|
||||||
return allStrings;
|
return allStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearChat(Player player)
|
public static void clearChat(Player player) {
|
||||||
{
|
for (int x = 0; x < 20; x++) {
|
||||||
for (int x = 0; x < 20; x++)
|
|
||||||
{
|
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,36 +56,39 @@ public class Page {
|
|||||||
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
|
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
|
||||||
String skillName = skilltype.toString();
|
String skillName = skilltype.toString();
|
||||||
String capitalized = Misc.getCapitalized(skillName);
|
String capitalized = Misc.getCapitalized(skillName);
|
||||||
String localized = Skills.localizeSkillName(skilltype);
|
String localized = SkillTools.localizeSkillName(skilltype);
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Available", new Object[] {localized, localized.toLowerCase()} ));
|
player.sendMessage(LocaleLoader.getString("Guides.Available", new Object[] {localized, localized.toLowerCase()} ));
|
||||||
|
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1 && args[0].equals("?")) {
|
||||||
if (args[0].equals("?")) {
|
String address = "Guides." + capitalized;
|
||||||
String address = "Guides."+capitalized;
|
|
||||||
int totalPages = Page.getTotalPageNumber(address);
|
int totalPages = Page.getTotalPageNumber(address);
|
||||||
|
|
||||||
if (args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= totalPages) {
|
if (args.length == 1) {
|
||||||
Page.clearChat(player);
|
|
||||||
for (String target : Page.grabPageContents(localized, address, Misc.getInt(args[1]))) {
|
|
||||||
player.sendMessage(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 1) {
|
|
||||||
Page.clearChat(player);
|
Page.clearChat(player);
|
||||||
|
|
||||||
for (String target : Page.grabPageContents(localized, address, 1)) {
|
for (String target : Page.grabPageContents(localized, address, 1)) {
|
||||||
player.sendMessage(target);
|
player.sendMessage(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length > 1 && Misc.getInt(args[1]) > totalPages) {
|
else {
|
||||||
|
if (!Misc.isInt(args[1])) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Misc.getInt(args[1]) <= totalPages) {
|
||||||
|
Page.clearChat(player);
|
||||||
|
|
||||||
|
for (String target : Page.grabPageContents(localized, address, Misc.getInt(args[1]))) {
|
||||||
|
player.sendMessage(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", new Object[] {totalPages} ));
|
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", new Object[] {totalPages} ));
|
||||||
}
|
}
|
||||||
else if (args.length > 1 && !Misc.isInt(args[1])) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Usage", new Object[] {localized.toLowerCase()} ));
|
player.sendMessage(LocaleLoader.getString("Guides.Usage", new Object[] {localized.toLowerCase()} ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -159,7 +159,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
protected void luckyEffectsDisplay() {
|
protected void luckyEffectsDisplay() {
|
||||||
if (isLucky) {
|
if (isLucky) {
|
||||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(skill) }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { SkillTools.localizeSkillName(skill) }) }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import com.gmail.nossr50.util.ModChecks;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class Skills {
|
public class SkillTools {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||||
public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
|
public static boolean abilitiesEnabled = Config.getInstance().getAbilitiesEnabled();
|
@ -5,7 +5,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class DodgeEventHandler extends AcrobaticsEventHandler {
|
public class DodgeEventHandler extends AcrobaticsEventHandler {
|
||||||
@ -47,7 +47,7 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
|
|||||||
PlayerProfile profile = manager.getProfile();
|
PlayerProfile profile = manager.getProfile();
|
||||||
|
|
||||||
if (System.currentTimeMillis() >= profile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
if (System.currentTimeMillis() >= profile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
|
||||||
Skills.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
|
SkillTools.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void processXPGain(int xpGain) {
|
protected void processXPGain(int xpGain) {
|
||||||
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
|
SkillTools.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
@ -112,7 +112,7 @@ public class Excavation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, SkillType.EXCAVATION, xp);
|
SkillTools.xpProcessing(player, profile, SkillType.EXCAVATION, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +125,7 @@ public class Excavation {
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Skills.abilityDurabilityLoss(player.getItemInHand(), Misc.toolDurabilityLoss);
|
SkillTools.abilityDurabilityLoss(player.getItemInHand(), Misc.toolDurabilityLoss);
|
||||||
|
|
||||||
if (!mcMMO.placeStore.isTrue(block) && Misc.blockBreakSimulate(block, player, true)) {
|
if (!mcMMO.placeStore.isTrue(block) && Misc.blockBreakSimulate(block, player, true)) {
|
||||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||||
|
@ -31,7 +31,7 @@ import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.Combat;
|
import com.gmail.nossr50.skills.Combat;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -62,7 +62,7 @@ public class Fishing {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.handleFoodSkills(player, SkillType.FISHING, event, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange);
|
SkillTools.handleFoodSkills(player, SkillType.FISHING, event, fishermansDietRankLevel1, fishermansDietMaxLevel, rankChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,7 +141,7 @@ public class Fishing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
SkillTools.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
import com.gmail.nossr50.skills.AbilityType;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -58,7 +58,7 @@ public class Herbalism {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.handleFoodSkills(player, SkillType.HERBALISM, event, farmersDietRankLevel1, farmersDietMaxLevel, rankChange);
|
SkillTools.handleFoodSkills(player, SkillType.HERBALISM, event, farmersDietRankLevel1, farmersDietMaxLevel, rankChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -437,7 +437,7 @@ public class Herbalism {
|
|||||||
if (Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle())
|
if (Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, SkillType.HERBALISM, xp);
|
SkillTools.xpProcessing(player, profile, SkillType.HERBALISM, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class Mining {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, SkillType.MINING, xp);
|
SkillTools.xpProcessing(player, profile, SkillType.MINING, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.AbilityType;
|
import com.gmail.nossr50.skills.AbilityType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
public class RemoteDetonationEventHandler {
|
public class RemoteDetonationEventHandler {
|
||||||
@ -43,8 +43,8 @@ public class RemoteDetonationEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean cooldownOver() {
|
protected boolean cooldownOver() {
|
||||||
if (!Skills.cooldownOver(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player)) {
|
if (!SkillTools.cooldownOver(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", new Object[] { Skills.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player) }));
|
player.sendMessage(LocaleLoader.getString("SkillTools.TooTired", new Object[] { SkillTools.calculateTimeLeft(profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR, AbilityType.BLAST_MINING.getCooldown(), player) }));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.getspout.spoutapi.sound.SoundEffect;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
@ -48,7 +48,7 @@ public class SuperBreakerEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void processDurabilityLoss() {
|
protected void processDurabilityLoss() {
|
||||||
Skills.abilityDurabilityLoss(heldItem, durabilityLoss);
|
SkillTools.abilityDurabilityLoss(heldItem, durabilityLoss);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processDropsAndXP() {
|
protected void processDropsAndXP() {
|
||||||
|
@ -16,7 +16,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -52,7 +52,7 @@ public class Repair {
|
|||||||
|
|
||||||
dif = (short) (dif * modify);
|
dif = (short) (dif * modify);
|
||||||
|
|
||||||
Skills.xpProcessing(player, profile, SkillType.REPAIR, dif * 10);
|
SkillTools.xpProcessing(player, profile, SkillType.REPAIR, dif * 10);
|
||||||
|
|
||||||
//CLANG CLANG
|
//CLANG CLANG
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.spoutEnabled) {
|
||||||
@ -248,7 +248,7 @@ public class Repair {
|
|||||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
|
int activationChance = Misc.calculateActivationChance(Permissions.luckyRepair(player));
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
|
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
player.sendMessage(LocaleLoader.getString("Repair.SkillTools.FeltEasy"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -68,11 +68,11 @@ public class SmeltResourceEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.mining(player)) {
|
if (Permissions.mining(player)) {
|
||||||
Skills.xpProcessing(player, profile, SkillType.MINING, xp / 2);
|
SkillTools.xpProcessing(player, profile, SkillType.MINING, xp / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.repair(player)) {
|
if (Permissions.repair(player)) {
|
||||||
Skills.xpProcessing(player, profile, SkillType.REPAIR, xp / 2);
|
SkillTools.xpProcessing(player, profile, SkillType.REPAIR, xp / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -37,11 +37,11 @@ public class TamingManager extends SkillManager {
|
|||||||
|
|
||||||
switch (event.getEntityType()) {
|
switch (event.getEntityType()) {
|
||||||
case WOLF:
|
case WOLF:
|
||||||
Skills.xpProcessing(player, profile, SkillType.TAMING, Taming.wolfXP);
|
SkillTools.xpProcessing(player, profile, SkillType.TAMING, Taming.wolfXP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OCELOT:
|
case OCELOT:
|
||||||
Skills.xpProcessing(player, profile, SkillType.TAMING, Taming.ocelotXP);
|
SkillTools.xpProcessing(player, profile, SkillType.TAMING, Taming.ocelotXP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -17,7 +17,7 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.Combat;
|
import com.gmail.nossr50.skills.Combat;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.BlockChecks;
|
import com.gmail.nossr50.util.BlockChecks;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
@ -42,13 +42,13 @@ public abstract class TreeFeller {
|
|||||||
if (treeFellerReachedThreshold) {
|
if (treeFellerReachedThreshold) {
|
||||||
treeFellerReachedThreshold = false;
|
treeFellerReachedThreshold = false;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.SkillTools.TreeFellerThreshold"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the tool can't sustain the durability loss
|
// If the tool can't sustain the durability loss
|
||||||
if (!handleDurabilityLoss(treeFellerBlocks, player)) {
|
if (!handleDurabilityLoss(treeFellerBlocks, player)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.SkillTools.TreeFeller.Splinter"));
|
||||||
|
|
||||||
int health = player.getHealth();
|
int health = player.getHealth();
|
||||||
|
|
||||||
@ -223,7 +223,7 @@ public abstract class TreeFeller {
|
|||||||
|
|
||||||
// Do we really have to check the permission here?
|
// Do we really have to check the permission here?
|
||||||
if (Permissions.woodcutting(player)) {
|
if (Permissions.woodcutting(player)) {
|
||||||
Skills.xpProcessing(player, Users.getProfile(player), SkillType.WOODCUTTING, xp);
|
SkillTools.xpProcessing(player, Users.getProfile(player), SkillType.WOODCUTTING, xp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.spout.SpoutSounds;
|
import com.gmail.nossr50.spout.SpoutSounds;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.ModChecks;
|
import com.gmail.nossr50.util.ModChecks;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public abstract class Woodcutting {
|
public final class Woodcutting {
|
||||||
public static final int DOUBLE_DROP_MAX_LEVEL = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel();
|
public static final int DOUBLE_DROP_MAX_LEVEL = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel();
|
||||||
public static final double DOUBLE_DROP_CHANCE = AdvancedConfig.getInstance().getMiningDoubleDropChance();
|
public static final double DOUBLE_DROP_CHANCE = AdvancedConfig.getInstance().getMiningDoubleDropChance();
|
||||||
public static final int LEAF_BLOWER_UNLOCK_LEVEL = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
public static final int LEAF_BLOWER_UNLOCK_LEVEL = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
|
||||||
@ -30,6 +30,8 @@ public abstract class Woodcutting {
|
|||||||
public static final int TREE_FELLER_THRESHOLD = Config.getInstance().getTreeFellerThreshold();
|
public static final int TREE_FELLER_THRESHOLD = Config.getInstance().getTreeFellerThreshold();
|
||||||
public static final boolean REQUIRES_TOOL = Config.getInstance().getWoodcuttingRequiresTool();
|
public static final boolean REQUIRES_TOOL = Config.getInstance().getWoodcuttingRequiresTool();
|
||||||
|
|
||||||
|
private Woodcutting() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Begins the Tree Feller ability
|
* Begins the Tree Feller ability
|
||||||
*
|
*
|
||||||
@ -75,7 +77,7 @@ public abstract class Woodcutting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkDoubleDrop(player, block);
|
checkDoubleDrop(player, block);
|
||||||
Skills.xpProcessing(player, Users.getProfile(player), SkillType.WOODCUTTING, xp);
|
SkillTools.xpProcessing(player, Users.getProfile(player), SkillType.WOODCUTTING, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -549,7 +549,7 @@ public class SpoutStuff {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", new Object[] {Skills.localizeSkillName(skillType), profile.getSkillLevel(skillType)} ), mat);
|
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", new Object[] {SkillTools.localizeSkillName(skillType), profile.getSkillLevel(skillType)} ), mat);
|
||||||
SpoutSounds.playLevelUpNoise(spoutPlayer, plugin);
|
SpoutSounds.playLevelUpNoise(spoutPlayer, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
import com.gmail.nossr50.spout.SpoutConfig;
|
import com.gmail.nossr50.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@ -63,10 +63,10 @@ public class XplockCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (Skills.isSkill(args[0])) {
|
if (SkillTools.isSkill(args[0])) {
|
||||||
if (Permissions.hasPermission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
if (Permissions.hasPermission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||||
spoutHud.setXpBarLocked(true);
|
spoutHud.setXpBarLocked(true);
|
||||||
spoutHud.setSkillLock(Skills.getSkillType(args[0]));
|
spoutHud.setSkillLock(SkillTools.getSkillType(args[0]));
|
||||||
spoutHud.updateXpBar();
|
spoutHud.updateXpBar();
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||||
|
@ -14,11 +14,9 @@ import com.gmail.nossr50.spout.popups.XpBar;
|
|||||||
public class SpoutHud {
|
public class SpoutHud {
|
||||||
private Player player;
|
private Player player;
|
||||||
private PlayerProfile profile;
|
private PlayerProfile profile;
|
||||||
|
|
||||||
private SkillType lastGained;
|
private SkillType lastGained;
|
||||||
private SkillType skillLock;
|
private SkillType skillLock;
|
||||||
private boolean xpBarLocked;
|
private boolean xpBarLocked;
|
||||||
|
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
private XpBar xpBar;
|
private XpBar xpBar;
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
|
|
||||||
public class XpBar {
|
public class XpBar {
|
||||||
private SpoutPlayer spoutPlayer;
|
private SpoutPlayer spoutPlayer;
|
||||||
|
|
||||||
private Widget xpBar;
|
private Widget xpBar;
|
||||||
private GenericGradient xpFill;
|
private GenericGradient xpFill;
|
||||||
private GenericGradient xpBackground;
|
private GenericGradient xpBackground;
|
||||||
|
@ -11,7 +11,6 @@ import java.util.Calendar;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -26,14 +25,13 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
|
||||||
public class Anniversary {
|
public final class Anniversary {
|
||||||
|
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
public static ArrayList<String> hasCelebrated;
|
public static ArrayList<String> hasCelebrated;
|
||||||
|
|
||||||
|
private Anniversary() {}
|
||||||
|
|
||||||
//This gets called onEnable
|
//This gets called onEnable
|
||||||
public void createAnniversaryFile() {
|
public static void createAnniversaryFile() {
|
||||||
File anniversaryFile = new File(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary");
|
File anniversaryFile = new File(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary");
|
||||||
|
|
||||||
if (!anniversaryFile.exists()) {
|
if (!anniversaryFile.exists()) {
|
||||||
@ -62,7 +60,7 @@ public class Anniversary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This gets called onDisable
|
//This gets called onDisable
|
||||||
public void saveAnniversaryFiles() {
|
public static void saveAnniversaryFiles() {
|
||||||
try {
|
try {
|
||||||
BufferedWriter writer = new BufferedWriter(new FileWriter(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
BufferedWriter writer = new BufferedWriter(new FileWriter(mcMMO.p.getDataFolder().getAbsolutePath() + File.separator + "anniversary"));
|
||||||
for (String player : hasCelebrated) {
|
for (String player : hasCelebrated) {
|
||||||
@ -77,7 +75,7 @@ public class Anniversary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This gets called from /mcmmo command
|
//This gets called from /mcmmo command
|
||||||
public void anniversaryCheck(final CommandSender sender) {
|
public static void anniversaryCheck(final CommandSender sender) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
|
GregorianCalendar anniversaryStart = new GregorianCalendar(2013, Calendar.FEBRUARY, 3);
|
||||||
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
|
GregorianCalendar anniversaryEnd = new GregorianCalendar(2013, Calendar.FEBRUARY, 6);
|
||||||
@ -105,11 +103,11 @@ public class Anniversary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getDateRange(Date date, Date start, Date end) {
|
private static boolean getDateRange(Date date, Date start, Date end) {
|
||||||
return !(date.before(start) || date.after(end));
|
return !(date.before(start) || date.after(end));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnFireworks(Player player) {
|
private static void spawnFireworks(Player player) {
|
||||||
int power = (int) (Math.random() * 3) + 1;
|
int power = (int) (Math.random() * 3) + 1;
|
||||||
int type = (int) (Math.random() * 5) + 1;
|
int type = (int) (Math.random() * 5) + 1;
|
||||||
|
|
||||||
@ -122,16 +120,16 @@ public class Anniversary {
|
|||||||
|
|
||||||
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
|
Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREWORK);
|
||||||
FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
|
FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
|
||||||
FireworkEffect effect = FireworkEffect.builder().flicker(random.nextBoolean()).withColor(colorchoose()).withFade(colorchoose()).with(typen).trail(random.nextBoolean()).build();
|
FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorchoose()).withFade(colorchoose()).with(typen).trail(Misc.getRandom().nextBoolean()).build();
|
||||||
fireworkmeta.addEffect(effect);
|
fireworkmeta.addEffect(effect);
|
||||||
fireworkmeta.setPower(power);
|
fireworkmeta.setPower(power);
|
||||||
fireworks.setFireworkMeta(fireworkmeta);
|
fireworks.setFireworkMeta(fireworkmeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Color> colorchoose() {
|
private static List<Color> colorchoose() {
|
||||||
// Thanks Zomis and Tejpbit for the help with this function!
|
// Thanks Zomis and Tejpbit for the help with this function!
|
||||||
|
|
||||||
int numberofcolors = random.nextInt(17) + 1;
|
int numberofcolors = Misc.getRandom().nextInt(17) + 1;
|
||||||
|
|
||||||
List<Color> allcolors = new ArrayList<Color>();
|
List<Color> allcolors = new ArrayList<Color>();
|
||||||
allcolors.add(Color.AQUA);
|
allcolors.add(Color.AQUA);
|
||||||
@ -155,7 +153,7 @@ public class Anniversary {
|
|||||||
List<Color> choosencolors = new ArrayList<Color>();
|
List<Color> choosencolors = new ArrayList<Color>();
|
||||||
|
|
||||||
for (int i = 0; i < numberofcolors; i++) {
|
for (int i = 0; i < numberofcolors; i++) {
|
||||||
choosencolors.add(allcolors.remove(random.nextInt(allcolors.size())));
|
choosencolors.add(allcolors.remove(Misc.getRandom().nextInt(allcolors.size())));
|
||||||
}
|
}
|
||||||
return choosencolors;
|
return choosencolors;
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,10 @@ import org.bukkit.material.MaterialData;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||||
|
|
||||||
public class BlockChecks {
|
public final class BlockChecks {
|
||||||
private static Config configInstance = Config.getInstance();
|
private static Config configInstance = Config.getInstance();
|
||||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
|
||||||
|
private BlockChecks() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a block type awards XP.
|
* Checks to see if a block type awards XP.
|
||||||
@ -62,7 +63,7 @@ public class BlockChecks {
|
|||||||
default:
|
default:
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ public class BlockChecks {
|
|||||||
public static boolean canActivateAbilities(Block block) {
|
public static boolean canActivateAbilities(Block block) {
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ public class BlockChecks {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) {
|
if (configInstance.getBlockModsEnabled() && ModChecks.isCustomOreBlock(block)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +202,7 @@ public class BlockChecks {
|
|||||||
default:
|
default:
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +238,7 @@ public class BlockChecks {
|
|||||||
default:
|
default:
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +266,7 @@ public class BlockChecks {
|
|||||||
default:
|
default:
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +289,7 @@ public class BlockChecks {
|
|||||||
default:
|
default:
|
||||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||||
|
|
||||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
if (configInstance.getBlockModsEnabled() && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +298,7 @@ public class BlockChecks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLog(Block block) {
|
public static boolean isLog(Block block) {
|
||||||
if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) {
|
if (block.getType().equals(Material.LOG) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,20 +8,12 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class ChatManager {
|
public final class ChatManager {
|
||||||
private mcMMO plugin;
|
public ChatManager () {}
|
||||||
private String playerName;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public ChatManager (mcMMO plugin, String playerName, String message) {
|
public static void handleAdminChat(String playerName, String message) {
|
||||||
this.plugin = plugin;
|
|
||||||
this.playerName = playerName;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleAdminChat() {
|
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, message);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, message);
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@ -29,20 +21,20 @@ public class ChatManager {
|
|||||||
|
|
||||||
String adminMessage = chatEvent.getMessage();
|
String adminMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
plugin.getLogger().info("[A]<" + playerName + "> " + adminMessage);
|
mcMMO.p.getLogger().info("[A]<" + playerName + "> " + adminMessage);
|
||||||
|
|
||||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
for (Player otherPlayer : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||||
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||||
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + adminMessage);
|
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", new Object[] {playerName}) + adminMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handlePartyChat(Party party) {
|
public static void handlePartyChat(Party party, String playerName, String message) {
|
||||||
String partyName = party.getName();
|
String partyName = party.getName();
|
||||||
|
|
||||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, message);
|
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, message);
|
||||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
if (chatEvent.isCancelled()) {
|
if (chatEvent.isCancelled()) {
|
||||||
return;
|
return;
|
||||||
@ -50,7 +42,7 @@ public class ChatManager {
|
|||||||
|
|
||||||
String partyMessage = chatEvent.getMessage();
|
String partyMessage = chatEvent.getMessage();
|
||||||
|
|
||||||
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + partyMessage);
|
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + partyMessage);
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + partyMessage);
|
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", new Object[] {playerName}) + partyMessage);
|
||||||
|
@ -8,32 +8,30 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.Skills;
|
import com.gmail.nossr50.skills.SkillTools;
|
||||||
|
|
||||||
public class Item {
|
public final class ChimaeraWing {
|
||||||
|
private ChimaeraWing() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for item usage.
|
* Check for item usage.
|
||||||
*
|
*
|
||||||
* @param player Player whose item usage to check
|
* @param player Player whose item usage to check
|
||||||
*/
|
*/
|
||||||
public static void itemChecks(Player player) {
|
public static void activationCheck(Player player) {
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (Config.getInstance().getChimaeraEnabled() && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
if (!Config.getInstance().getChimaeraEnabled() || inHand.getTypeId() != Config.getInstance().getChimaeraItemId()) {
|
||||||
chimaeraWing(player);
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void chimaeraWing(Player player) {
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
ItemStack inHand = player.getItemInHand();
|
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
int amount = inHand.getAmount();
|
int amount = inHand.getAmount();
|
||||||
long recentlyHurt = profile.getRecentlyHurt();
|
long recentlyHurt = profile.getRecentlyHurt();
|
||||||
|
|
||||||
if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
if (Permissions.chimaeraWing(player) && inHand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
|
||||||
if (Skills.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
if (SkillTools.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||||
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
|
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
|
||||||
|
|
||||||
for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
|
||||||
@ -53,11 +51,11 @@ public class Item {
|
|||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
|
||||||
}
|
}
|
||||||
else if (!Skills.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
else if (!SkillTools.cooldownOver(recentlyHurt, 60, player) && amount >= Config.getInstance().getChimaeraCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(recentlyHurt, 60, player)}));
|
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", new Object[] {SkillTools.calculateTimeLeft(recentlyHurt, 60, player)}));
|
||||||
}
|
}
|
||||||
else if (amount <= Config.getInstance().getChimaeraCost()) {
|
else if (amount <= Config.getInstance().getChimaeraCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", new Object[] { Misc.prettyItemString(Config.getInstance().getChimaeraItemId()) }));
|
player.sendMessage(LocaleLoader.getString("SkillTools.NeedMore", new Object[] { Misc.prettyItemString(Config.getInstance().getChimaeraItemId()) }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,13 +7,14 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
|
|
||||||
public abstract class Hardcore {
|
public final class Hardcore {
|
||||||
public static double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
public static double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
||||||
public static double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
public static double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
||||||
|
|
||||||
public static boolean statLossEnabled = Config.getInstance().getHardcoreEnabled();
|
public static boolean statLossEnabled = Config.getInstance().getHardcoreEnabled();
|
||||||
public static boolean vampirismEnabled = Config.getInstance().getHardcoreVampirismEnabled();
|
public static boolean vampirismEnabled = Config.getInstance().getHardcoreVampirismEnabled();
|
||||||
|
|
||||||
|
private Hardcore() {}
|
||||||
|
|
||||||
public static void invokeStatPenalty(Player player) {
|
public static void invokeStatPenalty(Player player) {
|
||||||
if (statLossPercentage <= 0 || statLossPercentage > 100) {
|
if (statLossPercentage <= 0 || statLossPercentage > 100) {
|
||||||
return;
|
return;
|
||||||
|
@ -12,12 +12,12 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
|
|
||||||
public class Leaderboard {
|
public final class Leaderboard {
|
||||||
private static mcMMO plugin = mcMMO.p;
|
|
||||||
private final static String location = mcMMO.getUsersFile();
|
|
||||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||||
private static long lastUpdate = 0;
|
private static long lastUpdate = 0;
|
||||||
|
|
||||||
|
private Leaderboard() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the leader boards.
|
* Update the leader boards.
|
||||||
*/
|
*/
|
||||||
@ -47,7 +47,7 @@ public class Leaderboard {
|
|||||||
|
|
||||||
//Read from the FlatFile database and fill our arrays with information
|
//Read from the FlatFile database and fill our arrays with information
|
||||||
try {
|
try {
|
||||||
FileReader file = new FileReader(location);
|
FileReader file = new FileReader(mcMMO.getUsersFilePath());
|
||||||
BufferedReader in = new BufferedReader(file);
|
BufferedReader in = new BufferedReader(file);
|
||||||
String line = "";
|
String line = "";
|
||||||
ArrayList<String> players = new ArrayList<String>();
|
ArrayList<String> players = new ArrayList<String>();
|
||||||
@ -130,7 +130,7 @@ public class Leaderboard {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
plugin.getLogger().severe(("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()));
|
mcMMO.p.getLogger().severe(("Exception while reading " + mcMMO.getUsersFilePath() + " (Are you sure you formatted it correctly?)" + e.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillComparator c = new SkillComparator();
|
SkillComparator c = new SkillComparator();
|
||||||
|
@ -25,19 +25,19 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
|
||||||
public class Misc {
|
public final class Misc {
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
|
|
||||||
public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
|
public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||||
public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
|
public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
|
||||||
public static boolean isSpawnerXPEnabled = Config.getInstance().getExperienceGainsMobspawnersEnabled();
|
public static boolean isSpawnerXPEnabled = Config.getInstance().getExperienceGainsMobspawnersEnabled();
|
||||||
|
|
||||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||||
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
||||||
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
||||||
|
|
||||||
|
private Misc() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate activation chance for a skill.
|
* Calculate activation chance for a skill.
|
||||||
*
|
*
|
||||||
@ -75,7 +75,7 @@ public class Misc {
|
|||||||
if (tamer instanceof Player) {
|
if (tamer instanceof Player) {
|
||||||
Player owner = (Player) tamer;
|
Player owner = (Player) tamer;
|
||||||
|
|
||||||
if (owner == attacker || PartyManager.getInstance().inSameParty(attacker, owner)) {
|
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,17 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
|||||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||||
|
|
||||||
public class ModChecks {
|
public final class ModChecks {
|
||||||
private static Config configInstance = Config.getInstance();
|
private static Config configInstance = Config.getInstance();
|
||||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
||||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
||||||
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
private static boolean customBlocksEnabled = configInstance.getBlockModsEnabled();
|
||||||
|
|
||||||
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
private static CustomToolsConfig toolInstance = CustomToolsConfig.getInstance();
|
||||||
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
private static CustomArmorConfig armorInstance = CustomArmorConfig.getInstance();
|
||||||
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
private static CustomBlocksConfig blocksInstance = CustomBlocksConfig.getInstance();
|
||||||
|
|
||||||
|
private ModChecks() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the custom armor associated with an item.
|
* Get the custom armor associated with an item.
|
||||||
*
|
*
|
||||||
|
@ -1,30 +1,42 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
|
|
||||||
public class MOTD {
|
public final class Motd {
|
||||||
private Player player;
|
private static final String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
||||||
private String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
private static final PluginDescriptionFile pluginDescription = mcMMO.p.getDescription();
|
||||||
|
|
||||||
public MOTD(Player player) {
|
private Motd() {}
|
||||||
this.player = player;
|
|
||||||
|
public static void displayAll(Player player) {
|
||||||
|
displayVersion(player, pluginDescription.getVersion());
|
||||||
|
displayHardcoreSettings(player);
|
||||||
|
displayXpPerks(player);
|
||||||
|
displayCooldownPerks(player);
|
||||||
|
displayActivationPerks(player);
|
||||||
|
displayLuckyPerks(player);
|
||||||
|
displayWebsite(player, pluginDescription.getWebsite());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display version info.
|
* Display version info.
|
||||||
* @param version The plugin version
|
* @param player Target player
|
||||||
|
* @param version Plugin version
|
||||||
*/
|
*/
|
||||||
public void displayVersion(String version) {
|
public static void displayVersion(Player player, String version) {
|
||||||
player.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {version}));
|
player.sendMessage(LocaleLoader.getString("MOTD.Version", new Object[] {version}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display Hardcore Mode settings.
|
* Display Hardcore Mode settings.
|
||||||
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public void displayHardcoreSettings() {
|
public static void displayHardcoreSettings(Player player) {
|
||||||
if (Hardcore.statLossEnabled) {
|
if (Hardcore.statLossEnabled) {
|
||||||
if (Hardcore.vampirismEnabled) {
|
if (Hardcore.vampirismEnabled) {
|
||||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
|
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
|
||||||
@ -40,8 +52,9 @@ public class MOTD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display XP perks.
|
* Display XP perks.
|
||||||
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public void displayXpPerks() {
|
public static void displayXpPerks(Player player) {
|
||||||
if (Permissions.xpQuadruple(player)) {
|
if (Permissions.xpQuadruple(player)) {
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
|
||||||
}
|
}
|
||||||
@ -61,8 +74,9 @@ public class MOTD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display cooldown perks.
|
* Display cooldown perks.
|
||||||
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public void displayCooldownPerks() {
|
public static void displayCooldownPerks(Player player) {
|
||||||
if (Permissions.cooldownsHalved(player)) {
|
if (Permissions.cooldownsHalved(player)) {
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/2" }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", new Object[] { "1/2" }) }));
|
||||||
}
|
}
|
||||||
@ -76,8 +90,9 @@ public class MOTD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display activiation perks.
|
* Display activiation perks.
|
||||||
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public void displayActivationPerks() {
|
public static void displayActivationPerks(Player player) {
|
||||||
if (Permissions.activationTwelve(player)) {
|
if (Permissions.activationTwelve(player)) {
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 12 }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", new Object[] { 12 }) }));
|
||||||
}
|
}
|
||||||
@ -91,8 +106,9 @@ public class MOTD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display "lucky" perks.
|
* Display "lucky" perks.
|
||||||
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public void displayLuckyPerks() {
|
public static void displayLuckyPerks(Player player) {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (Permissions.lucky(player, skill)) {
|
if (Permissions.lucky(player, skill)) {
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc.login") }));
|
||||||
@ -103,9 +119,10 @@ public class MOTD {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Display website info.
|
* Display website info.
|
||||||
* @param website The plugin website
|
* @param player Target player
|
||||||
|
* @param website Plugin website
|
||||||
*/
|
*/
|
||||||
public void displayWebsite(String website) {
|
public static void displayWebsite(Player player, String website) {
|
||||||
player.sendMessage(LocaleLoader.getString("MOTD.Website", new Object[] {website}));
|
player.sendMessage(LocaleLoader.getString("MOTD.Website", new Object[] {website}));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,21 +5,11 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.skills.SkillType;
|
import com.gmail.nossr50.skills.SkillType;
|
||||||
|
|
||||||
public class Permissions {
|
public final class Permissions {
|
||||||
public static boolean hasPermission(CommandSender sender, String perm)
|
private Permissions() {}
|
||||||
{
|
|
||||||
if (sender.hasPermission(perm))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
public static boolean hasPermission(CommandSender sender, String perm) {
|
||||||
}
|
return (sender.hasPermission(perm));
|
||||||
|
|
||||||
public static boolean hasPermission(Player sender, String perm)
|
|
||||||
{
|
|
||||||
if (sender.hasPermission(perm))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -12,9 +12,11 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
|
||||||
public class Users {
|
public final class Users {
|
||||||
private static Map<String, McMMOPlayer> players = new HashMap<String, McMMOPlayer>();
|
private static Map<String, McMMOPlayer> players = new HashMap<String, McMMOPlayer>();
|
||||||
|
|
||||||
|
private Users() {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load users.
|
* Load users.
|
||||||
*/
|
*/
|
||||||
@ -22,7 +24,7 @@ public class Users {
|
|||||||
new File(mcMMO.getFlatFileDirectory()).mkdir();
|
new File(mcMMO.getFlatFileDirectory()).mkdir();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new File(mcMMO.getUsersFile()).createNewFile();
|
new File(mcMMO.getUsersFilePath()).createNewFile();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user