Merge remote branch 'origin/master'

This commit is contained in:
GJ 2012-04-27 10:07:04 -04:00
commit 96ab3d1c7e
85 changed files with 3533 additions and 3533 deletions

View File

@ -13,6 +13,7 @@ Version 1.3.06-dev
+ Added API functions for admin & party chat
+ Added Iron Grip skill to Unarmed which gives players an chance to keep from being disarmed.
+ Added some new languages to the locale files.
= Fixed exploit where you could teleport to yourself with PTP to prevent things like fall damage
= Fixed NPE error with Metrics on startup
= Fixed bug where Herbalism required double drops permission to give XP
= Fixed bug where {0} would be displayed in front of your power level in mcstats

View File

@ -3,11 +3,11 @@ package com.gmail.nossr50.api;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ChatAPI {
/**
@ -61,7 +61,7 @@ public class ChatAPI {
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(player) || player.isOp())
if (Permissions.getInstance().adminChat(player) || player.isOp())
player.sendMessage(aPrefix + chatEvent.getMessage());
}
}

View File

@ -2,9 +2,9 @@ package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Users;
public class ExperienceAPI {

View File

@ -4,8 +4,8 @@ import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class PartyAPI {

View File

@ -3,12 +3,12 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class CommandHelper {
@ -23,8 +23,8 @@ public class CommandHelper {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player != null && !mcPermissions.getInstance().permission(player, permission)) {
player.sendMessage(mcLocale.getString("mcMMO.NoPermission"));
if (player != null && !Permissions.getInstance().permission(player, permission)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
}
@ -34,7 +34,7 @@ public class CommandHelper {
public static boolean noConsoleUsage(CommandSender sender) {
if (!(sender instanceof Player)) {
sender.sendMessage(mcLocale.getString("Commands.NoConsole"));
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
return true;
}
@ -51,26 +51,26 @@ public class CommandHelper {
if (Skills.hasGatheringSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.Header.Gathering"));
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
if (mcPermissions.getInstance().excavation(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
if (Permissions.getInstance().excavation(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
}
if (mcPermissions.getInstance().fishing(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
if (Permissions.getInstance().fishing(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
}
if (mcPermissions.getInstance().herbalism(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
if (Permissions.getInstance().herbalism(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
}
if (mcPermissions.getInstance().mining(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
if (Permissions.getInstance().mining(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
}
if (mcPermissions.getInstance().woodcutting(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
if (Permissions.getInstance().woodcutting(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
}
}
}
@ -89,26 +89,26 @@ public class CommandHelper {
if (Skills.hasCombatSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.Header.Combat"));
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
if (mcPermissions.getInstance().axes(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
if (Permissions.getInstance().axes(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
}
if (mcPermissions.getInstance().archery(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
if (Permissions.getInstance().archery(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
}
if (mcPermissions.getInstance().swords(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
if (Permissions.getInstance().swords(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
}
if (mcPermissions.getInstance().taming(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
if (Permissions.getInstance().taming(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
}
if (mcPermissions.getInstance().unarmed(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
if (Permissions.getInstance().unarmed(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
}
}
}
@ -126,14 +126,14 @@ public class CommandHelper {
public static void printMiscSkills(Player inspect, CommandSender display) {
if (Skills.hasMiscSkills(inspect)) {
PlayerProfile PP = Users.getProfile(inspect);
display.sendMessage(mcLocale.getString("Stats.Header.Misc"));
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
if (mcPermissions.getInstance().acrobatics(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (Permissions.getInstance().acrobatics(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
}
if (mcPermissions.getInstance().repair(inspect)) {
display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
if (Permissions.getInstance().repair(inspect)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
}
}
}

View File

@ -7,14 +7,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class AddlevelsCommand implements CommandExecutor{
private final mcMMO plugin;
@ -40,11 +40,11 @@ public class AddlevelsCommand implements CommandExecutor{
case 2:
if (sender instanceof Player) {
if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
if (Misc.isInt(args[1])) {
modifiedPlayer = (Player) sender;
levels = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
@ -54,7 +54,7 @@ public class AddlevelsCommand implements CommandExecutor{
skillName = "all skills";
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
}
PP.addLevels(skill, levels);
@ -73,16 +73,16 @@ public class AddlevelsCommand implements CommandExecutor{
PP = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
if (Misc.isInt(args[2])) {
levels = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
@ -94,7 +94,7 @@ public class AddlevelsCommand implements CommandExecutor{
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}

View File

@ -6,13 +6,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
//TODO: Any way we can make this work for offline use?
public class AddxpCommand implements CommandExecutor {
@ -38,11 +38,11 @@ public class AddxpCommand implements CommandExecutor {
case 2:
if (sender instanceof Player) {
if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
if (Misc.isInt(args[1])) {
modifiedPlayer = (Player) sender;
xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
@ -53,7 +53,7 @@ public class AddxpCommand implements CommandExecutor {
skillName = "all skills";
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
}
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
@ -80,16 +80,16 @@ public class AddxpCommand implements CommandExecutor {
String playerName = modifiedPlayer.getName();
if (!Users.getProfile(modifiedPlayer).isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
if (Misc.isInt(args[2])) {
xp = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
@ -101,7 +101,7 @@ public class AddxpCommand implements CommandExecutor {
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}

View File

@ -6,14 +6,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class InspectCommand implements CommandExecutor {
private final mcMMO plugin;
@ -40,49 +40,49 @@ public class InspectCommand implements CommandExecutor {
if (target.isOnline()) {
Player player = (Player) target;
if (sender instanceof Player && !sender.isOp() && !m.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0) && !mcPermissions.getInstance().inspectDistanceBypass((Player) sender)) {
sender.sendMessage(mcLocale.getString("Inspect.TooFar"));
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.Stats", new Object[] { target.getName() }));
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
CommandHelper.printGatheringSkills(player, sender);
CommandHelper.printCombatSkills(player, sender);
CommandHelper.printMiscSkills(player, sender);
sender.sendMessage(mcLocale.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() }));
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() }));
return true;
}
else {
if (sender instanceof Player && !sender.isOp() && !mcPermissions.getInstance().inspectOfflineBypass((Player) sender)) {
sender.sendMessage(mcLocale.getString("Inspect.Offline"));
if (sender instanceof Player && !sender.isOp() && !Permissions.getInstance().inspectOfflineBypass((Player) sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(mcLocale.getString("Stats.Header.Gathering"));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(mcLocale.getString("Stats.Header.Combat"));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(mcLocale.getString("Stats.Header.Misc"));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
return true;
}

View File

@ -5,10 +5,10 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McstatsCommand implements CommandExecutor {
@ -21,14 +21,14 @@ public class McstatsCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
player.sendMessage(mcLocale.getString("Stats.Own.Stats"));
player.sendMessage(mcLocale.getString("mcMMO.NoSkillNote"));
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
CommandHelper.printGatheringSkills(player);
CommandHelper.printCombatSkills(player);
CommandHelper.printMiscSkills(player);
player.sendMessage(mcLocale.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) }));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) }));
return true;
}

View File

@ -7,14 +7,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class MmoeditCommand implements CommandExecutor {
private final mcMMO plugin;
@ -40,11 +40,11 @@ public class MmoeditCommand implements CommandExecutor {
case 2:
if (sender instanceof Player) {
if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
if (Misc.isInt(args[1])) {
modifiedPlayer = (Player) sender;
newValue = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
@ -54,7 +54,7 @@ public class MmoeditCommand implements CommandExecutor {
skillName = "all skills";
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
}
PP.modifySkill(skill, newValue);
@ -76,16 +76,16 @@ public class MmoeditCommand implements CommandExecutor {
PP = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
if (Misc.isInt(args[2])) {
newValue = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
@ -97,7 +97,7 @@ public class MmoeditCommand implements CommandExecutor {
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = m.getCapitalized(skill.toString());
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}

View File

@ -6,11 +6,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.runnables.SQLConversionTask;
import com.gmail.nossr50.util.Users;
public class MmoupdateCommand implements CommandExecutor {
private final mcMMO plugin;

View File

@ -5,11 +5,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
public class XprateCommand implements CommandExecutor {
private final mcMMO plugin;
@ -22,9 +22,9 @@ public class XprateCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage1 = mcLocale.getString("Commands.xprate.proper.0");
String usage2 = mcLocale.getString("Commands.xprate.proper.1");
String usage3 = mcLocale.getString("Commands.xprate.proper.2");
String usage1 = LocaleLoader.getString("Commands.xprate.proper.0");
String usage2 = LocaleLoader.getString("Commands.xprate.proper.1");
String usage3 = LocaleLoader.getString("Commands.xprate.proper.2");
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
return true;
@ -35,7 +35,7 @@ public class XprateCommand implements CommandExecutor {
if (args[0].equalsIgnoreCase("reset")) {
if (xpevent) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
}
xpevent = !xpevent;
@ -45,7 +45,7 @@ public class XprateCommand implements CommandExecutor {
Config.getInstance().xpGainMultiplier = oldrate;
}
}
else if (m.isInt(args[0])) {
else if (Misc.isInt(args[0])) {
sender.sendMessage(usage3);
}
else {
@ -55,7 +55,7 @@ public class XprateCommand implements CommandExecutor {
return true;
case 2:
if (m.isInt(args[0])) {
if (Misc.isInt(args[0])) {
oldrate = Config.getInstance().xpGainMultiplier;
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
@ -65,12 +65,12 @@ public class XprateCommand implements CommandExecutor {
sender.sendMessage(usage3);
}
Config.getInstance().xpGainMultiplier = m.getInt(args[0]);
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
if (xpevent) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(mcLocale.getString("Commands.xprate.started.0"));
x.sendMessage(mcLocale.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
else {

View File

@ -5,10 +5,10 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McabilityCommand implements CommandExecutor {
@ -25,10 +25,10 @@ public class McabilityCommand implements CommandExecutor {
PlayerProfile PP = Users.getProfile((Player) sender);
if (PP.getAbilityUse()) {
sender.sendMessage(mcLocale.getString("Commands.Ability.Off"));
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.Ability.On"));
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
}
PP.toggleAbilityUse();

View File

@ -6,9 +6,9 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
public class MccCommand implements CommandExecutor {
@ -23,49 +23,49 @@ public class MccCommand implements CommandExecutor {
player.sendMessage(ChatColor.RED + "---[]" + ChatColor.YELLOW + "mcMMO Commands" + ChatColor.RED + "[]---"); //TODO: Needs more locale.
if (mcPermissions.getInstance().party(player)) {
player.sendMessage(mcLocale.getString("Commands.Party.Commands"));
player.sendMessage("/party " + mcLocale.getString("Commands.Party"));
player.sendMessage("/party q " + mcLocale.getString("Commands.Party.Quit"));
if (Permissions.getInstance().party(player)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
player.sendMessage("/party " + LocaleLoader.getString("Commands.Party"));
player.sendMessage("/party q " + LocaleLoader.getString("Commands.Party.Quit"));
if (mcPermissions.getInstance().partyChat(player)) {
player.sendMessage("/p " + mcLocale.getString("Commands.Party.Toggle"));
if (Permissions.getInstance().partyChat(player)) {
player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle"));
}
player.sendMessage("/invite " + mcLocale.getString("Commands.Party.Invite"));
player.sendMessage("/accept " + mcLocale.getString("Commands.Party.Accept"));
player.sendMessage("/invite " + LocaleLoader.getString("Commands.Party.Invite"));
player.sendMessage("/accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (mcPermissions.getInstance().partyTeleport(player)) {
player.sendMessage("/ptp " + mcLocale.getString("Commands.Party.Teleport"));
if (Permissions.getInstance().partyTeleport(player)) {
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
player.sendMessage(mcLocale.getString("Commands.Other"));
player.sendMessage("/mcstats " + mcLocale.getString("Commands.Stats"));
player.sendMessage("/mctop " + mcLocale.getString("m.mccLeaderboards"));
player.sendMessage(LocaleLoader.getString("Commands.Other"));
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
player.sendMessage("/mctop " + LocaleLoader.getString("m.mccLeaderboards"));
if (mcPermissions.getInstance().mcAbility(player)) {
player.sendMessage("/mcability " + mcLocale.getString("Commands.ToggleAbility"));
if (Permissions.getInstance().mcAbility(player)) {
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (mcPermissions.getInstance().adminChat(player)) {
player.sendMessage("/a " + mcLocale.getString("Commands.AdminToggle"));
if (Permissions.getInstance().adminChat(player)) {
player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (mcPermissions.getInstance().inspect(player)) {
player.sendMessage("/inspect " + mcLocale.getString("Commands.Inspect"));
if (Permissions.getInstance().inspect(player)) {
player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (mcPermissions.getInstance().mmoedit(player)) {
player.sendMessage("/mmoedit " + mcLocale.getString("Commands.mmoedit"));
if (Permissions.getInstance().mmoedit(player)) {
player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (mcPermissions.getInstance().mcgod(player)) {
player.sendMessage("/mcgod " + mcLocale.getString("Commands.mcgod"));
if (Permissions.getInstance().mcgod(player)) {
player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
}
player.sendMessage(mcLocale.getString("Commands.SkillInfo"));
player.sendMessage("/mcmmo " + mcLocale.getString("Commands.ModDescription"));
player.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
player.sendMessage("/mcmmo " + LocaleLoader.getString("Commands.ModDescription"));
return true;
}

View File

@ -5,10 +5,10 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McgodCommand implements CommandExecutor {
@ -25,10 +25,10 @@ public class McgodCommand implements CommandExecutor {
PlayerProfile PP = Users.getProfile((Player) sender);
if (PP.getGodMode()) {
sender.sendMessage(mcLocale.getString("Commands.GodMode.Disabled"));
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.GodMode.Enabled"));
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
}
PP.toggleGodMode();

View File

@ -8,13 +8,13 @@ import org.bukkit.command.CommandSender;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
public class McmmoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String description = mcLocale.getString("mcMMO.Description");
String description = LocaleLoader.getString("mcMMO.Description");
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);

View File

@ -7,11 +7,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McrefreshCommand implements CommandExecutor {
private final mcMMO plugin;
@ -48,7 +48,7 @@ public class McrefreshCommand implements CommandExecutor {
String playerName = player.getName();
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
@ -67,7 +67,7 @@ public class McrefreshCommand implements CommandExecutor {
PP.resetAbilityMode();
if (player.isOnline()) {
((Player) player).sendMessage(mcLocale.getString("Ability.Generic.Refresh"));
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
}
return true;

View File

@ -10,11 +10,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McremoveCommand implements CommandExecutor {
private final String location = mcMMO.usersFile;
@ -82,7 +82,7 @@ public class McremoveCommand implements CommandExecutor {
}
else {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
}
}
else {
@ -90,7 +90,7 @@ public class McremoveCommand implements CommandExecutor {
sender.sendMessage(success);
}
else {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
}
}

View File

@ -7,12 +7,12 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.Leaderboard;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc;
public class MctopCommand implements CommandExecutor {
@ -28,25 +28,25 @@ public class MctopCommand implements CommandExecutor {
return true;
case 1:
if (m.isInt(args[0])) {
if (Misc.isInt(args[0])) {
flatfileDisplay(Integer.valueOf(args[0]), "ALL", sender);
}
else if (Skills.isSkill(args[0])) {
flatfileDisplay(1, args[0].toUpperCase(), sender);
}
else {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
return true;
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
if (Misc.isInt(args[1])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
}
else {
@ -69,25 +69,25 @@ public class MctopCommand implements CommandExecutor {
return true;
case 1:
if (m.isInt(args[0])) {
if (Misc.isInt(args[0])) {
sqlDisplay(Integer.valueOf(args[0]), powerlevel, sender);
}
else if (Skills.isSkill(args[0])) {
sqlDisplay(1, args[0].toLowerCase(), sender);
}
else {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
}
return true;
case 2:
if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
if (Misc.isInt(args[1])) {
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
}
else {
@ -107,10 +107,10 @@ public class MctopCommand implements CommandExecutor {
String[] info = Leaderboard.retrieveInfo(skill, page);
if (skill == "ALL") {
sender.sendMessage(mcLocale.getString("Commands.PowerLevel.Leaderboard"));
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.Skill.Leaderboard", new Object[] { m.getCapitalized(skill) }));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(skill) }));
}
int n = (page * 10) - 9; // Position
@ -136,10 +136,10 @@ public class MctopCommand implements CommandExecutor {
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
if (query == "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing") {
sender.sendMessage(mcLocale.getString("Commands.PowerLevel.Leaderboard"));
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.Skill.Leaderboard", new Object[] { m.getCapitalized(query) }));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", new Object[] { Misc.getCapitalized(query) }));
}
for (int i = (page * 10) - 9; i <= (page * 10); i++) {

View File

@ -6,13 +6,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ACommand implements CommandExecutor {
private final mcMMO plugin;
@ -42,10 +42,10 @@ public class ACommand implements CommandExecutor {
PP.toggleAdminChat();
if (PP.getAdminChatMode()) {
sender.sendMessage(mcLocale.getString("Commands.AdminChat.On"));
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.AdminChat.Off"));
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.Off"));
}
}
else {
@ -88,7 +88,7 @@ public class ACommand implements CommandExecutor {
plugin.getLogger().info("[A]<*Console*> " + message);
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(player) || player.isOp()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
player.sendMessage(prefix + message);
}
}

View File

@ -5,14 +5,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class AcceptCommand implements CommandExecutor {
private final mcMMO plugin;
@ -60,7 +60,7 @@ public class AcceptCommand implements CommandExecutor {
}
else {
player.sendMessage(mcLocale.getString("mcMMO.NoInvites"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
}
return true;

View File

@ -6,12 +6,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
//TODO: Make this work from console.
public class InviteCommand implements CommandExecutor {
@ -41,7 +41,7 @@ public class InviteCommand implements CommandExecutor {
Party partyInstance = Party.getInstance();
if (!PP.inParty()) {
player.sendMessage(mcLocale.getString("Commands.Party.None"));
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@ -52,19 +52,19 @@ public class InviteCommand implements CommandExecutor {
PlayerProfile PPt = Users.getProfile(target);
PPt.modifyInvite(PP.getParty());
player.sendMessage(mcLocale.getString("Commands.Invite.Success"));
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(mcLocale.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(mcLocale.getString("Commands.Party.Invite.1"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}
else {
player.sendMessage(mcLocale.getString("Party.Locked"));
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
}
else {
player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}

View File

@ -6,13 +6,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class PCommand implements CommandExecutor {
private final mcMMO plugin;
@ -43,10 +43,10 @@ public class PCommand implements CommandExecutor {
PP.togglePartyChat();
if (PP.getPartyChatMode()) {
sender.sendMessage(mcLocale.getString("Commands.Party.Chat.On"));
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
}
else {
sender.sendMessage(mcLocale.getString("Commands.Party.Chat.Off"));
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Off"));
}
}
else {
@ -61,7 +61,7 @@ public class PCommand implements CommandExecutor {
PP = Users.getProfile(player);
if (!PP.inParty()) {
player.sendMessage(mcLocale.getString("Commands.Party.None"));
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@ -87,7 +87,7 @@ public class PCommand implements CommandExecutor {
}
if (!Party.getInstance().isParty(args[0])) {
sender.sendMessage(mcLocale.getString("Party.InvalidName"));
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}

View File

@ -6,14 +6,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class PartyCommand implements CommandExecutor {
private final mcMMO plugin;
@ -48,9 +48,9 @@ public class PartyCommand implements CommandExecutor {
switch (args.length) {
case 0:
if (!inParty) {
player.sendMessage(mcLocale.getString("Party.Help.0"));
player.sendMessage(mcLocale.getString("Party.Help.1"));
player.sendMessage(mcLocale.getString("Party.Help.2"));
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
}
else {
String tempList = "";
@ -71,8 +71,8 @@ public class PartyCommand implements CommandExecutor {
tempList += ChatColor.WHITE + playerName;
}
player.sendMessage(mcLocale.getString("Commands.Party.InParty", new Object[] { partyName }));
player.sendMessage(mcLocale.getString("Commands.Party.Members", new Object[] { tempList }));
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] { tempList }));
}
return true;
@ -88,33 +88,33 @@ public class PartyCommand implements CommandExecutor {
}
partyInstance.removeFromParty(player, PP);
player.sendMessage(mcLocale.getString("Commands.Party.Leave"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
player.sendMessage("Commands.Party.None");
}
}
else if (args[0].equals("?")) {
player.sendMessage(mcLocale.getString("Party.Help.3"));
player.sendMessage(mcLocale.getString("Party.Help.1"));
player.sendMessage(mcLocale.getString("Party.Help.4"));
player.sendMessage(mcLocale.getString("Party.Help.5"));
player.sendMessage(mcLocale.getString("Party.Help.6"));
player.sendMessage(mcLocale.getString("Party.Help.7"));
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
}
else if (args[0].equalsIgnoreCase("lock")) {
if (inParty) {
if (isLeader) {
if (partyInstance.isPartyLocked(partyName)) {
player.sendMessage(mcLocale.getString("Party.IsLocked"));
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
}
else {
partyInstance.lockParty(partyName);
player.sendMessage(mcLocale.getString("Party.Locked"));
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
}
else {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
@ -125,15 +125,15 @@ public class PartyCommand implements CommandExecutor {
if (inParty) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
player.sendMessage(mcLocale.getString("Party.IsntLocked"));
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
}
else {
partyInstance.unlockParty(partyName);
player.sendMessage(mcLocale.getString("Party.Unlocked"));
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
}
else {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
@ -167,7 +167,7 @@ public class PartyCommand implements CommandExecutor {
case 2:
if (!partyInstance.isParty(args[0])) {
sender.sendMessage(mcLocale.getString("Party.InvalidName"));
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}
@ -179,10 +179,10 @@ public class PartyCommand implements CommandExecutor {
}
partyInstance.setPartyPassword(partyName, args[1]);
player.sendMessage(mcLocale.getString("Party.PasswordSet", new Object[] { args[1] }));
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] { args[1] }));
}
else {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("kick")) {
@ -190,7 +190,7 @@ public class PartyCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
@ -198,7 +198,7 @@ public class PartyCommand implements CommandExecutor {
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { targetName }));
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
@ -211,11 +211,11 @@ public class PartyCommand implements CommandExecutor {
}
partyInstance.removeFromParty(target, PPt);
target.sendMessage(mcLocale.getString("Commands.Party.Kick", new Object[] { partyName }));
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] { partyName }));
}
}
else {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("owner")) {
@ -223,14 +223,14 @@ public class PartyCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { targetName }));
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
@ -239,7 +239,7 @@ public class PartyCommand implements CommandExecutor {
}
}
else {
player.sendMessage(mcLocale.getString("Party.NotOwner"));
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
@ -268,9 +268,9 @@ public class PartyCommand implements CommandExecutor {
return true;
default:
player.sendMessage(mcLocale.getString("Party.Help.0"));
player.sendMessage(mcLocale.getString("Party.Help.1"));
player.sendMessage(mcLocale.getString("Party.Help.2"));
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
return true;
}
}

View File

@ -6,14 +6,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class PtpCommand implements CommandExecutor {
private final mcMMO plugin;
@ -40,12 +40,12 @@ public class PtpCommand implements CommandExecutor {
PlayerProfile PP = Users.getProfile(player);
if (!Party.getInstance().isInParty(player, PP)) {
player.sendMessage(mcLocale.getString("Commands.Party.None"));
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
player.sendMessage(mcLocale.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
return true;
}
@ -53,15 +53,16 @@ public class PtpCommand implements CommandExecutor {
if (player.equals(target)) {
player.sendMessage("You can't teleport to yourself!"); //TODO: Use locale
return true;
}
if (target == null) {
player.sendMessage(mcLocale.getString("Party.Teleport.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Teleport.Invalid"));
return true;
}
if (target.isDead()) {
player.sendMessage(mcLocale.getString("Party.Teleport.Dead"));
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return true;
}
@ -74,11 +75,11 @@ public class PtpCommand implements CommandExecutor {
}
player.teleport(target);
player.sendMessage(mcLocale.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(mcLocale.getString("Party.Teleport.Target", new Object[] { player.getName() }));
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
}
else {
player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { target.getName() }));
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
return true;
}

View File

@ -5,13 +5,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsCommand implements CommandExecutor {
private float skillValue;
@ -40,40 +40,40 @@ public class AcrobaticsCommand implements CommandExecutor {
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Acrobatics.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
}
if (canRoll) {
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.0"), mcLocale.getString("Acrobatics.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
if (canGracefulRoll) {
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.2"), mcLocale.getString("Acrobatics.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3") }));
}
if (canDodge) {
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Acrobatics.Effect.4"), mcLocale.getString("Acrobatics.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canRoll) {
player.sendMessage(mcLocale.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
if (canGracefulRoll) {
player.sendMessage(mcLocale.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
if (canDodge) {
player.sendMessage(mcLocale.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
@ -105,7 +105,7 @@ public class AcrobaticsCommand implements CommandExecutor {
}
private void permissionsCheck(Player player) {
mcPermissions permInstance = mcPermissions.getInstance();
Permissions permInstance = Permissions.getInstance();
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class ArcheryCommand implements CommandExecutor {
private float skillValue;
@ -34,19 +34,19 @@ public class ArcheryCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Archery.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Archery") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Archery.Effect.0"), mcLocale.getString("Archery.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Archery.Effect.2"), mcLocale.getString("Archery.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Archery.Effect.4"), mcLocale.getString("Archery.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
player.sendMessage(mcLocale.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
player.sendMessage(mcLocale.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);

View File

@ -5,11 +5,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class AxesCommand implements CommandExecutor {
private float skillValue;
@ -35,23 +35,23 @@ public class AxesCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.AXES);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Axes.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Axes") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Axes.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Axes") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Axes.Effect.0"), mcLocale.getString("Axes.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Axes.Effect.2"), mcLocale.getString("Axes.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Axes.Effect.4"), mcLocale.getString("Axes.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Axes.Effect.6"), mcLocale.getString("Axes.Effect.7") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Axes.Effect.8"), mcLocale.getString("Axes.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Axes.Combat.CritChance", new Object[] { critChance }));
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Axes.Ability.Bonus.0"), mcLocale.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Axes.Ability.Bonus.2"), mcLocale.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Axes.Ability.Bonus.4"), mcLocale.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
player.sendMessage(mcLocale.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
return true;
}

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class ExcavationCommand implements CommandExecutor {
private float skillValue;
@ -32,16 +32,16 @@ public class ExcavationCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Excavation.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Excavation") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Excavation.Effect.0"), mcLocale.getString("Excavation.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Excavation.Effect.2"), mcLocale.getString("Excavation.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);

View File

@ -5,13 +5,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Fishing;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class FishingCommand implements CommandExecutor {
@Override
@ -27,25 +27,25 @@ public class FishingCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Fishing.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Fishing") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Fishing.Effect.0"), mcLocale.getString("Fishing.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Fishing.Effect.2"), mcLocale.getString("Fishing.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Fishing.Effect.4"), mcLocale.getString("Fishing.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
player.sendMessage(mcLocale.getString("Fishing.Ability.Info"));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Info"));
//TODO: Do we really need to display this twice? Not like there are any associated stats.
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Fishing.Ability.Locked.0") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
}
else {
player.sendMessage(mcLocale.getString("Fishing.Ability.Shake"));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
}
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class HerbalismCommand implements CommandExecutor {
private float skillValue;
@ -36,23 +36,23 @@ public class HerbalismCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Herbalism.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Herbalism") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Herbalism.Effect.0"), mcLocale.getString("Herbalism.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Herbalism.Effect.2"), mcLocale.getString("Herbalism.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Herbalism.Effect.4"), mcLocale.getString("Herbalism.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Herbalism.Effect.6"), mcLocale.getString("Herbalism.Effect.7") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Herbalism.Effect.8"), mcLocale.getString("Herbalism.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
player.sendMessage(mcLocale.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
player.sendMessage(mcLocale.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
player.sendMessage(mcLocale.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
player.sendMessage(mcLocale.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class MiningCommand implements CommandExecutor {
private float skillValue;
@ -36,40 +36,40 @@ public class MiningCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.MINING);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Mining.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Mining") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Mining.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Mining") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Mining.Effect.0"), mcLocale.getString("Mining.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Mining.Effect.2"), mcLocale.getString("Mining.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Mining.Effect.4"), mcLocale.getString("Mining.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Mining.Effect.6"), mcLocale.getString("Mining.Effect.7") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Mining.Effect.8"), mcLocale.getString("Mining.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
player.sendMessage(mcLocale.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
if (PP.getSkillLevel(SkillType.MINING) < 125) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Mining.Ability.Locked.0") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
}
else {
player.sendMessage(mcLocale.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, mcLocale.getString("Mining.Blast.Effect." + (blastMiningRank - 1)) }));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (blastMiningRank - 1)) }));
}
if (PP.getSkillLevel(SkillType.MINING) < 250) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Mining.Ability.Locked.1") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
}
else {
player.sendMessage(mcLocale.getString("m.MiningBiggerBombs", new Object[] { blastRadiusIncrease }));
player.sendMessage(LocaleLoader.getString("m.MiningBiggerBombs", new Object[] { blastRadiusIncrease }));
}
if (PP.getSkillLevel(SkillType.MINING) < 500) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Mining.Ability.Locked.2") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
}
else {
player.sendMessage(mcLocale.getString("m.MiningDemolitionsExpertDamageDecrease", new Object[] { blastDamageDecrease }));
player.sendMessage(LocaleLoader.getString("m.MiningDemolitionsExpertDamageDecrease", new Object[] { blastDamageDecrease }));
}
Page.grabGuidePageForSkill(SkillType.MINING, player, args);

View File

@ -5,14 +5,14 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class RepairCommand implements CommandExecutor {
private float skillValue;
@ -37,23 +37,23 @@ public class RepairCommand implements CommandExecutor {
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Repair.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Repair") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Repair.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Repair.Effect.0"), mcLocale.getString("Repair.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Repair.Effect.2"), mcLocale.getString("Repair.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Repair.Effect.4"), mcLocale.getString("Repair.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), mcLocale.getString("Repair.Effect.7") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Repair.Effect.8"), mcLocale.getString("Repair.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), LocaleLoader.getString("Repair.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
player.sendMessage(mcLocale.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
player.sendMessage(mcLocale.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
player.sendMessage(mcLocale.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
player.sendMessage(mcLocale.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class SwordsCommand implements CommandExecutor {
private float skillValue;
@ -35,22 +35,22 @@ public class SwordsCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.SWORDS);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Swords.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Swords") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Swords.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Swords") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Swords.Effect.0"), mcLocale.getString("Swords.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Swords.Effect.2"), mcLocale.getString("Swords.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Swords.Effect.4"), mcLocale.getString("Swords.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Swords.Effect.6"), mcLocale.getString("Swords.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
player.sendMessage(mcLocale.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
player.sendMessage(mcLocale.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(mcLocale.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
player.sendMessage(mcLocale.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);

View File

@ -5,13 +5,13 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class TamingCommand implements CommandExecutor {
private float skillValue;
@ -33,60 +33,60 @@ public class TamingCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.TAMING);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Taming.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Taming") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.0"), mcLocale.getString("Taming.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.2"), mcLocale.getString("Taming.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.4"), mcLocale.getString("Taming.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.6"), mcLocale.getString("Taming.Effect.7") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.8"), mcLocale.getString("Taming.Effect.9") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.10"), mcLocale.getString("Taming.Effect.11") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.12"), mcLocale.getString("Taming.Effect.13") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Taming.Effect.16"), mcLocale.getString("Taming.Effect.17") }));
player.sendMessage(mcLocale.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
player.sendMessage(mcLocale.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Taming.Ability.Locked.0") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Taming.Ability.Bonus.0"), mcLocale.getString("Taming.Ability.Bonus.1") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Taming.Ability.Locked.1") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Taming.Ability.Bonus.2"), mcLocale.getString("Taming.Ability.Bonus.3") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Taming.Ability.Locked.2") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Taming.Ability.Bonus.4"), mcLocale.getString("Taming.Ability.Bonus.5") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Taming.Ability.Locked.3") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Taming.Ability.Bonus.6"), mcLocale.getString("Taming.Ability.Bonus.7") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Taming.Ability.Locked.4") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Taming.Ability.Bonus.8"), mcLocale.getString("Taming.Ability.Bonus.9 ") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9 ") }));
}
player.sendMessage(mcLocale.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class UnarmedCommand implements CommandExecutor {
private float skillValue;
@ -35,21 +35,21 @@ public class UnarmedCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Unarmed.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.Unarmed") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Unarmed.Effect.0"), mcLocale.getString("Unarmed.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Unarmed.Effect.2"), mcLocale.getString("Unarmed.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Unarmed.Effect.4"), mcLocale.getString("Unarmed.Effect.5") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Unarmed.Effect.6"), mcLocale.getString("Unarmed.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Unarmed.Ability.Bonus.0"), mcLocale.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
player.sendMessage(mcLocale.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
player.sendMessage(mcLocale.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
player.sendMessage(mcLocale.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);

View File

@ -5,12 +5,12 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class WoodcuttingCommand implements CommandExecutor {
private float skillValue;
@ -33,26 +33,26 @@ public class WoodcuttingCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("WoodCutting.SkillName") }));
player.sendMessage(mcLocale.getString("Commands.XPGain", new Object[] { mcLocale.getString("Commands.XPGain.WoodCutting") }));
player.sendMessage(mcLocale.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Effects.Effects") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Woodcutting.Effect.0"), mcLocale.getString("Woodcutting.Effect.1") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Woodcutting.Effect.2"), mcLocale.getString("Woodcutting.Effect.3") }));
player.sendMessage(mcLocale.getString("Effects.Template", new Object[] { mcLocale.getString("Woodcutting.Effect.4"), mcLocale.getString("Woodcutting.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
player.sendMessage(mcLocale.getString("Skills.Header", new Object[] { mcLocale.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
player.sendMessage(mcLocale.getString("Ability.Generic.Template.Lock", new Object[] { mcLocale.getString("Woodcutting.Ability.Locked.0") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
}
else {
player.sendMessage(mcLocale.getString("Ability.Generic.Template", new Object[] { mcLocale.getString("Woodcutting.Ability.0"), mcLocale.getString("Woodcutting.Ability.1") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
}
player.sendMessage(mcLocale.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
player.sendMessage(mcLocale.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);

View File

@ -6,15 +6,15 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class MchudCommand implements CommandExecutor {
private final mcMMO plugin;
@ -33,7 +33,7 @@ public class MchudCommand implements CommandExecutor {
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled()) {
sender.sendMessage(mcLocale.getString("Commands.Disabled"));
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@ -6,16 +6,16 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class XplockCommand implements CommandExecutor {
@Override
@ -27,7 +27,7 @@ public class XplockCommand implements CommandExecutor {
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
sender.sendMessage(mcLocale.getString("Commands.Disabled"));
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
@ -38,7 +38,7 @@ public class XplockCommand implements CommandExecutor {
case 0:
if (PP.getXpBarLocked()) {
PP.toggleXpBarLocked();
player.sendMessage(mcLocale.getString("Commands.xplock.unlocked"));
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
return true;
}
@ -47,27 +47,27 @@ public class XplockCommand implements CommandExecutor {
if (lastGained != null) {
PP.toggleXpBarLocked();
PP.setSkillLock(lastGained);
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(lastGained.toString()) }));
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
return true;
}
case 1:
if (Skills.isSkill(args[0])) {
if (mcPermissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
PP.setXpBarLocked(true);
PP.setSkillLock(Skills.getSkillType(args[0]));
SpoutStuff.updateXpBar(player);
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(args[0]) }));
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
return true;
}
else {
player.sendMessage(mcLocale.getString("mcMMO.NoPermission"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
}
else {
player.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}

View File

@ -3,12 +3,12 @@ package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
import com.gmail.nossr50.util.Permissions;
public enum AbilityType {
BERSERK(
@ -104,23 +104,23 @@ public enum AbilityType {
}
public String getAbilityOn() {
return mcLocale.getString(this.abilityOn);
return LocaleLoader.getString(this.abilityOn);
}
public String getAbilityOff() {
return mcLocale.getString(this.abilityOff);
return LocaleLoader.getString(this.abilityOff);
}
public String getAbilityPlayer(Player player) {
return mcLocale.getString(this.abilityPlayer, new Object[] {player.getName()});
return LocaleLoader.getString(this.abilityPlayer, new Object[] {player.getName()});
}
public String getAbilityPlayerOff(Player player) {
return mcLocale.getString(this.abilityPlayerOff, new Object[] {player.getName()});
return LocaleLoader.getString(this.abilityPlayerOff, new Object[] {player.getName()});
}
public String getAbilityRefresh() {
return mcLocale.getString(this.abilityRefresh);
return LocaleLoader.getString(this.abilityRefresh);
}
/**
@ -132,31 +132,31 @@ public enum AbilityType {
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return mcPermissions.getInstance().berserk(player);
return Permissions.getInstance().berserk(player);
case BLAST_MINING:
return mcPermissions.getInstance().blastMining(player);
return Permissions.getInstance().blastMining(player);
case GIGA_DRILL_BREAKER:
return mcPermissions.getInstance().gigaDrillBreaker(player);
return Permissions.getInstance().gigaDrillBreaker(player);
case GREEN_TERRA:
return mcPermissions.getInstance().greenTerra(player);
return Permissions.getInstance().greenTerra(player);
case LEAF_BLOWER:
return mcPermissions.getInstance().leafBlower(player);
return Permissions.getInstance().leafBlower(player);
case SERRATED_STRIKES:
return mcPermissions.getInstance().serratedStrikes(player);
return Permissions.getInstance().serratedStrikes(player);
case SKULL_SPLIITER:
return mcPermissions.getInstance().skullSplitter(player);
return Permissions.getInstance().skullSplitter(player);
case SUPER_BREAKER:
return mcPermissions.getInstance().superBreaker(player);
return Permissions.getInstance().superBreaker(player);
case TREE_FELLER:
return mcPermissions.getInstance().treeFeller(player);
return Permissions.getInstance().treeFeller(player);
default:
return false;

View File

@ -9,11 +9,11 @@ import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class HUDmmo {
private int center_x = 427 / 2;
@ -286,7 +286,7 @@ public class HUDmmo {
return;
}
((GenericTexture) xpicon).setUrl(m.getCapitalized(theType.toString()) + ".png");
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
@ -314,7 +314,7 @@ public class HUDmmo {
Color color = getRetroColor(theType);
xpicon.setUrl(m.getCapitalized(theType.toString()) + "_r.png");
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + "_r.png");
xpfill.setBottomColor(color);
xpfill.setTopColor(color);

View File

@ -13,8 +13,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.mcMMO;
public class PlayerProfile {
@ -30,7 +30,6 @@ public class PlayerProfile {
/* Party Stuff */
private String party;
private String invite;
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
/* Toggles */
private boolean loaded = false;
@ -101,15 +100,15 @@ public class PlayerProfile {
public boolean loadMySQL() {
int id = 0;
id = mcMMO.database.getInt("SELECT id FROM "+tablePrefix+"users WHERE user = '" + playerName + "'");
if(id == 0)
return false;
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
this.userid = id;
if (id > 0) {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+tablePrefix+"huds WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
if(huds.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+tablePrefix+"huds (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"huds (user_id) VALUES ("+id+")");
} else {
if(huds.get(1).get(0) != null)
{
@ -124,17 +123,17 @@ public class PlayerProfile {
hud = Config.getInstance().defaulthud;
}
}
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+tablePrefix+"users WHERE id = " + id);
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE id = " + id);
//lastlogin = Integer.parseInt(users.get(1).get(0));
party = users.get(1).get(1);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+tablePrefix+"cooldowns WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+Config.getInstance().getMySQLTablePrefix()+"cooldowns WHERE user_id = " + id);
/*
* I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works
*/
if(cooldowns.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+tablePrefix+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
}
else
{
@ -147,7 +146,7 @@ public class PlayerProfile {
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
}
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+tablePrefix+"skills WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + id);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
@ -160,7 +159,7 @@ public class PlayerProfile {
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+tablePrefix+"experience WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + id);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
@ -183,11 +182,11 @@ public class PlayerProfile {
public void addMySQLPlayer() {
int id = 0;
mcMMO.database.write("INSERT INTO "+tablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.getInt("SELECT id FROM "+tablePrefix+"users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO "+tablePrefix+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+tablePrefix+"skills (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+tablePrefix+"experience (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
this.userid = id;
}
@ -206,53 +205,53 @@ public class PlayerProfile {
if(!character[0].equals(playerName)){continue;}
//Get Mining
if(character.length > 1 && m.isInt(character[1]))
if(character.length > 1 && Misc.isInt(character[1]))
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
//Party
if(character.length > 3)
party = character[3];
//Mining XP
if(character.length > 4 && m.isInt(character[4]))
if(character.length > 4 && Misc.isInt(character[4]))
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
if(character.length > 5 && m.isInt(character[5]))
if(character.length > 5 && Misc.isInt(character[5]))
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
if(character.length > 6 && m.isInt(character[6]))
if(character.length > 6 && Misc.isInt(character[6]))
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
if(character.length > 7 && m.isInt(character[7]))
if(character.length > 7 && Misc.isInt(character[7]))
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
if(character.length > 8 && m.isInt(character[8]))
if(character.length > 8 && Misc.isInt(character[8]))
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
if(character.length > 9 && m.isInt(character[9]))
if(character.length > 9 && Misc.isInt(character[9]))
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
if(character.length > 10 && m.isInt(character[10]))
if(character.length > 10 && Misc.isInt(character[10]))
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
if(character.length > 11 && m.isInt(character[11]))
if(character.length > 11 && Misc.isInt(character[11]))
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
if(character.length > 12 && m.isInt(character[12]))
if(character.length > 12 && Misc.isInt(character[12]))
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
if(character.length > 13 && m.isInt(character[13]))
if(character.length > 13 && Misc.isInt(character[13]))
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
if(character.length > 14 && m.isInt(character[14]))
if(character.length > 14 && Misc.isInt(character[14]))
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
if(character.length > 15 && m.isInt(character[15]))
if(character.length > 15 && Misc.isInt(character[15]))
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
if(character.length > 16 && m.isInt(character[16]))
if(character.length > 16 && Misc.isInt(character[16]))
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
if(character.length > 17 && m.isInt(character[17]))
if(character.length > 17 && Misc.isInt(character[17]))
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
if(character.length > 18 && m.isInt(character[18]))
if(character.length > 18 && Misc.isInt(character[18]))
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
if(character.length > 19 && m.isInt(character[19]))
if(character.length > 19 && Misc.isInt(character[19]))
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
if(character.length > 20 && m.isInt(character[20]))
if(character.length > 20 && Misc.isInt(character[20]))
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
if(character.length > 21 && m.isInt(character[21]))
if(character.length > 21 && Misc.isInt(character[21]))
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
if(character.length > 22 && m.isInt(character[22]))
if(character.length > 22 && Misc.isInt(character[22]))
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
if(character.length > 24 && m.isInt(character[24]))
if(character.length > 24 && Misc.isInt(character[24]))
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
if(character.length > 25 && m.isInt(character[25]))
if(character.length > 25 && Misc.isInt(character[25]))
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
if(character.length > 26)
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
@ -297,13 +296,13 @@ public class PlayerProfile {
public void save() {
Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds
// if we are using mysql save to database
// if we are using mysql save to database
if (Config.getInstance().getUseMySQL()) {
mcMMO.database.write("UPDATE "+tablePrefix+"huds SET "
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET "
+" hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+tablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.write("UPDATE "+tablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.write("UPDATE "+tablePrefix+"cooldowns SET "
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"cooldowns SET "
+" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
@ -313,7 +312,7 @@ public class PlayerProfile {
+", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+tablePrefix+"skills SET "
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"skills SET "
+" taming = "+skills.get(SkillType.TAMING)
+", mining = "+skills.get(SkillType.MINING)
+", repair = "+skills.get(SkillType.REPAIR)
@ -327,7 +326,7 @@ public class PlayerProfile {
+", acrobatics = "+skills.get(SkillType.ACROBATICS)
+", fishing = "+skills.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+tablePrefix+"experience SET "
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"experience SET "
+" taming = "+skillsXp.get(SkillType.TAMING)
+", mining = "+skillsXp.get(SkillType.MINING)
+", repair = "+skillsXp.get(SkillType.REPAIR)
@ -1175,7 +1174,7 @@ public class PlayerProfile {
String memberName = x.getName();
if (!memberName.equals(playerName) && Party.getInstance().isPartyLeader(memberName, getParty())) {
if (m.isNear(player.getLocation(), x.getLocation(), 25.0)) {
if (Misc.isNear(player.getLocation(), x.getLocation(), 25.0)) {
PlayerProfile PartyLeader = Users.getProfile(x);
int leaderSkill = PartyLeader.getSkillLevel(skillType);
int playerSkill = getSkillLevel(skillType);

View File

@ -2,9 +2,9 @@ package com.gmail.nossr50.datatypes;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public enum SkillType {
ACROBATICS(Config.getInstance().getLevelCapAcrobatics(), Config.getInstance().getFormulaMultiplierAcrobatics()),
@ -75,40 +75,40 @@ public enum SkillType {
public boolean getPermissions(Player player) {
switch (this) {
case ACROBATICS:
return mcPermissions.getInstance().acrobatics(player);
return Permissions.getInstance().acrobatics(player);
case ARCHERY:
return mcPermissions.getInstance().archery(player);
return Permissions.getInstance().archery(player);
case AXES:
return mcPermissions.getInstance().axes(player);
return Permissions.getInstance().axes(player);
case EXCAVATION:
return mcPermissions.getInstance().excavation(player);
return Permissions.getInstance().excavation(player);
case FISHING:
return mcPermissions.getInstance().fishing(player);
return Permissions.getInstance().fishing(player);
case HERBALISM:
return mcPermissions.getInstance().herbalism(player);
return Permissions.getInstance().herbalism(player);
case MINING:
return mcPermissions.getInstance().mining(player);
return Permissions.getInstance().mining(player);
case REPAIR:
return mcPermissions.getInstance().repair(player);
return Permissions.getInstance().repair(player);
case SWORDS:
return mcPermissions.getInstance().swords(player);
return Permissions.getInstance().swords(player);
case TAMING:
return mcPermissions.getInstance().taming(player);
return Permissions.getInstance().taming(player);
case UNARMED:
return mcPermissions.getInstance().unarmed(player);
return Permissions.getInstance().unarmed(player);
case WOODCUTTING:
return mcPermissions.getInstance().woodcutting(player);
return Permissions.getInstance().woodcutting(player);
default:
return false;

View File

@ -3,16 +3,16 @@ package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemChecks;
public enum ToolType {
AXE(mcLocale.getString("Axes.Ability.Lower"), mcLocale.getString("Axes.Ability.Ready")),
FISTS(mcLocale.getString("Unarmed.Ability.Lower"), mcLocale.getString("Unarmed.Ability.Ready")),
HOE(mcLocale.getString("Herbalism.Ability.Lower"), mcLocale.getString("Herbalism.Ability.Ready")),
PICKAXE(mcLocale.getString("Mining.Ability.Lower"), mcLocale.getString("Mining.Ability.Ready")),
SHOVEL(mcLocale.getString("Excavation.Ability.Lower"), mcLocale.getString("Excavation.Ability.Ready")),
SWORD(mcLocale.getString("Swords.Ability.Lower"), mcLocale.getString("Swords.Ability.Ready"));
AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")),
FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")),
HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")),
PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")),
SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")),
SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready"));
private String lowerTool;
private String raiseTool;

View File

@ -2,11 +2,7 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
@ -19,6 +15,10 @@ import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.WoodCutting;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
@ -145,7 +145,7 @@ public class BlockListener implements Listener {
*/
/* Green Terra */
if (PP.getToolPreparationMode(ToolType.HOE) && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
@ -154,7 +154,7 @@ public class BlockListener implements Listener {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
if (mcPermissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
if (Permissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
@ -162,7 +162,7 @@ public class BlockListener implements Listener {
* MINING
*/
if (mcPermissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (Permissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
Mining.miningBlockCheck(player, block);
}
@ -175,7 +175,7 @@ public class BlockListener implements Listener {
* WOOD CUTTING
*/
if (mcPermissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
WoodCutting.woodcuttingBlockCheck(player, block);
}
@ -184,7 +184,7 @@ public class BlockListener implements Listener {
}
}
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && mcPermissions.getInstance().treeFeller(player)) {
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player)) {
WoodCutting.treeFeller(event);
}
@ -192,7 +192,7 @@ public class BlockListener implements Listener {
* EXCAVATION
*/
if (Excavation.canBeGigaDrillBroken(mat) && mcPermissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
if (Excavation.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
}
@ -229,7 +229,7 @@ public class BlockListener implements Listener {
if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
}
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
@ -251,7 +251,7 @@ public class BlockListener implements Listener {
/*
* ABILITY TRIGGER CHECKS
*/
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
Herbalism.greenTerra(player, block);
}
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {

View File

@ -22,23 +22,23 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.mcBleedTimer;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class EntityListener implements Listener {
private final mcMMO plugin;
@ -76,7 +76,7 @@ public class EntityListener implements Listener {
if (defender instanceof LivingEntity) {
LivingEntity livingDefender = (LivingEntity)defender;
if (!m.isInvincible(livingDefender, event)) {
if (!Misc.isInvincible(livingDefender, event)) {
Combat.combatChecks(event, plugin);
}
}
@ -109,11 +109,11 @@ public class EntityListener implements Listener {
return;
}
if (!m.isInvincible(player, event)) {
if (cause == DamageCause.FALL && mcPermissions.getInstance().acrobatics(player)) {
if (!Misc.isInvincible(player, event)) {
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player)) {
Acrobatics.acrobaticsCheck(player, event);
}
else if (cause == DamageCause.BLOCK_EXPLOSION && mcPermissions.getInstance().demolitionsExpertise(player)) {
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
BlastMining.demolitionsExpertise(player, event);
}
@ -126,7 +126,7 @@ public class EntityListener implements Listener {
case WOLF:
Wolf wolf = (Wolf) entity;
if ((!m.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
if ((!Misc.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
Taming.preventDamage(event);
}
break;
@ -147,7 +147,7 @@ public class EntityListener implements Listener {
x.setFireTicks(0);
/* Remove bleed track */
mcBleedTimer.remove(x);
BleedTimer.remove(x);
Archery.arrowRetrievalCheck(x, plugin);
@ -185,7 +185,7 @@ public class EntityListener implements Listener {
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (mcPermissions.getInstance().biggerBombs(player)) {
if (Permissions.getInstance().biggerBombs(player)) {
BlastMining.biggerBombs(player, event);
}
}
@ -292,7 +292,7 @@ public class EntityListener implements Listener {
public void onEntityTame(EntityTameEvent event) {
Player player = (Player) event.getOwner();
if (mcPermissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
PlayerProfile PP = Users.getProfile(player);
EntityType type = event.getEntityType();
int xp = 0;

View File

@ -24,13 +24,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Item;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
@ -40,7 +34,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Fishing;
@ -48,6 +42,12 @@ import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Item;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class PlayerListener implements Listener {
private final mcMMO plugin;
@ -67,16 +67,16 @@ public class PlayerListener implements Listener {
PlayerProfile PP = Users.getProfile(player);
if (PP.getGodMode()) {
if (!mcPermissions.getInstance().mcgod(player)) {
if (!Permissions.getInstance().mcgod(player)) {
PP.toggleGodMode();
player.sendMessage(mcLocale.getString("Commands.GodMode.Forbidden"));
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
}
}
if (PP.inParty()) {
if (!mcPermissions.getInstance().party(player)) {
if (!Permissions.getInstance().party(player)) {
PP.removeParty();
player.sendMessage(mcLocale.getString("Party.Forbidden"));
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
}
}
@ -90,7 +90,7 @@ public class PlayerListener implements Listener {
public void onPlayerFish(PlayerFishEvent event) {
Player player = event.getPlayer();
if (mcPermissions.getInstance().fishing(player)) {
if (Permissions.getInstance().fishing(player)) {
State state = event.getState();
switch (state) {
@ -99,7 +99,7 @@ public class PlayerListener implements Listener {
break;
case CAUGHT_ENTITY:
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && mcPermissions.getInstance().shakeMob(player)) {
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && Permissions.getInstance().shakeMob(player)) {
Fishing.shakeMob(event);
}
break;
@ -155,7 +155,7 @@ public class PlayerListener implements Listener {
}
//Schedule PlayerProfile removal 2 minutes after quitting
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
}
/**
@ -167,14 +167,14 @@ public class PlayerListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (mcPermissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
player.sendMessage(mcLocale.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
player.sendMessage(mcLocale.getString("mcMMO.Wiki"));
if (Permissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
player.sendMessage(LocaleLoader.getString("mcMMO.Wiki"));
}
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
if (XprateCommand.xpevent) {
player.sendMessage(mcLocale.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
}
}
@ -204,7 +204,7 @@ public class PlayerListener implements Listener {
case RIGHT_CLICK_BLOCK:
/* REPAIR CHECKS */
if (mcPermissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId() && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId() && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
@ -225,7 +225,7 @@ public class PlayerListener implements Listener {
}
/* GREEN THUMB CHECK */
if (mcPermissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
if (Permissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
Herbalism.greenThumbBlocks(is, player, block);
}
@ -235,7 +235,7 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
if (mcPermissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
if (Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.remoteDetonation(player, plugin);
}
@ -258,7 +258,7 @@ public class PlayerListener implements Listener {
Item.itemchecks(player);
/* BLAST MINING CHECK */
if (mcPermissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
if (Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
BlastMining.remoteDetonation(player, plugin);
}
@ -268,7 +268,7 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && mcPermissions.getInstance().taming(player)) {
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
if (is.getType().equals(Material.RAW_FISH)) {
Taming.animalSummon(EntityType.OCELOT, player, plugin);
}
@ -334,7 +334,7 @@ public class PlayerListener implements Listener {
event.setMessage(chatEvent.getMessage());
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || mcPermissions.getInstance().adminChat(x)) {
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
intendedRecipients.add(x);
}
}

View File

@ -6,10 +6,10 @@ import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutInputListener implements Listener {
private mcMMO plugin;

View File

@ -6,12 +6,12 @@ import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutListener implements Listener {
//Why do we have this here? We never use it...

View File

@ -6,7 +6,6 @@ import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
@ -16,6 +15,7 @@ import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutScreenListener implements Listener {
//Why do we have this here? We never use it...

View File

@ -1,81 +1,81 @@
package com.gmail.nossr50.locale;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.bukkit.ChatColor;
import com.gmail.nossr50.config.Config;
public class mcLocale {
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
private static ResourceBundle RESOURCE_BUNDLE = null;
public static String getString(String key) {
return getString(key, null);
}
/**
* Gets the appropriate string from the Locale files.
*
* @param key The key to look up the string with
* @param messageArguments Any arguments to be added to the string
* @return The properly formatted locale string
*/
public static String getString(String key, Object[] messageArguments) {
try {
if (RESOURCE_BUNDLE == null) {
package com.gmail.nossr50.locale;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.bukkit.ChatColor;
import com.gmail.nossr50.config.Config;
public class LocaleLoader {
private static final String BUNDLE_NAME = "com.gmail.nossr50.locale.locale";
private static ResourceBundle RESOURCE_BUNDLE = null;
public static String getString(String key) {
return getString(key, null);
}
/**
* Gets the appropriate string from the Locale files.
*
* @param key The key to look up the string with
* @param messageArguments Any arguments to be added to the string
* @return The properly formatted locale string
*/
public static String getString(String key, Object[] messageArguments) {
try {
if (RESOURCE_BUNDLE == null) {
Locale.setDefault(new Locale("en", "US"));
Locale locale = null;
String[] myLocale = Config.getInstance().getLocale().split("[-_ ]");
if (myLocale.length == 1) {
locale = new Locale(myLocale[0]);
}
else if (myLocale.length >= 2) {
locale = new Locale(myLocale[0], myLocale[1]);
}
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, locale);
}
String output = RESOURCE_BUNDLE.getString(key);
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
}
output = addColors(output);
return output;
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
}
private static String addColors(String input) {
input = input.replaceAll("\\Q[[BLACK]]\\E", ChatColor.BLACK.toString());
input = input.replaceAll("\\Q[[DARK_BLUE]]\\E", ChatColor.DARK_BLUE.toString());
input = input.replaceAll("\\Q[[DARK_GREEN]]\\E", ChatColor.DARK_GREEN.toString());
input = input.replaceAll("\\Q[[DARK_AQUA]]\\E", ChatColor.DARK_AQUA.toString());
input = input.replaceAll("\\Q[[DARK_RED]]\\E", ChatColor.DARK_RED.toString());
input = input.replaceAll("\\Q[[DARK_PURPLE]]\\E", ChatColor.DARK_PURPLE.toString());
input = input.replaceAll("\\Q[[GOLD]]\\E", ChatColor.GOLD.toString());
input = input.replaceAll("\\Q[[GRAY]]\\E", ChatColor.GRAY.toString());
input = input.replaceAll("\\Q[[DARK_GRAY]]\\E", ChatColor.DARK_GRAY.toString());
input = input.replaceAll("\\Q[[BLUE]]\\E", ChatColor.BLUE.toString());
input = input.replaceAll("\\Q[[GREEN]]\\E", ChatColor.GREEN.toString());
input = input.replaceAll("\\Q[[AQUA]]\\E", ChatColor.AQUA.toString());
input = input.replaceAll("\\Q[[RED]]\\E", ChatColor.RED.toString());
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
return input;
}
}
Locale locale = null;
String[] myLocale = Config.getInstance().getLocale().split("[-_ ]");
if (myLocale.length == 1) {
locale = new Locale(myLocale[0]);
}
else if (myLocale.length >= 2) {
locale = new Locale(myLocale[0], myLocale[1]);
}
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, locale);
}
String output = RESOURCE_BUNDLE.getString(key);
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
}
output = addColors(output);
return output;
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
}
private static String addColors(String input) {
input = input.replaceAll("\\Q[[BLACK]]\\E", ChatColor.BLACK.toString());
input = input.replaceAll("\\Q[[DARK_BLUE]]\\E", ChatColor.DARK_BLUE.toString());
input = input.replaceAll("\\Q[[DARK_GREEN]]\\E", ChatColor.DARK_GREEN.toString());
input = input.replaceAll("\\Q[[DARK_AQUA]]\\E", ChatColor.DARK_AQUA.toString());
input = input.replaceAll("\\Q[[DARK_RED]]\\E", ChatColor.DARK_RED.toString());
input = input.replaceAll("\\Q[[DARK_PURPLE]]\\E", ChatColor.DARK_PURPLE.toString());
input = input.replaceAll("\\Q[[GOLD]]\\E", ChatColor.GOLD.toString());
input = input.replaceAll("\\Q[[GRAY]]\\E", ChatColor.GRAY.toString());
input = input.replaceAll("\\Q[[DARK_GRAY]]\\E", ChatColor.DARK_GRAY.toString());
input = input.replaceAll("\\Q[[BLUE]]\\E", ChatColor.BLUE.toString());
input = input.replaceAll("\\Q[[GREEN]]\\E", ChatColor.GREEN.toString());
input = input.replaceAll("\\Q[[AQUA]]\\E", ChatColor.AQUA.toString());
input = input.replaceAll("\\Q[[RED]]\\E", ChatColor.RED.toString());
input = input.replaceAll("\\Q[[LIGHT_PURPLE]]\\E", ChatColor.LIGHT_PURPLE.toString());
input = input.replaceAll("\\Q[[YELLOW]]\\E", ChatColor.YELLOW.toString());
input = input.replaceAll("\\Q[[WHITE]]\\E", ChatColor.WHITE.toString());
return input;
}
}

View File

@ -8,10 +8,14 @@ import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import java.io.File;
import java.io.IOException;
@ -106,11 +110,11 @@ public class mcMMO extends JavaPlugin {
//Schedule Spout Activation 1 second after start-up
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
//Periodic save timer (Saves every 10 minutes)
scheduler.scheduleSyncRepeatingTask(this, new mcSaveTimer(this), 0, Config.getInstance().getSaveInterval() * 1200);
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, Config.getInstance().getSaveInterval() * 1200);
//Regen & Cooldown timer (Runs every second)
scheduler.scheduleSyncRepeatingTask(this, new mcTimer(this), 0, 20);
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
//Bleed timer (Runs every two seconds)
scheduler.scheduleSyncRepeatingTask(this, new mcBleedTimer(this), 0, 40);
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(this), 0, 40);
registerCommands();
@ -183,18 +187,18 @@ public class mcMMO extends JavaPlugin {
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
//Skills commands
aliasMap.put(mcLocale.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
aliasMap.put(mcLocale.getString("Archery.SkillName").toLowerCase(), "archery");
aliasMap.put(mcLocale.getString("Axes.SkillName").toLowerCase(), "axes");
aliasMap.put(mcLocale.getString("Excavation.SkillName").toLowerCase(), "excavation");
aliasMap.put(mcLocale.getString("Fishing.SkillName").toLowerCase(), "fishing");
aliasMap.put(mcLocale.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
aliasMap.put(mcLocale.getString("Mining.SkillName").toLowerCase(), "mining");
aliasMap.put(mcLocale.getString("Repair.SkillName").toLowerCase(), "repair");
aliasMap.put(mcLocale.getString("Swords.SkillName").toLowerCase(), "swords");
aliasMap.put(mcLocale.getString("Taming.SkillName").toLowerCase(), "taming");
aliasMap.put(mcLocale.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
aliasMap.put(mcLocale.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
aliasMap.put(LocaleLoader.getString("Archery.SkillName").toLowerCase(), "archery");
aliasMap.put(LocaleLoader.getString("Axes.SkillName").toLowerCase(), "axes");
aliasMap.put(LocaleLoader.getString("Excavation.SkillName").toLowerCase(), "excavation");
aliasMap.put(LocaleLoader.getString("Fishing.SkillName").toLowerCase(), "fishing");
aliasMap.put(LocaleLoader.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
aliasMap.put(LocaleLoader.getString("Mining.SkillName").toLowerCase(), "mining");
aliasMap.put(LocaleLoader.getString("Repair.SkillName").toLowerCase(), "repair");
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
aliasMap.put(LocaleLoader.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
//Register commands
//Skills commands

View File

@ -16,10 +16,10 @@ import java.util.Map;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class Party {
public static String pluginPath;
@ -92,7 +92,7 @@ public class Party {
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName}));
p.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", new Object[] {playerName}));
}
}
}
@ -226,7 +226,7 @@ public class Party {
if (player != null) {
for (Player p : getOnlineMembers(player)) {
if (p.getName() != playerName) {
p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName}));
p.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", new Object[] {playerName}));
}
}
}
@ -323,10 +323,10 @@ public class Party {
informPartyMembers(player);
if (!invite) {
player.sendMessage(mcLocale.getString("Commands.Party.Join", new Object[]{ newParty }));
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", new Object[]{ newParty }));
}
else {
player.sendMessage(mcLocale.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() }));
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() }));
}
}

View File

@ -5,13 +5,13 @@ import java.util.HashSet;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Users;
public class mcBleedTimer implements Runnable {
public class BleedTimer implements Runnable {
private final mcMMO plugin;
private static HashSet<LivingEntity> bleedList = new HashSet<LivingEntity>();
@ -20,7 +20,7 @@ public class mcBleedTimer implements Runnable {
private static boolean lock = false;
public mcBleedTimer(final mcMMO plugin) {
public BleedTimer(final mcMMO plugin) {
this.plugin = plugin;
}
@ -54,7 +54,7 @@ public class mcBleedTimer implements Runnable {
PP.decreaseBleedTicks();
if (PP.getBleedTicks() == 0) {
player.sendMessage(mcLocale.getString("Swords.Combat.Bleeding.Stopped"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
}
}
}

View File

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

View File

@ -3,9 +3,9 @@ package com.gmail.nossr50.runnables;
import java.io.BufferedReader;
import java.io.FileReader;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Misc;
public class SQLConversionTask implements Runnable {
private final mcMMO plugin;
@ -179,34 +179,34 @@ public class SQLConversionTask implements Runnable {
mcMMO.database.write("UPDATE "
+ tablePrefix
+ "skills SET "
+ " taming = taming+" + m.getInt(taming)
+ ", mining = mining+" + m.getInt(mining)
+ ", repair = repair+" + m.getInt(repair)
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
+ ", unarmed = unarmed+" + m.getInt(unarmed)
+ ", herbalism = herbalism+" + m.getInt(herbalism)
+ ", excavation = excavation+" + m.getInt(excavation)
+ ", archery = archery+" + m.getInt(archery)
+ ", swords = swords+" + m.getInt(swords)
+ ", axes = axes+" + m.getInt(axes)
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
+ ", fishing = fishing+" + m.getInt(fishing)
+ " taming = taming+" + Misc.getInt(taming)
+ ", mining = mining+" + Misc.getInt(mining)
+ ", repair = repair+" + Misc.getInt(repair)
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
+ ", excavation = excavation+" + Misc.getInt(excavation)
+ ", archery = archery+" + Misc.getInt(archery)
+ ", swords = swords+" + Misc.getInt(swords)
+ ", axes = axes+" + Misc.getInt(axes)
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
+ ", fishing = fishing+" + Misc.getInt(fishing)
+ " WHERE user_id = " + id);
mcMMO.database.write("UPDATE "
+ tablePrefix
+ "experience SET "
+ " taming = " + m.getInt(tamingXP)
+ ", mining = " + m.getInt(miningXP)
+ ", repair = " + m.getInt(repairXP)
+ ", woodcutting = " + m.getInt(woodCuttingXP)
+ ", unarmed = " + m.getInt(unarmedXP)
+ ", herbalism = " + m.getInt(herbalismXP)
+ ", excavation = " + m.getInt(excavationXP)
+ ", archery = " + m.getInt(archeryXP)
+ ", swords = " + m.getInt(swordsXP)
+ ", axes = " + m.getInt(axesXP)
+ ", acrobatics = " + m.getInt(acrobaticsXP)
+ ", fishing = " + m.getInt(fishingXP)
+ " taming = " + Misc.getInt(tamingXP)
+ ", mining = " + Misc.getInt(miningXP)
+ ", repair = " + Misc.getInt(repairXP)
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
+ ", unarmed = " + Misc.getInt(unarmedXP)
+ ", herbalism = " + Misc.getInt(herbalismXP)
+ ", excavation = " + Misc.getInt(excavationXP)
+ ", archery = " + Misc.getInt(archeryXP)
+ ", swords = " + Misc.getInt(swordsXP)
+ ", axes = " + Misc.getInt(axesXP)
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
+ ", fishing = " + Misc.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
else {
@ -241,34 +241,34 @@ public class SQLConversionTask implements Runnable {
mcMMO.database.write("UPDATE "
+ tablePrefix
+ "skills SET "
+ " taming = taming+" + m.getInt(taming)
+ ", mining = mining+" + m.getInt(mining)
+ ", repair = repair+" + m.getInt(repair)
+ ", woodcutting = woodcutting+" + m.getInt(woodcutting)
+ ", unarmed = unarmed+" + m.getInt(unarmed)
+ ", herbalism = herbalism+" + m.getInt(herbalism)
+ ", excavation = excavation+" + m.getInt(excavation)
+ ", archery = archery+" + m.getInt(archery)
+ ", swords = swords+" + m.getInt(swords)
+ ", axes = axes+" + m.getInt(axes)
+ ", acrobatics = acrobatics+" + m.getInt(acrobatics)
+ ", fishing = fishing+" + m.getInt(fishing)
+ " taming = taming+" + Misc.getInt(taming)
+ ", mining = mining+" + Misc.getInt(mining)
+ ", repair = repair+" + Misc.getInt(repair)
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
+ ", excavation = excavation+" + Misc.getInt(excavation)
+ ", archery = archery+" + Misc.getInt(archery)
+ ", swords = swords+" + Misc.getInt(swords)
+ ", axes = axes+" + Misc.getInt(axes)
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
+ ", fishing = fishing+" + Misc.getInt(fishing)
+ " WHERE user_id = " + id);
mcMMO.database.write("UPDATE "
+ tablePrefix
+ "experience SET "
+ " taming = " + m.getInt(tamingXP)
+ ", mining = " + m.getInt(miningXP)
+ ", repair = " + m.getInt(repairXP)
+ ", woodcutting = " + m.getInt(woodCuttingXP)
+ ", unarmed = " + m.getInt(unarmedXP)
+ ", herbalism = " + m.getInt(herbalismXP)
+ ", excavation = " + m.getInt(excavationXP)
+ ", archery = " + m.getInt(archeryXP)
+ ", swords = " + m.getInt(swordsXP)
+ ", axes = " + m.getInt(axesXP)
+ ", acrobatics = " + m.getInt(acrobaticsXP)
+ ", fishing = " + m.getInt(fishingXP)
+ " taming = " + Misc.getInt(tamingXP)
+ ", mining = " + Misc.getInt(miningXP)
+ ", repair = " + Misc.getInt(repairXP)
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
+ ", unarmed = " + Misc.getInt(unarmedXP)
+ ", herbalism = " + Misc.getInt(herbalismXP)
+ ", excavation = " + Misc.getInt(excavationXP)
+ ", archery = " + Misc.getInt(archeryXP)
+ ", swords = " + Misc.getInt(swordsXP)
+ ", axes = " + Misc.getInt(axesXP)
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
+ ", fishing = " + Misc.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
}

View File

@ -2,10 +2,10 @@ package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Database;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Users;
public class SQLReconnect implements Runnable {
private final mcMMO plugin;

View File

@ -2,13 +2,13 @@ package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Users;
public class mcSaveTimer implements Runnable {
public class SaveTimer implements Runnable {
private final mcMMO plugin;
public mcSaveTimer(final mcMMO plugin) {
public SaveTimer(final mcMMO plugin) {
this.plugin = plugin;
}

View File

@ -1,53 +1,46 @@
package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
public class mcTimer implements Runnable {
private final mcMMO plugin;
public mcTimer(final mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
long curTime = System.currentTimeMillis();
for (Player player : plugin.getServer().getOnlinePlayers()) {
if (player == null) { //Is this even possible?
continue;
}
PlayerProfile PP = Users.getProfile(player);
if (PP == null) { //Is this even possible?
continue;
}
/*
* MONITOR SKILLS
*/
for (SkillType skill : SkillType.values()) {
if (skill.getTool() != null && skill.getAbility() != null) {
Skills.monitorSkill(player, PP, curTime, skill);
}
}
/*
* COOLDOWN MONITORING
*/
for (AbilityType ability : AbilityType.values()) {
if (ability.getCooldown() > 0 ) {
Skills.watchCooldown(player, PP, curTime, ability);
}
}
}
}
}
package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Users;
public class SkillMonitor implements Runnable {
private final mcMMO plugin;
public SkillMonitor(final mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
long curTime = System.currentTimeMillis();
for (Player player : plugin.getServer().getOnlinePlayers()) {
PlayerProfile PP = Users.getProfile(player);
/*
* MONITOR SKILLS
*/
for (SkillType skill : SkillType.values()) {
if (skill.getTool() != null && skill.getAbility() != null) {
Skills.monitorSkill(player, PP, curTime, skill);
}
}
/*
* COOLDOWN MONITORING
*/
for (AbilityType ability : AbilityType.values()) {
if (ability.getCooldown() > 0 ) {
Skills.watchCooldown(player, PP, curTime, ability);
}
}
}
}
}

View File

@ -6,13 +6,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Acrobatics {
@ -35,7 +35,7 @@ public class Acrobatics {
int damage = event.getDamage();
int health = player.getHealth();
if (!mcPermissions.getInstance().gracefulRoll(player)) {
if (!Permissions.getInstance().gracefulRoll(player)) {
gracefulRoll = false;
}
@ -43,7 +43,7 @@ public class Acrobatics {
acrovar = acrovar * 2;
}
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && mcPermissions.getInstance().roll(player)) {
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && Permissions.getInstance().roll(player)) {
int threshold = 7;
if (gracefulRoll) {
@ -68,10 +68,10 @@ public class Acrobatics {
}
if (gracefulRoll) {
player.sendMessage(mcLocale.getString("Acrobatics.Ability.Proc"));
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
else {
player.sendMessage(mcLocale.getString("Acrobatics.Roll.Text"));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
}
}
}
@ -103,12 +103,12 @@ public class Acrobatics {
}
}
if (mcPermissions.getInstance().acrobatics(defender)) {
if (Permissions.getInstance().acrobatics(defender)) {
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(4000) <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
defender.sendMessage(mcLocale.getString("Acrobatics.Combat.Proc"));
if (random.nextInt(4000) <= skillCheck && Permissions.getInstance().dodge(defender)) {
defender.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER);

View File

@ -8,14 +8,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Archery {
@ -52,7 +52,7 @@ public class Archery {
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
Location loc = defender.getLocation();
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(10) > 5) {
loc.setPitch(90);
@ -61,11 +61,11 @@ public class Archery {
loc.setPitch(-90);
}
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().daze(attacker)) {
defender.teleport(loc);
Combat.dealDamage(defender, 4);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}
@ -77,7 +77,7 @@ public class Archery {
*/
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
if (plugin.arrowTracker.containsKey(entity)) {
m.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
Misc.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
}
plugin.arrowTracker.remove(entity);

View File

@ -11,12 +11,12 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class Axes {
@ -72,7 +72,7 @@ public class Axes {
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck && !entity.isDead()){
int damage = event.getDamage();
@ -80,12 +80,12 @@ public class Axes {
if (entity instanceof Player){
event.setDamage((int) (damage * PVP_MODIFIER));
Player player = (Player) entity;
player.sendMessage(mcLocale.getString("Axes.Combat.CritStruck"));
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
}
else {
event.setDamage(damage * PVE_MODIFIER);
}
attacker.sendMessage(mcLocale.getString("Axes.Combat.CriticalHit"));
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
}
}
@ -138,7 +138,7 @@ public class Axes {
if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) {
event.setDamage(event.getDamage() + 2);
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
attacker.sendMessage(mcLocale.getString("Axes.Combat.GI.Proc"));
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
}

View File

@ -15,14 +15,14 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import com.gmail.nossr50.BlockChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class BlastMining {
@ -256,24 +256,24 @@ public class BlastMining {
Block block = player.getTargetBlock(transparent, BLOCKS_AWAY);
if (block.getType().equals(Material.TNT) && m.blockBreakSimulate(block, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) {
if (block.getType().equals(Material.TNT) && Misc.blockBreakSimulate(block, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) {
final double MAX_DISTANCE_AWAY = 10.0;
AbilityType ability = AbilityType.BLAST_MINING;
/* Check Cooldown */
if(!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
/* Send message to nearby players */
for(Player y : player.getWorld().getPlayers()) {
if(y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
if(y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayer(player));
}
}
player.sendMessage(mcLocale.getString("Mining.Blast.Boom"));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
/* Create the TNT entity */
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);

View File

@ -11,10 +11,10 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile;
@ -68,7 +68,7 @@ public class Excavation {
int xp = Config.getInstance().getExcavationBaseXP();
if (mcPermissions.getInstance().excavationTreasures(player)) {
if (Permissions.getInstance().excavationTreasures(player)) {
switch (type) {
case DIRT:
treasures = LoadTreasures.excavationFromDirt;
@ -114,7 +114,7 @@ public class Excavation {
//Drop items
for (ItemStack x : is) {
if (x != null) {
m.mcDropItem(loc, x);
Misc.mcDropItem(loc, x);
}
}
}

View File

@ -17,16 +17,16 @@ import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Wool;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.LoadTreasures;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class Fishing {
@ -136,7 +136,7 @@ public class Fishing {
boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack();
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
for (Enchantment newEnchant : Enchantment.values()) {
@ -166,7 +166,7 @@ public class Fishing {
}
if (enchanted) {
player.sendMessage(mcLocale.getString("Fishing.MagicFound"));
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
}
}
@ -185,91 +185,91 @@ public class Fishing {
switch (type) {
case BLAZE:
m.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD));
Misc.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD));
break;
case CAVE_SPIDER:
if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
}
else {
m.mcDropItem(loc, new ItemStack(Material.STRING));
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
}
break;
case CHICKEN:
if (DROP_NUMBER > 66) {
m.mcDropItem(loc, new ItemStack(Material.FEATHER));
Misc.mcDropItem(loc, new ItemStack(Material.FEATHER));
}
else if (DROP_NUMBER > 33) {
m.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN));
Misc.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN));
}
else {
m.mcDropItem(loc, new ItemStack(Material.EGG));
Misc.mcDropItem(loc, new ItemStack(Material.EGG));
}
break;
case COW:
if (DROP_NUMBER > 99) {
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
}
else if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.LEATHER));
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
}
else {
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
}
break;
case CREEPER:
m.mcDropItem(loc, new ItemStack(Material.SULPHUR));
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
break;
case ENDERMAN:
m.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL));
Misc.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL));
break;
case GHAST:
if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SULPHUR));
Misc.mcDropItem(loc, new ItemStack(Material.SULPHUR));
}
else {
m.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR));
Misc.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR));
}
break;
case MAGMA_CUBE:
m.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM));
Misc.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM));
break;
case MUSHROOM_COW:
if (DROP_NUMBER > 99) {
m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
Misc.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
}
else if (DROP_NUMBER > 98) {
m.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
Misc.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
}
else if (DROP_NUMBER > 66) {
m.mcDropItem(loc, new ItemStack(Material.LEATHER));
Misc.mcDropItem(loc, new ItemStack(Material.LEATHER));
}
else if (DROP_NUMBER > 33) {
m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
Misc.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
}
else {
m.mcDropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
Misc.mcDropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
}
break;
case PIG:
m.mcDropItem(loc, new ItemStack(Material.PORK));
Misc.mcDropItem(loc, new ItemStack(Material.PORK));
break;
case PIG_ZOMBIE:
if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
}
else {
m.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET));
Misc.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET));
}
break;
@ -283,48 +283,48 @@ public class Fishing {
ItemStack theWool = wool.toItemStack();
theWool.setAmount(1 + random.nextInt(6));
m.mcDropItem(loc, theWool);
Misc.mcDropItem(loc, theWool);
sheep.setSheared(true);
}
break;
case SKELETON:
if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.BONE));
Misc.mcDropItem(loc, new ItemStack(Material.BONE));
}
else {
m.mcDropItems(loc, new ItemStack(Material.ARROW), 3);
Misc.mcDropItems(loc, new ItemStack(Material.ARROW), 3);
}
break;
case SLIME:
m.mcDropItem(loc, new ItemStack(Material.SLIME_BALL));
Misc.mcDropItem(loc, new ItemStack(Material.SLIME_BALL));
break;
case SNOWMAN:
if (DROP_NUMBER > 99) {
m.mcDropItem(loc, new ItemStack(Material.PUMPKIN));
Misc.mcDropItem(loc, new ItemStack(Material.PUMPKIN));
}
else {
m.mcDropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
Misc.mcDropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
}
break;
case SPIDER:
if (DROP_NUMBER > 50) {
m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
Misc.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
}
else {
m.mcDropItem(loc, new ItemStack(Material.STRING));
Misc.mcDropItem(loc, new ItemStack(Material.STRING));
}
break;
case SQUID:
m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
Misc.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
break;
case ZOMBIE:
m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
Misc.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
break;
default:

View File

@ -11,16 +11,16 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.GreenThumbTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Herbalism {
@ -44,7 +44,7 @@ public class Herbalism {
inventory.removeItem(new ItemStack(Material.SEEDS));
player.updateInventory();
if (m.blockBreakSimulate(block, player, false)) {
if (Misc.blockBreakSimulate(block, player, false)) {
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type.equals(Material.SMOOTH_BRICK)) {
block.setData((byte) 0x1); //Set type of the brick to mossy
}
@ -156,7 +156,7 @@ public class Herbalism {
mat = Material.WHEAT;
xp = Config.getInstance().getHerbalismXPWheat();
if (Config.getInstance().getHerbalismWheatRegrowth() && mcPermissions.getInstance().greenThumbWheat(player)) {
if (Config.getInstance().getHerbalismWheatRegrowth() && Permissions.getInstance().greenThumbWheat(player)) {
greenThumbWheat(block, player, event, plugin);
}
}
@ -227,26 +227,26 @@ public class Herbalism {
if (mat == null) {
return;
} else if (mcPermissions.getInstance().herbalismDoubleDrops(player)) {
} else if (Permissions.getInstance().herbalismDoubleDrops(player)) {
ItemStack is = new ItemStack(mat);
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
if (type.equals(Material.CACTUS)) {
m.mcDropItems(loc, is, catciDrops);
Misc.mcDropItems(loc, is, catciDrops);
}
else if (type.equals(Material.MELON_BLOCK)) {
m.mcDropItems(loc, is, 3);
m.mcRandomDropItems(loc, is, 50, 4);
Misc.mcDropItems(loc, is, 3);
Misc.mcRandomDropItems(loc, is, 50, 4);
}
else if (type.equals(Material.NETHER_WARTS)) {
m.mcDropItems(loc, is, 2);
m.mcRandomDropItems(loc, is, 50, 3);
Misc.mcDropItems(loc, is, 2);
Misc.mcRandomDropItems(loc, is, 50, 3);
}
else if (type.equals(Material.SUGAR_CANE_BLOCK)) {
m.mcDropItems(loc, is, caneDrops);
Misc.mcDropItems(loc, is, caneDrops);
}
else {
m.mcDropItem(loc, is);
Misc.mcDropItem(loc, is);
}
}
}
@ -275,8 +275,8 @@ public class Herbalism {
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
event.setCancelled(true);
m.mcDropItem(loc, new ItemStack(Material.WHEAT));
m.mcRandomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
Misc.mcDropItem(loc, new ItemStack(Material.WHEAT));
Misc.mcRandomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
@ -305,7 +305,7 @@ public class Herbalism {
greenTerra(player, block);
}
else {
player.sendMessage(mcLocale.getString("mcPlayerListener.GreenThumbFail"));
player.sendMessage(LocaleLoader.getString("mcPlayerListener.GreenThumbFail"));
}
}
}

View File

@ -11,11 +11,11 @@ import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.sound.SoundEffect;
import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@ -38,40 +38,40 @@ public class Mining {
switch (type) {
case COAL_ORE:
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
m.mcDropItem(loc, item);
Misc.mcDropItem(loc, item);
break;
case DIAMOND_ORE:
item = new ItemStack(Material.DIAMOND);
m.mcDropItem(loc, item);
Misc.mcDropItem(loc, item);
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
item = new ItemStack(Material.REDSTONE);
m.mcDropItems(loc, item, 4);
m.mcRandomDropItem(loc, item, 50);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItem(loc, item, 50);
break;
case GLOWSTONE:
item = new ItemStack(Material.GLOWSTONE_DUST);
m.mcDropItems(loc, item, 2);
m.mcRandomDropItems(loc, item, 50, 2);
Misc.mcDropItems(loc, item, 2);
Misc.mcRandomDropItems(loc, item, 50, 2);
break;
case LAPIS_ORE:
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
m.mcDropItems(loc, item, 4);
m.mcRandomDropItems(loc, item, 50, 4);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItems(loc, item, 50, 4);
break;
case STONE:
item = new ItemStack(Material.COBBLESTONE);
m.mcDropItem(loc, item);
Misc.mcDropItem(loc, item);
break;
default:
m.mcDropItem(loc, item);
Misc.mcDropItem(loc, item);
break;
}
}
@ -167,9 +167,9 @@ public class Mining {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().miningDoubleDrops(player)) {
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
m.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
Misc.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
}
else {
miningDrops(block);
@ -215,7 +215,7 @@ public class Mining {
*/
public static void SuperBreakerBlockCheck(Player player, Block block) {
Material type = block.getType();
int tier = m.getTier(player.getItemInHand());
int tier = Misc.getTier(player.getItemInHand());
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);

View File

@ -14,17 +14,17 @@ import org.bukkit.inventory.PlayerInventory;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
public class Repair {
@ -47,20 +47,20 @@ public class Repair {
/*
* REPAIR ARMOR
*/
if (ItemChecks.isArmor(is) && Config.getInstance().getRepairArmorAllowed() && mcPermissions.getInstance().armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && mcPermissions.getInstance().diamondRepair(player)) {
if (ItemChecks.isArmor(is) && Config.getInstance().getRepairArmorAllowed() && Permissions.getInstance().armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 6, true);
}
else if (ItemChecks.isIronArmor(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && mcPermissions.getInstance().ironRepair(player)) {
else if (ItemChecks.isIronArmor(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, true);
}
else if (ItemChecks.isGoldArmor(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && mcPermissions.getInstance().goldRepair(player)) {
else if (ItemChecks.isGoldArmor(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 4, true);
}
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(Config.getInstance().getRepairLeatherMaterial()) && mcPermissions.getInstance().leatherRepair(player)) {
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(Config.getInstance().getRepairLeatherMaterial()) && Permissions.getInstance().leatherRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairLeatherMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
@ -72,28 +72,28 @@ public class Repair {
/*
* REPAIR TOOLS
*/
else if (ItemChecks.isTool(is) && Config.getInstance().getRepairToolsAllowed() && mcPermissions.getInstance().toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(Config.getInstance().getRepairStoneMaterial()) && skillLevel >= Config.getInstance().getRepairStoneLevelRequirement() && mcPermissions.getInstance().stoneRepair(player)) {
else if (ItemChecks.isTool(is) && Config.getInstance().getRepairToolsAllowed() && Permissions.getInstance().toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(Config.getInstance().getRepairStoneMaterial()) && skillLevel >= Config.getInstance().getRepairStoneLevelRequirement() && Permissions.getInstance().stoneRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStoneMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isWoodTool(is) && inventory.contains(Config.getInstance().getRepairWoodMaterial()) && mcPermissions.getInstance().woodRepair(player)) {
else if (ItemChecks.isWoodTool(is) && inventory.contains(Config.getInstance().getRepairWoodMaterial()) && Permissions.getInstance().woodRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairWoodMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isIronTool(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && mcPermissions.getInstance().ironRepair(player)) {
else if (ItemChecks.isIronTool(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isDiamondTool(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && mcPermissions.getInstance().diamondRepair(player)) {
else if (ItemChecks.isDiamondTool(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isGoldTool(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && mcPermissions.getInstance().goldRepair(player)) {
else if (ItemChecks.isGoldTool(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 8, true);
}
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && skillLevel >= Config.getInstance().getRepairStringLevelRequirement() && mcPermissions.getInstance().stringRepair(player)){
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && skillLevel >= Config.getInstance().getRepairStringLevelRequirement() && Permissions.getInstance().stringRepair(player)){
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStringMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
@ -103,7 +103,7 @@ public class Repair {
}
}
else {
player.sendMessage(mcLocale.getString("Repair.Skills.FullDurability"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
}
}
@ -188,11 +188,11 @@ public class Repair {
int rank = getArcaneForgingRank(Users.getProfile(player));
if (rank == 0 || !mcPermissions.getInstance().arcaneForging(player)) {
if (rank == 0 || !Permissions.getInstance().arcaneForging(player)) {
for (Enchantment x : enchants.keySet()) {
is.removeEnchantment(x);
}
player.sendMessage(mcLocale.getString("Repair.Arcane.Lost"));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
return;
}
@ -219,13 +219,13 @@ public class Repair {
Map<Enchantment, Integer> newEnchants = is.getEnchantments();
if (newEnchants.isEmpty()) {
player.sendMessage(mcLocale.getString("Repair.Arcane.Fail"));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
}
else if (downgraded || newEnchants.size() < enchants.size()) {
player.sendMessage(mcLocale.getString("Repair.Arcane.Downgrade"));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
}
else {
player.sendMessage(mcLocale.getString("Repair.Arcane.Perfect"));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
}
}
@ -352,49 +352,49 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if (is.getAmount() != 1) {
player.sendMessage(mcLocale.getString("Repair.Skills.StackedItems"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
}
else {
if (ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is)) {
if (skillLevel < Config.getInstance().getRepairDiamondLevelRequirement()) {
player.sendMessage(mcLocale.getString("Repair.Skills.AdeptDiamond"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptDiamond"));
}
else {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.BLUE + m.prettyItemString(Config.getInstance().getRepairDiamondMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.BLUE + Misc.prettyItemString(Config.getInstance().getRepairDiamondMaterial()));
}
}
else if (ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is)) {
if (skillLevel < Config.getInstance().getRepairIronLevelRequirement()) {
player.sendMessage(mcLocale.getString("Repair.Skills.AdeptIron"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptIron"));
}
else {
player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(Config.getInstance().getRepairIronMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairIronMaterial()));
}
}
else if (ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is)) {
if (skillLevel < Config.getInstance().getRepairGoldLevelRequirement()) {
player.sendMessage(mcLocale.getString("Repair.Skills.AdeptGold"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptGold"));
}
else {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.GOLD + m.prettyItemString(Config.getInstance().getRepairGoldMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GOLD + Misc.prettyItemString(Config.getInstance().getRepairGoldMaterial()));
}
}
else if (ItemChecks.isStoneTool(is)) {
if (skillLevel < Config.getInstance().getRepairStoneLevelRequirement()) {
player.sendMessage(mcLocale.getString("Repair.Skills.AdeptStone"));
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptStone"));
}
else {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.GRAY + m.prettyItemString(Config.getInstance().getRepairStoneMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairStoneMaterial()));
}
}
else if (ItemChecks.isWoodTool(is)) {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + m.prettyItemString(Config.getInstance().getRepairWoodMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + Misc.prettyItemString(Config.getInstance().getRepairWoodMaterial()));
}
else if (ItemChecks.isLeatherArmor(is)) {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + m.prettyItemString(Config.getInstance().getRepairLeatherMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairLeatherMaterial()));
}
else if (ItemChecks.isStringTool(is)) {
player.sendMessage(mcLocale.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + m.prettyItemString(Config.getInstance().getRepairStringMaterial()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairStringMaterial()));
}
}
}
@ -410,8 +410,8 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().repairBonus(player)) {
player.sendMessage(mcLocale.getString("Repair.Skills.FeltEasy"));
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().repairBonus(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
return true;
}
@ -445,7 +445,7 @@ public class Repair {
}
/* Handle the enchants */
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !mcPermissions.getInstance().arcaneBypass(player)) {
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) {
addEnchants(player, item);
}
@ -470,7 +470,7 @@ public class Repair {
}
}
else {
player.sendMessage(mcLocale.getString("Repair.Listener.Anvil"));
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
}
PP.togglePlacedAnvil();

View File

@ -9,20 +9,20 @@ import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Leaderboard;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
public class Skills {
@ -106,7 +106,7 @@ public class Skills {
if (ability.getPermissions(player) && tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
}
@ -146,7 +146,7 @@ public class Skills {
player.sendMessage(ability.getAbilityOff());
for (Player y : player.getWorld().getPlayers()) {
if (y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayerOff(player));
}
}
@ -188,7 +188,7 @@ public class Skills {
if (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
while (PP.getSkillXpLevel(skillType) >= PP.getXpToLevel(skillType)) {
if ((skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) && (m.getPowerLevelCap() >= PP.getPowerLevel() + 1)) {
if ((skillType.getMaxLevel() >= PP.getSkillLevel(skillType) + 1) && (Misc.getPowerLevelCap() >= PP.getPowerLevel() + 1)) {
PP.removeXP(skillType, PP.getXpToLevel(skillType));
skillups++;
PP.skillUp(skillType, 1);
@ -206,7 +206,7 @@ public class Skills {
ProcessLeaderboardUpdate(SkillType.ALL, player);
}
String capitalized = m.getCapitalized(skillType.toString());
String capitalized = Misc.getCapitalized(skillType.toString());
/* Spout Stuff */
if (Config.getInstance().spoutEnabled && player instanceof SpoutPlayer) {
@ -225,11 +225,11 @@ public class Skills {
}
}
else {
player.sendMessage(mcLocale.getString(capitalized + ".Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
}
else {
player.sendMessage(mcLocale.getString(capitalized + ".Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", new Object[] {String.valueOf(skillups), PP.getSkillLevel(skillType)}));
}
}
@ -296,11 +296,11 @@ public class Skills {
* @return true if the player has combat skills, false otherwise
*/
public static boolean hasCombatSkills(Player player) {
if (mcPermissions.getInstance().axes(player)
|| mcPermissions.getInstance().archery(player)
|| mcPermissions.getInstance().swords(player)
|| mcPermissions.getInstance().taming(player)
|| mcPermissions.getInstance().unarmed(player)) {
if (Permissions.getInstance().axes(player)
|| Permissions.getInstance().archery(player)
|| Permissions.getInstance().swords(player)
|| Permissions.getInstance().taming(player)
|| Permissions.getInstance().unarmed(player)) {
return true;
}
else {
@ -315,11 +315,11 @@ public class Skills {
* @return true if the player has gathering skills, false otherwise
*/
public static boolean hasGatheringSkills(Player player) {
if (mcPermissions.getInstance().excavation(player)
|| mcPermissions.getInstance().fishing(player)
|| mcPermissions.getInstance().herbalism(player)
|| mcPermissions.getInstance().mining(player)
|| mcPermissions.getInstance().woodcutting(player)) {
if (Permissions.getInstance().excavation(player)
|| Permissions.getInstance().fishing(player)
|| Permissions.getInstance().herbalism(player)
|| Permissions.getInstance().mining(player)
|| Permissions.getInstance().woodcutting(player)) {
return true;
}
else {
@ -334,7 +334,7 @@ public class Skills {
* @return true if the player has misc skills, false otherwise
*/
public static boolean hasMiscSkills(Player player) {
if (mcPermissions.getInstance().acrobatics(player) || mcPermissions.getInstance().repair(player)) {
if (Permissions.getInstance().acrobatics(player) || Permissions.getInstance().repair(player)) {
return true;
}
else {
@ -377,7 +377,7 @@ public class Skills {
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
return;
}
}
@ -388,7 +388,7 @@ public class Skills {
player.sendMessage(ability.getAbilityOn());
for (Player y : player.getWorld().getPlayers()) {
if (y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayer(player));
}
}
@ -420,7 +420,7 @@ public class Skills {
case GIGA_DRILL_BREAKER:
case SUPER_BREAKER:
case LEAF_BLOWER:
if (!m.blockBreakSimulate(block, player, true)) {
if (!Misc.blockBreakSimulate(block, player, true)) {
activate = false;
break;
}

View File

@ -9,17 +9,17 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.mcBleedTimer;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Swords {
@ -54,7 +54,7 @@ public class Swords {
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
if (entity instanceof Player) {
@ -71,9 +71,9 @@ public class Swords {
Users.getProfile(target).addBleedTicks(bleedTicks);
}
else {
mcBleedTimer.add(entity);
BleedTimer.add(entity);
}
attacker.sendMessage(mcLocale.getString("Swords.Combat.Bleeding"));
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
}
@ -95,19 +95,19 @@ public class Swords {
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (ItemChecks.isSword(defender.getItemInHand()) && mcPermissions.getInstance().counterAttack(defender)) {
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
final int MAX_BONUS_LEVEL = 600;
final int COUNTER_ATTACK_MODIFIER = 2;
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck) {
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
defender.sendMessage(mcLocale.getString("Swords.Combat.Countered"));
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(mcLocale.getString("Swords.Combat.Counter.Hit"));
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}

View File

@ -18,15 +18,15 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.runnables.mcBleedTimer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Taming {
@ -94,14 +94,14 @@ public class Taming {
if (entity instanceof Player) {
Player target = (Player) entity;
target.sendMessage(mcLocale.getString("Combat.StruckByGore"));
target.sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
Users.getProfile(target).addBleedTicks(2);
}
else {
mcBleedTimer.add((LivingEntity) entity);
BleedTimer.add((LivingEntity) entity);
}
master.sendMessage(mcLocale.getString("Combat.Gore"));
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
}
}
@ -147,20 +147,20 @@ public class Taming {
case CONTACT:
case LAVA:
case FIRE:
if (mcPermissions.getInstance().environmentallyAware(master)) {
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
if (event.getDamage() >= wolf.getHealth()) {
return;
}
wolf.teleport(master.getLocation());
master.sendMessage(mcLocale.getString("Taming.Listener.Wolf"));
master.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
}
}
break;
case FALL:
if (mcPermissions.getInstance().environmentallyAware(master)) {
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
event.setCancelled(true);
}
@ -169,7 +169,7 @@ public class Taming {
/* Thick Fur */
case FIRE_TICK:
if (mcPermissions.getInstance().thickFur(master)) {
if (Permissions.getInstance().thickFur(master)) {
if(skillLevel >= THICK_FUR_LEVEL) {
wolf.setFireTicks(0);
}
@ -178,7 +178,7 @@ public class Taming {
case ENTITY_ATTACK:
case PROJECTILE:
if (mcPermissions.getInstance().thickFur(master)) {
if (Permissions.getInstance().thickFur(master)) {
if (skillLevel >= THICK_FUR_LEVEL) {
event.setDamage(event.getDamage() / THICK_FUR_MODIFIER);
}
@ -188,7 +188,7 @@ public class Taming {
/* Shock Proof */
case ENTITY_EXPLOSION:
case BLOCK_EXPLOSION:
if (mcPermissions.getInstance().shockProof(master)) {
if (Permissions.getInstance().shockProof(master)) {
if (skillLevel >= SHOCK_PROOF_LEVEL) {
event.setDamage(event.getDamage() / SHOCK_PROOF_MODIFIER);
}
@ -232,11 +232,11 @@ public class Taming {
if (x.getType().equals(type)) {
switch (type) {
case WOLF:
player.sendMessage(mcLocale.getString("Taming.Summon.Fail.Wolf"));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
return;
case OCELOT:
player.sendMessage(mcLocale.getString("Taming.Summon.Fail.Ocelot"));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
return;
default:
@ -258,10 +258,10 @@ public class Taming {
}
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
player.sendMessage(mcLocale.getString("Taming.Summon.Complete"));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
else {
player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(summonItem.getId()));
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(summonItem.getId()));
}
}
}
@ -276,15 +276,15 @@ public class Taming {
public static void beastLore(EntityDamageByEntityEvent event, LivingEntity target, Player inspector) {
if (target instanceof Tameable) {
Tameable beast = (Tameable) target;
String message = mcLocale.getString("Combat.BeastLore") + " ";
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
int health = target.getHealth();
event.setCancelled(true);
if (beast.isTamed()) {
message = message.concat(mcLocale.getString("Combat.BeastLoreOwner", new Object[] {getOwnerName(beast)}) + " ");
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", new Object[] {getOwnerName(beast)}) + " ");
}
message = message.concat(mcLocale.getString("Combat.BeastLoreHealth", new Object[] {health, target.getMaxHealth()}));
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", new Object[] {health, target.getMaxHealth()}));
inspector.sendMessage(message);
}
}

View File

@ -8,12 +8,12 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Unarmed {
@ -49,15 +49,15 @@ public class Unarmed {
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
ItemStack inHand = defender.getItemInHand();
if (!inHand.getType().equals(Material.AIR)) {
if (random.nextInt(3000) <= skillCheck && ironGrip(defender, attacker)) {
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
m.mcDropItem(defender.getLocation(), inHand);
Misc.mcDropItem(defender.getLocation(), inHand);
defender.setItemInHand(new ItemStack(Material.AIR));
}
}
@ -73,11 +73,11 @@ public class Unarmed {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().deflect(defender)) {
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().deflect(defender)) {
event.setCancelled(true);
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect"));
defender.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
}
}
@ -86,7 +86,7 @@ public class Unarmed {
PlayerProfile PPd = Users.getProfile(defender);
int skillLevel = PPd.getSkillLevel(SkillType.UNARMED);
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck) {
defender.sendMessage(ChatColor.GREEN + "Your iron grip kept you from being disarmed!"); //TODO: Use locale

View File

@ -11,17 +11,17 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import org.bukkit.event.block.BlockBreakEvent;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import org.getspout.spoutapi.sound.SoundEffect;
@ -54,7 +54,7 @@ public class WoodCutting {
*/
private static void removeBlocks(ArrayList<Block> toBeFelled, Player player, PlayerProfile PP) {
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
player.sendMessage(mcLocale.getString("Woodcutting.Skills.TreeFellerThreshold"));
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
return;
}
@ -67,7 +67,7 @@ public class WoodCutting {
/* This is to prevent using wood axes everytime you tree fell */
if ((inHand.getDurability() + durabilityLoss >= inHand.getType().getMaxDurability()) || inHand.getType().equals(Material.AIR)) {
player.sendMessage(mcLocale.getString("Woodcutting.Skills.TreeFeller.Splinter"));
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
int health = player.getHealth();
@ -85,7 +85,7 @@ public class WoodCutting {
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData());
for (Block x : toBeFelled) {
if (m.blockBreakSimulate(x, player, true)) {
if (Misc.blockBreakSimulate(x, player, true)) {
if (x.getType() == Material.LOG) {
Tree tree = (Tree) x.getState().getData();
TreeSpecies species = tree.getSpecies();
@ -141,13 +141,13 @@ public class WoodCutting {
x.setType(Material.AIR);
/* Drop the block */
m.mcDropItem(x.getLocation(), item);
Misc.mcDropItem(x.getLocation(), item);
}
else if (x.getType() == Material.LEAVES) {
final int SAPLING_DROP_CHANCE = 10;
item = new ItemStack(Material.SAPLING, 1, (short) 0, (byte) (x.getData() & 3)); //Drop the right type of sapling
m.mcRandomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
Misc.mcRandomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE);
//Remove the block
x.setData((byte) 0);
@ -258,9 +258,9 @@ public class WoodCutting {
byte type = block.getData();
Material mat = Material.getMaterial(block.getTypeId());
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().woodcuttingDoubleDrops(player)) {
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
m.mcDropItem(block.getLocation(), item);
Misc.mcDropItem(block.getLocation(), item);
}
}

View File

@ -20,8 +20,6 @@ import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.keyboard.Keyboard;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
@ -30,6 +28,8 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.listeners.SpoutInputListener;
import com.gmail.nossr50.listeners.SpoutListener;
import com.gmail.nossr50.listeners.SpoutScreenListener;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class SpoutStuff {
private static mcMMO plugin = mcMMO.p;
@ -118,8 +118,8 @@ public class SpoutStuff {
continue;
}
String standardFileName = m.getCapitalized(y.toString())+".png";
String retroFileName = m.getCapitalized(y.toString())+"_r.png";
String standardFileName = Misc.getCapitalized(y.toString())+".png";
String retroFileName = Misc.getCapitalized(y.toString())+"_r.png";
writeFile(standardFileName, hudStandardDirectory);
writeFile(retroFileName, hudRetroDirectory);
@ -179,8 +179,8 @@ public class SpoutStuff {
continue;
}
files.add(new File(hudStandardDirectory + m.getCapitalized(y.toString()) + ".png"));
files.add(new File(hudRetroDirectory + m.getCapitalized(y.toString()) + "_r.png"));
files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png"));
files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png"));
}
/* Blank icons */
@ -544,7 +544,7 @@ public class SpoutStuff {
}
//TODO: Use Locale
sPlayer.sendNotification(ChatColor.GREEN + "Level Up!", ChatColor.YELLOW + m.getCapitalized(skillType.toString()) + ChatColor.DARK_AQUA + " (" + ChatColor.GREEN + PP.getSkillLevel(skillType) + ChatColor.DARK_AQUA + ")", mat);
sPlayer.sendNotification(ChatColor.GREEN + "Level Up!", ChatColor.YELLOW + Misc.getCapitalized(skillType.toString()) + ChatColor.DARK_AQUA + " (" + ChatColor.GREEN + PP.getSkillLevel(skillType) + ChatColor.DARK_AQUA + ")", mat);
SpoutSounds.playLevelUpNoise(sPlayer, plugin);
}

View File

@ -1,119 +1,119 @@
package com.gmail.nossr50;
import org.bukkit.Material;
import com.gmail.nossr50.config.Config;
public class BlockChecks {
/**
* Checks to see if a block type awards XP.
*
* @param material The type of Block to check
* @return true if the block type awards XP, false otherwise
*/
public static boolean shouldBeWatched(Material material) {
switch (material) {
case BROWN_MUSHROOM:
case CACTUS:
case CLAY:
case COAL_ORE:
case DIAMOND_ORE:
case DIRT:
case ENDER_STONE:
case GLOWING_REDSTONE_ORE:
case GLOWSTONE:
case GOLD_ORE:
case GRASS:
case GRAVEL:
case IRON_ORE:
case JACK_O_LANTERN:
case LAPIS_ORE:
case LOG:
case MELON_BLOCK:
case MOSSY_COBBLESTONE:
case MYCEL:
case NETHERRACK:
case OBSIDIAN:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
case REDSTONE_ORE:
case SAND:
case SANDSTONE:
case SOUL_SAND:
case STONE:
case SUGAR_CANE_BLOCK:
case VINE:
case WATER_LILY:
case YELLOW_FLOWER:
return true;
default:
return false;
}
}
/**
* Check if a block should allow for the activation of abilities.
*
* @param material The type of Block to check
* @return true if the block should allow ability activation, false otherwise
*/
public static boolean abilityBlockCheck(Material material) {
switch (material) {
case BED_BLOCK:
case BREWING_STAND:
case BOOKSHELF:
case BURNING_FURNACE:
case CAKE_BLOCK:
case CHEST:
case DISPENSER:
case ENCHANTMENT_TABLE:
case FENCE_GATE:
case FURNACE:
case IRON_DOOR_BLOCK:
case JUKEBOX:
case LEVER:
case NOTE_BLOCK:
case STONE_BUTTON:
case TRAP_DOOR:
case WALL_SIGN:
case WOODEN_DOOR:
case WORKBENCH:
return false;
default:
break;
}
if (Material.getMaterial(Config.getInstance().getRepairAnvilId()).equals(material)) {
return false;
}
else {
return true;
}
}
/**
* Check if a block type is an ore.
*
* @param material The type of Block to check
* @return true if the Block is an ore, false otherwise
*/
public static boolean isOre(Material material) {
switch (material) {
case COAL_ORE:
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
return true;
default:
return false;
}
}
}
package com.gmail.nossr50.util;
import org.bukkit.Material;
import com.gmail.nossr50.config.Config;
public class BlockChecks {
/**
* Checks to see if a block type awards XP.
*
* @param material The type of Block to check
* @return true if the block type awards XP, false otherwise
*/
public static boolean shouldBeWatched(Material material) {
switch (material) {
case BROWN_MUSHROOM:
case CACTUS:
case CLAY:
case COAL_ORE:
case DIAMOND_ORE:
case DIRT:
case ENDER_STONE:
case GLOWING_REDSTONE_ORE:
case GLOWSTONE:
case GOLD_ORE:
case GRASS:
case GRAVEL:
case IRON_ORE:
case JACK_O_LANTERN:
case LAPIS_ORE:
case LOG:
case MELON_BLOCK:
case MOSSY_COBBLESTONE:
case MYCEL:
case NETHERRACK:
case OBSIDIAN:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
case REDSTONE_ORE:
case SAND:
case SANDSTONE:
case SOUL_SAND:
case STONE:
case SUGAR_CANE_BLOCK:
case VINE:
case WATER_LILY:
case YELLOW_FLOWER:
return true;
default:
return false;
}
}
/**
* Check if a block should allow for the activation of abilities.
*
* @param material The type of Block to check
* @return true if the block should allow ability activation, false otherwise
*/
public static boolean abilityBlockCheck(Material material) {
switch (material) {
case BED_BLOCK:
case BREWING_STAND:
case BOOKSHELF:
case BURNING_FURNACE:
case CAKE_BLOCK:
case CHEST:
case DISPENSER:
case ENCHANTMENT_TABLE:
case FENCE_GATE:
case FURNACE:
case IRON_DOOR_BLOCK:
case JUKEBOX:
case LEVER:
case NOTE_BLOCK:
case STONE_BUTTON:
case TRAP_DOOR:
case WALL_SIGN:
case WOODEN_DOOR:
case WORKBENCH:
return false;
default:
break;
}
if (Material.getMaterial(Config.getInstance().getRepairAnvilId()).equals(material)) {
return false;
}
else {
return true;
}
}
/**
* Check if a block type is an ore.
*
* @param material The type of Block to check
* @return true if the Block is an ore, false otherwise
*/
public static boolean isOre(Material material) {
switch (material) {
case COAL_ORE:
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
return true;
default:
return false;
}
}
}

View File

@ -1,486 +1,487 @@
package com.gmail.nossr50;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.GainXp;
import com.gmail.nossr50.runnables.mcBleedTimer;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.Axes;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Swords;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.skills.Unarmed;
public class Combat {
/**
* Apply combat modifiers and process and XP gain.
*
* @param event The event to run the combat checks on.
* @param plugin mcMMO plugin instance
*/
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO plugin) {
if (event.getDamage() == 0 || event.getEntity().isDead()) {
return;
}
Entity damager = event.getDamager();
LivingEntity target = (LivingEntity) event.getEntity();
EntityType damagerType = damager.getType();
EntityType targetType = target.getType();
switch (damagerType) {
case PLAYER:
Player attacker = (Player) event.getDamager();
ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
combatAbilityChecks(attacker);
if (ItemChecks.isSword(itemInHand) && mcPermissions.getInstance().swords(attacker)) {
if (!mcBleedTimer.contains(target) && mcPermissions.getInstance().swordsBleed(attacker)) {
Swords.bleedCheck(attacker, target, plugin);
}
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && mcPermissions.getInstance().serratedStrikes(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
}
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
}
else if (ItemChecks.isAxe(itemInHand) && mcPermissions.getInstance().axes(attacker)) {
if (mcPermissions.getInstance().axeBonus(attacker)) {
Axes.axesBonus(attacker, event);
}
if (mcPermissions.getInstance().criticalHit(attacker)) {
Axes.axeCriticalCheck(attacker, event);
}
if (mcPermissions.getInstance().impact(attacker)) {
Axes.impact(attacker, target, event);
}
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && mcPermissions.getInstance().skullSplitter(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
}
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
}
else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) {
if (mcPermissions.getInstance().unarmedBonus(attacker)) {
Unarmed.unarmedBonus(PPa, event);
}
if (PPa.getAbilityMode(AbilityType.BERSERK) && mcPermissions.getInstance().berserk(attacker)) {
event.setDamage((int) (event.getDamage() * 1.5));
}
if (targetType.equals(EntityType.PLAYER) && mcPermissions.getInstance().disarm(attacker)) {
Unarmed.disarmProcCheck(attacker, (Player) target);
}
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
}
else if (itemInHand.getType().equals(Material.BONE) && mcPermissions.getInstance().beastLore(attacker)) {
Taming.beastLore(event, target, attacker);
}
break;
case WOLF:
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
Player master = (Player) wolf.getOwner();
PlayerProfile PPo = Users.getProfile(master);
if (mcPermissions.getInstance().taming(master)) {
if (mcPermissions.getInstance().fastFoodService(master)) {
Taming.fastFoodService(PPo, wolf, event);
}
if (mcPermissions.getInstance().sharpenedclaws(master)) {
Taming.sharpenedClaws(PPo, event);
}
if (mcPermissions.getInstance().gore(master)) {
Taming.gore(PPo, event, master, plugin);
}
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
}
}
break;
case ARROW:
archeryCheck((EntityDamageByEntityEvent) event, plugin);
break;
default:
break;
}
if (targetType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
}
}
/**
* Process combat abilities based on weapon preparation modes.
*
* @param attacker The player attacking
*/
public static void combatAbilityChecks(Player attacker) {
PlayerProfile PPa = Users.getProfile(attacker);
if (PPa.getToolPreparationMode(ToolType.AXE)) {
Skills.abilityCheck(attacker, SkillType.AXES);
}
else if (PPa.getToolPreparationMode(ToolType.SWORD)) {
Skills.abilityCheck(attacker, SkillType.SWORDS);
}
else if (PPa.getToolPreparationMode(ToolType.FISTS)) {
Skills.abilityCheck(attacker, SkillType.UNARMED);
}
}
/**
* Process archery abilities.
*
* @param event The event to run the archery checks on.
* @param pluginx mcMMO plugin instance
*/
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
Arrow arrow = (Arrow) event.getDamager();
LivingEntity shooter = arrow.getShooter();
LivingEntity target = (LivingEntity) event.getEntity();
if (target instanceof Player) {
Player defender = (Player) target;
if (mcPermissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) {
Unarmed.deflectCheck(defender, event);
}
}
if (shooter instanceof Player) {
Player attacker = (Player) shooter;
PlayerProfile PPa = Users.getProfile(attacker);
int damage = event.getDamage();
if (mcPermissions.getInstance().archery(attacker) && damage > 0) {
/*Archery needs a damage bonus to be viable in PVP*/
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
/* Cap maximum bonus at 200% */
if(dmgBonusPercent > 2)
dmgBonusPercent = 2;
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */
//TODO: Work in progress for balancing out Archery, will work on it more later...
//TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended?
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
event.setDamage(event.getDamage() + archeryBonus);
if (mcPermissions.getInstance().trackArrows(attacker)) {
Archery.trackArrows(pluginx, target, PPa);
}
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
if (target instanceof Player) {
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
event.setCancelled(true);
return;
}
Archery.dazeCheck(defender, attacker);
}
}
}
}
/**
* Attempt to damage target for value dmg with reason CUSTOM
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
*/
public static void dealDamage(LivingEntity target, int dmg) {
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
}
/**
* Attempt to damage target for value dmg with reason cause
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param cause DamageCause to pass to damage event
*/
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Apply Area-of-Effect ability actions.
*
* @param attacker The attacking player
* @param target The defending entity
* @param damage The initial damage amount
* @param plugin mcMMO plugin instance
* @param type The type of skill being used
*/
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
int numberOfTargets = m.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
int damageAmount = 0;
if (type.equals(SkillType.AXES)) {
damageAmount = damage / 2;
}
else if (type.equals(SkillType.SWORDS)) {
damageAmount = damage / 4;
}
if (damageAmount < 1) {
damageAmount = 1;
}
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
EntityType entityType = entity.getType();
if (entityType.equals(EntityType.WOLF)) {
Wolf wolf = (Wolf) entity;
AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner.equals(attacker) || Party.getInstance().inSameParty(attacker, owner)) {
continue;
}
}
}
if (entity instanceof LivingEntity && numberOfTargets >= 1) {
if (entityType.equals(EntityType.PLAYER)) {
Player defender = (Player) entity;
PlayerProfile PP = Users.getProfile(defender);
//Reasons why the target shouldn't be hit
if (PP.getGodMode()) {
continue;
}
if (defender.getName().equals(attacker.getName())) { //Is this even possible?
continue;
}
if (Party.getInstance().inSameParty(attacker, defender)) {
continue;
}
if (defender.isDead()) {
continue;
}
//Apply effect to players only if PVP is enabled
if (target.getWorld().getPVP()) {
String message = "";
if (type.equals(SkillType.AXES)) {
message = mcLocale.getString("Axes.Combat.Cleave.Struck");
}
else if (type.equals(SkillType.SWORDS)) {
message = mcLocale.getString("Swords.Combat.SS.Struck");
}
dealDamage(defender, damageAmount, attacker);
defender.sendMessage(message);
if (type.equals(SkillType.SWORDS)) {
PP.addBleedTicks(5);
}
numberOfTargets--;
}
}
else {
LivingEntity livingEntity = (LivingEntity) entity;
if (type.equals(SkillType.SWORDS)) {
mcBleedTimer.add(livingEntity);
}
dealDamage(livingEntity, damageAmount, attacker);
numberOfTargets--;
}
}
}
}
/**
* Start the task that gives combat XP.
*
* @param attacker The attacking player
* @param PP The player's PlayerProfile
* @param target The defending entity
* @param skillType The skill being used
* @param plugin mcMMO plugin instance
*/
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) {
double baseXP = 0;
if (target instanceof Player) {
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
return;
}
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
}
}
else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
baseXP = Config.getInstance().getAnimalsXP();
}
else {
EntityType type = target.getType();
switch (type) {
case BLAZE:
baseXP = Config.getInstance().getBlazeXP();
break;
case CAVE_SPIDER:
baseXP = Config.getInstance().getCaveSpiderXP();
break;
case CREEPER:
baseXP = Config.getInstance().getCreeperXP();
break;
case ENDER_DRAGON:
baseXP = Config.getInstance().getEnderDragonXP();
break;
case ENDERMAN:
baseXP = Config.getInstance().getEndermanXP();
break;
case GHAST:
baseXP = Config.getInstance().getGhastXP();
break;
case MAGMA_CUBE:
baseXP = Config.getInstance().getMagmaCubeXP();
break;
case IRON_GOLEM:
if (!((IronGolem) target).isPlayerCreated())
baseXP = Config.getInstance().getIronGolemXP();
break;
case PIG_ZOMBIE:
baseXP = Config.getInstance().getPigZombieXP();
break;
case SILVERFISH:
baseXP = Config.getInstance().getSilverfishXP();
break;
case SKELETON:
baseXP = Config.getInstance().getSkeletonXP();
break;
case SLIME:
baseXP = Config.getInstance().getSlimeXP();
break;
case SPIDER:
baseXP = Config.getInstance().getSpiderXP();
break;
case ZOMBIE:
baseXP = Config.getInstance().getZombieXP();
break;
default:
break;
}
}
baseXP *= 10;
}
if (baseXP != 0) {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
}
}
}
package com.gmail.nossr50.util;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.GainXp;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.Axes;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Swords;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.skills.Unarmed;
public class Combat {
/**
* Apply combat modifiers and process and XP gain.
*
* @param event The event to run the combat checks on.
* @param plugin mcMMO plugin instance
*/
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO plugin) {
if (event.getDamage() == 0 || event.getEntity().isDead()) {
return;
}
Entity damager = event.getDamager();
LivingEntity target = (LivingEntity) event.getEntity();
EntityType damagerType = damager.getType();
EntityType targetType = target.getType();
switch (damagerType) {
case PLAYER:
Player attacker = (Player) event.getDamager();
ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
combatAbilityChecks(attacker);
if (ItemChecks.isSword(itemInHand) && Permissions.getInstance().swords(attacker)) {
if (!BleedTimer.contains(target) && Permissions.getInstance().swordsBleed(attacker)) {
Swords.bleedCheck(attacker, target, plugin);
}
if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES) && Permissions.getInstance().serratedStrikes(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
}
startGainXp(attacker, PPa, target, SkillType.SWORDS, plugin);
}
else if (ItemChecks.isAxe(itemInHand) && Permissions.getInstance().axes(attacker)) {
if (Permissions.getInstance().axeBonus(attacker)) {
Axes.axesBonus(attacker, event);
}
if (Permissions.getInstance().criticalHit(attacker)) {
Axes.axeCriticalCheck(attacker, event);
}
if (Permissions.getInstance().impact(attacker)) {
Axes.impact(attacker, target, event);
}
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && Permissions.getInstance().skullSplitter(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
}
startGainXp(attacker, PPa, target, SkillType.AXES, plugin);
}
else if (itemInHand.getType().equals(Material.AIR) && Permissions.getInstance().unarmed(attacker)) {
if (Permissions.getInstance().unarmedBonus(attacker)) {
Unarmed.unarmedBonus(PPa, event);
}
if (PPa.getAbilityMode(AbilityType.BERSERK) && Permissions.getInstance().berserk(attacker)) {
event.setDamage((int) (event.getDamage() * 1.5));
}
if (targetType.equals(EntityType.PLAYER) && Permissions.getInstance().disarm(attacker)) {
Unarmed.disarmProcCheck(attacker, (Player) target);
}
startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin);
}
else if (itemInHand.getType().equals(Material.BONE) && Permissions.getInstance().beastLore(attacker)) {
Taming.beastLore(event, target, attacker);
}
break;
case WOLF:
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
Player master = (Player) wolf.getOwner();
PlayerProfile PPo = Users.getProfile(master);
if (Permissions.getInstance().taming(master)) {
if (Permissions.getInstance().fastFoodService(master)) {
Taming.fastFoodService(PPo, wolf, event);
}
if (Permissions.getInstance().sharpenedclaws(master)) {
Taming.sharpenedClaws(PPo, event);
}
if (Permissions.getInstance().gore(master)) {
Taming.gore(PPo, event, master, plugin);
}
startGainXp(master, PPo, target, SkillType.TAMING, plugin);
}
}
break;
case ARROW:
archeryCheck((EntityDamageByEntityEvent) event, plugin);
break;
default:
break;
}
if (targetType.equals(EntityType.PLAYER)) {
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
}
}
/**
* Process combat abilities based on weapon preparation modes.
*
* @param attacker The player attacking
*/
public static void combatAbilityChecks(Player attacker) {
PlayerProfile PPa = Users.getProfile(attacker);
if (PPa.getToolPreparationMode(ToolType.AXE)) {
Skills.abilityCheck(attacker, SkillType.AXES);
}
else if (PPa.getToolPreparationMode(ToolType.SWORD)) {
Skills.abilityCheck(attacker, SkillType.SWORDS);
}
else if (PPa.getToolPreparationMode(ToolType.FISTS)) {
Skills.abilityCheck(attacker, SkillType.UNARMED);
}
}
/**
* Process archery abilities.
*
* @param event The event to run the archery checks on.
* @param pluginx mcMMO plugin instance
*/
public static void archeryCheck(EntityDamageByEntityEvent event, mcMMO pluginx) {
Arrow arrow = (Arrow) event.getDamager();
LivingEntity shooter = arrow.getShooter();
LivingEntity target = (LivingEntity) event.getEntity();
if (target instanceof Player) {
Player defender = (Player) target;
if (Permissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) {
Unarmed.deflectCheck(defender, event);
}
}
if (shooter instanceof Player) {
Player attacker = (Player) shooter;
PlayerProfile PPa = Users.getProfile(attacker);
int damage = event.getDamage();
if (Permissions.getInstance().archery(attacker) && damage > 0) {
/*Archery needs a damage bonus to be viable in PVP*/
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
/* Cap maximum bonus at 200% */
if(dmgBonusPercent > 2)
dmgBonusPercent = 2;
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */
//TODO: Work in progress for balancing out Archery, will work on it more later...
//TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended?
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
event.setDamage(event.getDamage() + archeryBonus);
if (Permissions.getInstance().trackArrows(attacker)) {
Archery.trackArrows(pluginx, target, PPa);
}
startGainXp(attacker, PPa, target, SkillType.ARCHERY, pluginx);
if (target instanceof Player) {
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (PPa.inParty() && PPd.inParty() && Party.getInstance().inSameParty(defender, attacker)) {
event.setCancelled(true);
return;
}
Archery.dazeCheck(defender, attacker);
}
}
}
}
/**
* Attempt to damage target for value dmg with reason CUSTOM
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
*/
public static void dealDamage(LivingEntity target, int dmg) {
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
}
/**
* Attempt to damage target for value dmg with reason cause
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param cause DamageCause to pass to damage event
*/
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Apply Area-of-Effect ability actions.
*
* @param attacker The attacking player
* @param target The defending entity
* @param damage The initial damage amount
* @param plugin mcMMO plugin instance
* @param type The type of skill being used
*/
private static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, mcMMO plugin, SkillType type) {
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
int damageAmount = 0;
if (type.equals(SkillType.AXES)) {
damageAmount = damage / 2;
}
else if (type.equals(SkillType.SWORDS)) {
damageAmount = damage / 4;
}
if (damageAmount < 1) {
damageAmount = 1;
}
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
EntityType entityType = entity.getType();
if (entityType.equals(EntityType.WOLF)) {
Wolf wolf = (Wolf) entity;
AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner.equals(attacker) || Party.getInstance().inSameParty(attacker, owner)) {
continue;
}
}
}
if (entity instanceof LivingEntity && numberOfTargets >= 1) {
if (entityType.equals(EntityType.PLAYER)) {
Player defender = (Player) entity;
PlayerProfile PP = Users.getProfile(defender);
//Reasons why the target shouldn't be hit
if (PP.getGodMode()) {
continue;
}
if (defender.getName().equals(attacker.getName())) { //Is this even possible?
continue;
}
if (Party.getInstance().inSameParty(attacker, defender)) {
continue;
}
if (defender.isDead()) {
continue;
}
//Apply effect to players only if PVP is enabled
if (target.getWorld().getPVP()) {
String message = "";
if (type.equals(SkillType.AXES)) {
message = LocaleLoader.getString("Axes.Combat.Cleave.Struck");
}
else if (type.equals(SkillType.SWORDS)) {
message = LocaleLoader.getString("Swords.Combat.SS.Struck");
}
dealDamage(defender, damageAmount, attacker);
defender.sendMessage(message);
if (type.equals(SkillType.SWORDS)) {
PP.addBleedTicks(5);
}
numberOfTargets--;
}
}
else {
LivingEntity livingEntity = (LivingEntity) entity;
if (type.equals(SkillType.SWORDS)) {
BleedTimer.add(livingEntity);
}
dealDamage(livingEntity, damageAmount, attacker);
numberOfTargets--;
}
}
}
}
/**
* Start the task that gives combat XP.
*
* @param attacker The attacking player
* @param PP The player's PlayerProfile
* @param target The defending entity
* @param skillType The skill being used
* @param plugin mcMMO plugin instance
*/
public static void startGainXp(Player attacker, PlayerProfile PP, LivingEntity target, SkillType skillType, mcMMO pluginx) {
double baseXP = 0;
if (target instanceof Player) {
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
return;
}
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (System.currentTimeMillis() >= (PPd.getRespawnATS() * 1000) + 5000 && ((PPd.getLastLogin() + 5) * 1000) < System.currentTimeMillis() && defender.getHealth() >= 1) {
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
}
}
else if (!target.hasMetadata("mcmmoFromMobSpawner")) {
if (target instanceof Animals && !target.hasMetadata("mcmmoSummoned")) {
baseXP = Config.getInstance().getAnimalsXP();
}
else {
EntityType type = target.getType();
switch (type) {
case BLAZE:
baseXP = Config.getInstance().getBlazeXP();
break;
case CAVE_SPIDER:
baseXP = Config.getInstance().getCaveSpiderXP();
break;
case CREEPER:
baseXP = Config.getInstance().getCreeperXP();
break;
case ENDER_DRAGON:
baseXP = Config.getInstance().getEnderDragonXP();
break;
case ENDERMAN:
baseXP = Config.getInstance().getEndermanXP();
break;
case GHAST:
baseXP = Config.getInstance().getGhastXP();
break;
case MAGMA_CUBE:
baseXP = Config.getInstance().getMagmaCubeXP();
break;
case IRON_GOLEM:
if (!((IronGolem) target).isPlayerCreated())
baseXP = Config.getInstance().getIronGolemXP();
break;
case PIG_ZOMBIE:
baseXP = Config.getInstance().getPigZombieXP();
break;
case SILVERFISH:
baseXP = Config.getInstance().getSilverfishXP();
break;
case SKELETON:
baseXP = Config.getInstance().getSkeletonXP();
break;
case SLIME:
baseXP = Config.getInstance().getSlimeXP();
break;
case SPIDER:
baseXP = Config.getInstance().getSpiderXP();
break;
case ZOMBIE:
baseXP = Config.getInstance().getZombieXP();
break;
default:
break;
}
}
baseXP *= 10;
}
if (baseXP != 0) {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
}
}
}

View File

@ -1,294 +1,295 @@
package com.gmail.nossr50;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Properties;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.DatabaseUpdate;
import com.gmail.nossr50.runnables.SQLReconnect;
public class Database {
private static String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName() + "?user=" + Config.getInstance().getMySQLUserName() + "&password=" + Config.getInstance().getMySQLUserPassword();
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
private static Connection conn = null;
private static mcMMO plugin = null;
private static long reconnectTimestamp = 0;
public Database(mcMMO instance) {
plugin = instance;
connect(); //Connect to MySQL
// Load the driver instance
try {
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection(connectionString);
}
catch (ClassNotFoundException e) {
plugin.getLogger().warning(e.getLocalizedMessage());
}
catch (SQLException ex) {
plugin.getLogger().warning(ex.getLocalizedMessage());
printErrors(ex);
}
}
/**
* Attempt to connect to the mySQL database.
*/
public static void connect() {
try {
System.out.println("[mcMMO] Attempting connection to MySQL...");
Properties conProperties = new Properties();
conProperties.put("autoReconnect", "false");
conProperties.put("maxReconnects", "0");
conn = DriverManager.getConnection(connectionString, conProperties);
System.out.println("[mcMMO] Connection to MySQL was a success!");
}
catch (SQLException ex) {
System.out.println("[mcMMO] Connection to MySQL failed!");
ex.printStackTrace();
printErrors(ex);
}
}
/**
* Attempt to create the database structure.
*/
public void createStructure() {
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL,"
+ "`party` varchar(100) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`id`),"
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
checkDatabaseStructure(DatabaseUpdate.FISHING);
checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
}
/**
* Check database structure for missing values.
*
* @param update Type of data to check updates for
*/
public void checkDatabaseStructure(DatabaseUpdate update) {
String sql = null;
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
switch (update) {
case BLAST_MINING:
sql = "SELECT * FROM `"+tablePrefix+"cooldowns` ORDER BY `"+tablePrefix+"cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
break;
case FISHING:
sql = "SELECT * FROM `"+tablePrefix+"experience` ORDER BY `"+tablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30";
break;
default:
break;
}
try {
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
Col.add(rs.getString(i));
}
Rows.put(rs.getRow(), Col);
}
}
}
catch (SQLException ex) {
if (update.equals(DatabaseUpdate.BLAST_MINING)) {
System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
}
else if (update.equals(DatabaseUpdate.FISHING)) {
System.out.println("Updating mcMMO MySQL tables for Fishing...");
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
}
}
}
/**
* Attempt to write the SQL query.
*
* @param sql Query to write.
* @return true if the query was successfully written, false otherwise.
*/
public boolean write(String sql) {
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.executeUpdate();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
}
else {
attemptReconnect();
}
return false;
}
/**
* Get the Integer. Only return first row / first field.
*
* @param sql SQL query to execute
* @return the value in the first row / first field
*/
public Integer getInt(String sql) {
ResultSet rs = null;
Integer result = 0;
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
if (rs.next()) {
result = rs.getInt(1);
}
else {
result = 0;
}
}
}
catch (SQLException ex) {
printErrors(ex);
}
}
else {
attemptReconnect();
}
return result;
}
/**
* Get connection status
*
* @return the boolean value for whether or not we are connected
*/
public static boolean isConnected() {
if(conn == null)
return false;
try {
return conn.isValid(3);
} catch (SQLException e) {
return false;
}
}
/**
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed
* This will check for a connection being present or not to prevent unneeded reconnection attempts
*/
public static void attemptReconnect() {
if(reconnectTimestamp + 60000 < System.currentTimeMillis()) {
System.out.println("[mcMMO] Connection to MySQL was lost! Attempting to reconnect in 60 seconds..."); //Only reconnect if another attempt hasn't been made recently
reconnectTimestamp = System.currentTimeMillis();
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 1200);
}
}
/**
* Read SQL query.
*
* @param sql SQL query to read
* @return the rows in this SQL query
*/
public HashMap<Integer, ArrayList<String>> read(String sql) {
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
Col.add(rs.getString(i));
}
Rows.put(rs.getRow(), Col);
}
}
}
catch (SQLException ex) {
printErrors(ex);
}
}
else {
attemptReconnect();
}
return Rows;
}
private static void printErrors(SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
package com.gmail.nossr50.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Properties;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.DatabaseUpdate;
import com.gmail.nossr50.runnables.SQLReconnect;
public class Database {
private static String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName() + "?user=" + Config.getInstance().getMySQLUserName() + "&password=" + Config.getInstance().getMySQLUserPassword();
private static String tablePrefix = Config.getInstance().getMySQLTablePrefix();
private static Connection conn = null;
private static mcMMO plugin = null;
private static long reconnectTimestamp = 0;
public Database(mcMMO instance) {
plugin = instance;
connect(); //Connect to MySQL
// Load the driver instance
try {
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection(connectionString);
}
catch (ClassNotFoundException e) {
plugin.getLogger().warning(e.getLocalizedMessage());
}
catch (SQLException ex) {
plugin.getLogger().warning(ex.getLocalizedMessage());
printErrors(ex);
}
}
/**
* Attempt to connect to the mySQL database.
*/
public static void connect() {
try {
System.out.println("[mcMMO] Attempting connection to MySQL...");
Properties conProperties = new Properties();
conProperties.put("autoReconnect", "false");
conProperties.put("maxReconnects", "0");
conn = DriverManager.getConnection(connectionString, conProperties);
System.out.println("[mcMMO] Connection to MySQL was a success!");
}
catch (SQLException ex) {
System.out.println("[mcMMO] Connection to MySQL failed!");
ex.printStackTrace();
printErrors(ex);
}
}
/**
* Attempt to create the database structure.
*/
public void createStructure() {
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL,"
+ "`party` varchar(100) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`id`),"
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`repair` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`unarmed` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`herbalism` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`excavation` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`archery` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
checkDatabaseStructure(DatabaseUpdate.FISHING);
checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
}
/**
* Check database structure for missing values.
*
* @param update Type of data to check updates for
*/
public void checkDatabaseStructure(DatabaseUpdate update) {
String sql = null;
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
switch (update) {
case BLAST_MINING:
sql = "SELECT * FROM `"+tablePrefix+"cooldowns` ORDER BY `"+tablePrefix+"cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
break;
case FISHING:
sql = "SELECT * FROM `"+tablePrefix+"experience` ORDER BY `"+tablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30";
break;
default:
break;
}
try {
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
Col.add(rs.getString(i));
}
Rows.put(rs.getRow(), Col);
}
}
}
catch (SQLException ex) {
if (update.equals(DatabaseUpdate.BLAST_MINING)) {
System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
}
else if (update.equals(DatabaseUpdate.FISHING)) {
System.out.println("Updating mcMMO MySQL tables for Fishing...");
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
}
}
}
/**
* Attempt to write the SQL query.
*
* @param sql Query to write.
* @return true if the query was successfully written, false otherwise.
*/
public boolean write(String sql) {
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.executeUpdate();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
}
else {
attemptReconnect();
}
return false;
}
/**
* Get the Integer. Only return first row / first field.
*
* @param sql SQL query to execute
* @return the value in the first row / first field
*/
public Integer getInt(String sql) {
ResultSet rs = null;
Integer result = 0;
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
if (rs.next()) {
result = rs.getInt(1);
}
else {
result = 0;
}
}
}
catch (SQLException ex) {
printErrors(ex);
}
}
else {
attemptReconnect();
}
return result;
}
/**
* Get connection status
*
* @return the boolean value for whether or not we are connected
*/
public static boolean isConnected() {
if(conn == null)
return false;
try {
return conn.isValid(3);
} catch (SQLException e) {
return false;
}
}
/**
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed
* This will check for a connection being present or not to prevent unneeded reconnection attempts
*/
public static void attemptReconnect() {
if(reconnectTimestamp + 60000 < System.currentTimeMillis()) {
System.out.println("[mcMMO] Connection to MySQL was lost! Attempting to reconnect in 60 seconds..."); //Only reconnect if another attempt hasn't been made recently
reconnectTimestamp = System.currentTimeMillis();
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 1200);
}
}
/**
* Read SQL query.
*
* @param sql SQL query to read
* @return the rows in this SQL query
*/
public HashMap<Integer, ArrayList<String>> read(String sql) {
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
if (isConnected()) {
try {
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
Col.add(rs.getString(i));
}
Rows.put(rs.getRow(), Col);
}
}
}
catch (SQLException ex) {
printErrors(ex);
}
}
else {
attemptReconnect();
}
return Rows;
}
private static void printErrors(SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}

View File

@ -1,64 +1,64 @@
package com.gmail.nossr50;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Item {
/**
* Check for item usage.
*
* @param player Player whose item usage to check
*/
public static void itemchecks(Player player) {
ItemStack inhand = player.getItemInHand();
if (Config.getInstance().getChimaeraEnabled() && inhand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
chimaerawing(player);
}
}
private static void chimaerawing(Player player) {
PlayerProfile PP = Users.getProfile(player);
ItemStack is = player.getItemInHand();
Block block = player.getLocation().getBlock();
int amount = is.getAmount();
if (mcPermissions.getInstance().chimaeraWing(player) && is.getTypeId() == Config.getInstance().getChimaeraItemId()) {
if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) {
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
player.sendMessage(mcLocale.getString("Item.ChimaeraWing.Fail"));
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
return;
}
}
if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK)) {
player.teleport(player.getBedSpawnLocation());
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
player.sendMessage(mcLocale.getString("Item.ChimaeraWing.Pass"));
}
else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= Config.getInstance().getChimaeraCost()) {
player.sendMessage(mcLocale.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)}));
}
else if (is.getAmount() <= Config.getInstance().getChimaeraCost()) {
player.sendMessage(mcLocale.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + m.prettyItemString(Config.getInstance().getChimaeraItemId()));
}
}
}
}
package com.gmail.nossr50.util;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Item {
/**
* Check for item usage.
*
* @param player Player whose item usage to check
*/
public static void itemchecks(Player player) {
ItemStack inhand = player.getItemInHand();
if (Config.getInstance().getChimaeraEnabled() && inhand.getTypeId() == Config.getInstance().getChimaeraItemId()) {
chimaerawing(player);
}
}
private static void chimaerawing(Player player) {
PlayerProfile PP = Users.getProfile(player);
ItemStack is = player.getItemInHand();
Block block = player.getLocation().getBlock();
int amount = is.getAmount();
if (Permissions.getInstance().chimaeraWing(player) && is.getTypeId() == Config.getInstance().getChimaeraItemId()) {
if (Skills.cooldownOver(PP.getRecentlyHurt(), 60) && amount >= Config.getInstance().getChimaeraCost()) {
player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost()));
for (int y = 0; block.getY() + y < player.getWorld().getMaxHeight(); y++) {
if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.teleport(block.getRelative(0, y - 1, 0).getLocation());
return;
}
}
if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK)) {
player.teleport(player.getBedSpawnLocation());
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
}
else if (!Skills.cooldownOver(PP.getRecentlyHurt(), 60) && is.getAmount() >= Config.getInstance().getChimaeraCost()) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", new Object[] {Skills.calculateTimeLeft(PP.getRecentlyHurt(), 60)}));
}
else if (is.getAmount() <= Config.getInstance().getChimaeraCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getChimaeraItemId()));
}
}
}
}

View File

@ -1,398 +1,398 @@
package com.gmail.nossr50;
import org.bukkit.inventory.ItemStack;
public class ItemChecks {
/**
* Checks if the item is a sword.
*
* @param is Item to check
* @return true if the item is a sword, false otherwise
*/
public static boolean isSword(ItemStack is) {
switch (is.getType()) {
case DIAMOND_SWORD:
case GOLD_SWORD:
case IRON_SWORD:
case STONE_SWORD:
case WOOD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks if the item is a hoe.
*
* @param is Item to check
* @return true if the item is a hoe, false otherwise
*/
public static boolean isHoe(ItemStack is) {
switch (is.getType()) {
case DIAMOND_HOE:
case GOLD_HOE:
case IRON_HOE:
case STONE_HOE:
case WOOD_HOE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a shovel.
*
* @param is Item to check
* @return true if the item is a shovel, false otherwise
*/
public static boolean isShovel(ItemStack is) {
switch (is.getType()) {
case DIAMOND_SPADE:
case GOLD_SPADE:
case IRON_SPADE:
case STONE_SPADE:
case WOOD_SPADE:
return true;
default:
return false;
}
}
/**
* Checks if the item is an axe.
*
* @param is Item to check
* @return true if the item is an axe, false otherwise
*/
public static boolean isAxe(ItemStack is) {
switch (is.getType()) {
case DIAMOND_AXE:
case GOLD_AXE:
case IRON_AXE:
case STONE_AXE:
case WOOD_AXE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pickaxe.
*
* @param is Item to check
* @return true if the item is a pickaxe, false otherwise
*/
public static boolean isMiningPick(ItemStack is) {
switch (is.getType()) {
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case IRON_PICKAXE:
case STONE_PICKAXE:
case WOOD_PICKAXE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a helmet.
*
* @param is Item to check
* @return true if the item is a helmet, false otherwise
*/
public static boolean isHelmet(ItemStack is) {
switch (is.getType()) {
case DIAMOND_HELMET:
case GOLD_HELMET:
case IRON_HELMET:
case LEATHER_HELMET:
return true;
default:
return false;
}
}
/**
* Checks if the item is a chestplate.
*
* @param is Item to check
* @return true if the item is a chestplate, false otherwise
*/
public static boolean isChestplate(ItemStack is) {
switch (is.getType()) {
case DIAMOND_CHESTPLATE:
case GOLD_CHESTPLATE:
case IRON_CHESTPLATE:
case LEATHER_CHESTPLATE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pair of pants.
*
* @param is Item to check
* @return true if the item is a pair of pants, false otherwise
*/
public static boolean isPants(ItemStack is) {
switch (is.getType()) {
case DIAMOND_LEGGINGS:
case GOLD_LEGGINGS:
case IRON_LEGGINGS:
case LEATHER_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pair of boots.
*
* @param is Item to check
* @return true if the item is a pair of boots, false otherwise
*/
public static boolean isBoots(ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case GOLD_BOOTS:
case IRON_BOOTS:
case LEATHER_BOOTS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a wearable armor piece.
*
* @param is Item to check
* @return true if the item is armor, false otherwise
*/
public static boolean isArmor(ItemStack is) {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
}
/**
* Checks to see if an item is a leather armor piece.
*
* @param is Item to check
* @return true if the item is leather armor, false otherwise
*/
public static boolean isLeatherArmor(ItemStack is) {
switch (is.getType()) {
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_HELMET:
case LEATHER_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a gold armor piece.
*
* @param is Item to check
* @return true if the item is gold armor, false otherwise
*/
public static boolean isGoldArmor(ItemStack is) {
switch (is.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
case GOLD_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is an iron armor piece.
*
* @param is Item to check
* @return true if the item is iron armor, false otherwise
*/
public static boolean isIronArmor(ItemStack is) {
switch (is.getType()) {
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_HELMET:
case IRON_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a diamond armor piece.
*
* @param is Item to check
* @return true if the item is diamond armor, false otherwise
*/
public static boolean isDiamondArmor(ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
case DIAMOND_HELMET:
case DIAMOND_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a tool.
*
* @param is Item to check
* @return true if the item is a tool, false otherwise
*/
public static boolean isTool(ItemStack is) {
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
}
/**
* Checks to see if an item is a stone tool.
*
* @param is Item to check
* @return true if the item is a stone tool, false otherwise
*/
public static boolean isStoneTool(ItemStack is) {
switch (is.getType()) {
case STONE_AXE:
case STONE_HOE:
case STONE_PICKAXE:
case STONE_SPADE:
case STONE_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a wooden tool.
*
* @param is Item to check
* @return true if the item is a wooden tool, false otherwise
*/
public static boolean isWoodTool(ItemStack is) {
switch (is.getType()) {
case WOOD_AXE:
case WOOD_HOE:
case WOOD_PICKAXE:
case WOOD_SPADE:
case WOOD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a string tool.
*
* @param is Item to check
* @return true if the item is a string tool, false otherwise
*/
public static boolean isStringTool(ItemStack is) {
switch (is.getType()) {
case BOW:
case FISHING_ROD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a gold tool.
*
* @param is Item to check
* @return true if the item is a stone tool, false otherwise
*/
public static boolean isGoldTool(ItemStack is) {
switch (is.getType()) {
case GOLD_AXE:
case GOLD_HOE:
case GOLD_PICKAXE:
case GOLD_SPADE:
case GOLD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is an iron tool.
*
* @param is Item to check
* @return true if the item is an iron tool, false otherwise
*/
public static boolean isIronTool(ItemStack is) {
switch (is.getType()) {
case IRON_AXE:
case IRON_HOE:
case IRON_PICKAXE:
case IRON_SPADE:
case IRON_SWORD:
case SHEARS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a diamond tool.
*
* @param is Item to check
* @return true if the item is a diamond tool, false otherwise
*/
public static boolean isDiamondTool(ItemStack is) {
switch (is.getType()) {
case DIAMOND_AXE:
case DIAMOND_HOE:
case DIAMOND_PICKAXE:
case DIAMOND_SPADE:
case DIAMOND_SWORD:
return true;
default:
return false;
}
}
}
package com.gmail.nossr50.util;
import org.bukkit.inventory.ItemStack;
public class ItemChecks {
/**
* Checks if the item is a sword.
*
* @param is Item to check
* @return true if the item is a sword, false otherwise
*/
public static boolean isSword(ItemStack is) {
switch (is.getType()) {
case DIAMOND_SWORD:
case GOLD_SWORD:
case IRON_SWORD:
case STONE_SWORD:
case WOOD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks if the item is a hoe.
*
* @param is Item to check
* @return true if the item is a hoe, false otherwise
*/
public static boolean isHoe(ItemStack is) {
switch (is.getType()) {
case DIAMOND_HOE:
case GOLD_HOE:
case IRON_HOE:
case STONE_HOE:
case WOOD_HOE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a shovel.
*
* @param is Item to check
* @return true if the item is a shovel, false otherwise
*/
public static boolean isShovel(ItemStack is) {
switch (is.getType()) {
case DIAMOND_SPADE:
case GOLD_SPADE:
case IRON_SPADE:
case STONE_SPADE:
case WOOD_SPADE:
return true;
default:
return false;
}
}
/**
* Checks if the item is an axe.
*
* @param is Item to check
* @return true if the item is an axe, false otherwise
*/
public static boolean isAxe(ItemStack is) {
switch (is.getType()) {
case DIAMOND_AXE:
case GOLD_AXE:
case IRON_AXE:
case STONE_AXE:
case WOOD_AXE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pickaxe.
*
* @param is Item to check
* @return true if the item is a pickaxe, false otherwise
*/
public static boolean isMiningPick(ItemStack is) {
switch (is.getType()) {
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case IRON_PICKAXE:
case STONE_PICKAXE:
case WOOD_PICKAXE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a helmet.
*
* @param is Item to check
* @return true if the item is a helmet, false otherwise
*/
public static boolean isHelmet(ItemStack is) {
switch (is.getType()) {
case DIAMOND_HELMET:
case GOLD_HELMET:
case IRON_HELMET:
case LEATHER_HELMET:
return true;
default:
return false;
}
}
/**
* Checks if the item is a chestplate.
*
* @param is Item to check
* @return true if the item is a chestplate, false otherwise
*/
public static boolean isChestplate(ItemStack is) {
switch (is.getType()) {
case DIAMOND_CHESTPLATE:
case GOLD_CHESTPLATE:
case IRON_CHESTPLATE:
case LEATHER_CHESTPLATE:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pair of pants.
*
* @param is Item to check
* @return true if the item is a pair of pants, false otherwise
*/
public static boolean isPants(ItemStack is) {
switch (is.getType()) {
case DIAMOND_LEGGINGS:
case GOLD_LEGGINGS:
case IRON_LEGGINGS:
case LEATHER_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks if the item is a pair of boots.
*
* @param is Item to check
* @return true if the item is a pair of boots, false otherwise
*/
public static boolean isBoots(ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case GOLD_BOOTS:
case IRON_BOOTS:
case LEATHER_BOOTS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a wearable armor piece.
*
* @param is Item to check
* @return true if the item is armor, false otherwise
*/
public static boolean isArmor(ItemStack is) {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
}
/**
* Checks to see if an item is a leather armor piece.
*
* @param is Item to check
* @return true if the item is leather armor, false otherwise
*/
public static boolean isLeatherArmor(ItemStack is) {
switch (is.getType()) {
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_HELMET:
case LEATHER_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a gold armor piece.
*
* @param is Item to check
* @return true if the item is gold armor, false otherwise
*/
public static boolean isGoldArmor(ItemStack is) {
switch (is.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
case GOLD_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is an iron armor piece.
*
* @param is Item to check
* @return true if the item is iron armor, false otherwise
*/
public static boolean isIronArmor(ItemStack is) {
switch (is.getType()) {
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_HELMET:
case IRON_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a diamond armor piece.
*
* @param is Item to check
* @return true if the item is diamond armor, false otherwise
*/
public static boolean isDiamondArmor(ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
case DIAMOND_HELMET:
case DIAMOND_LEGGINGS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a tool.
*
* @param is Item to check
* @return true if the item is a tool, false otherwise
*/
public static boolean isTool(ItemStack is) {
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
}
/**
* Checks to see if an item is a stone tool.
*
* @param is Item to check
* @return true if the item is a stone tool, false otherwise
*/
public static boolean isStoneTool(ItemStack is) {
switch (is.getType()) {
case STONE_AXE:
case STONE_HOE:
case STONE_PICKAXE:
case STONE_SPADE:
case STONE_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a wooden tool.
*
* @param is Item to check
* @return true if the item is a wooden tool, false otherwise
*/
public static boolean isWoodTool(ItemStack is) {
switch (is.getType()) {
case WOOD_AXE:
case WOOD_HOE:
case WOOD_PICKAXE:
case WOOD_SPADE:
case WOOD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a string tool.
*
* @param is Item to check
* @return true if the item is a string tool, false otherwise
*/
public static boolean isStringTool(ItemStack is) {
switch (is.getType()) {
case BOW:
case FISHING_ROD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a gold tool.
*
* @param is Item to check
* @return true if the item is a stone tool, false otherwise
*/
public static boolean isGoldTool(ItemStack is) {
switch (is.getType()) {
case GOLD_AXE:
case GOLD_HOE:
case GOLD_PICKAXE:
case GOLD_SPADE:
case GOLD_SWORD:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is an iron tool.
*
* @param is Item to check
* @return true if the item is an iron tool, false otherwise
*/
public static boolean isIronTool(ItemStack is) {
switch (is.getType()) {
case IRON_AXE:
case IRON_HOE:
case IRON_PICKAXE:
case IRON_SPADE:
case IRON_SWORD:
case SHEARS:
return true;
default:
return false;
}
}
/**
* Checks to see if an item is a diamond tool.
*
* @param is Item to check
* @return true if the item is a diamond tool, false otherwise
*/
public static boolean isDiamondTool(ItemStack is) {
switch (is.getType()) {
case DIAMOND_AXE:
case DIAMOND_HOE:
case DIAMOND_PICKAXE:
case DIAMOND_SPADE:
case DIAMOND_SWORD:
return true;
default:
return false;
}
}
}

View File

@ -1,300 +1,301 @@
package com.gmail.nossr50;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard {
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
private static String location = mcMMO.usersFile;
private static mcMMO plugin = mcMMO.p;
/**
* Create the leaderboards.
*/
public static void makeLeaderboards() {
//Make Trees
Tree Mining = new Tree();
Tree WoodCutting = new Tree();
Tree Herbalism = new Tree();
Tree Excavation = new Tree();
Tree Acrobatics = new Tree();
Tree Repair = new Tree();
Tree Swords = new Tree();
Tree Axes = new Tree();
Tree Archery = new Tree();
Tree Unarmed = new Tree();
Tree Taming = new Tree();
Tree Fishing = new Tree();
Tree PowerLevel = new Tree();
//Add Data To Trees
try {
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
ArrayList<String> players = new ArrayList<String>();
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
String p = character[0];
int powerLevel = 0;
//Prevent the same player from being added multiple times
if (players.contains(p)) {
continue;
}
else {
players.add(p);
}
if (character.length > 1 && m.isInt(character[1])) {
Mining.add(p, Integer.valueOf(character[1]));
powerLevel += Integer.valueOf(character[1]);
}
if (character.length > 5 && m.isInt(character[5])) {
WoodCutting.add(p, Integer.valueOf(character[5]));
powerLevel += Integer.valueOf(character[5]);
}
if (character.length > 7 && m.isInt(character[7])) {
Repair.add(p, Integer.valueOf(character[7]));
powerLevel += Integer.valueOf(character[7]);
}
if (character.length > 8 && m.isInt(character[8])) {
Unarmed.add(p, Integer.valueOf(character[8]));
powerLevel += Integer.valueOf(character[8]);
}
if (character.length > 9 && m.isInt(character[9])) {
Herbalism.add(p, Integer.valueOf(character[9]));
powerLevel += Integer.valueOf(character[9]);
}
if (character.length > 10 && m.isInt(character[10])) {
Excavation.add(p, Integer.valueOf(character[10]));
powerLevel += Integer.valueOf(character[10]);
}
if (character.length > 11 && m.isInt(character[11])) {
Archery.add(p, Integer.valueOf(character[11]));
powerLevel += Integer.valueOf(character[11]);
}
if (character.length > 12 && m.isInt(character[12])) {
Swords.add(p, Integer.valueOf(character[12]));
powerLevel += Integer.valueOf(character[12]);
}
if (character.length > 13 && m.isInt(character[13])) {
Axes.add(p, Integer.valueOf(character[13]));
powerLevel += Integer.valueOf(character[13]);
}
if (character.length > 14 && m.isInt(character[14])) {
Acrobatics.add(p, Integer.valueOf(character[14]));
powerLevel += Integer.valueOf(character[14]);
}
if (character.length > 24 && m.isInt(character[24])) {
Taming.add(p, Integer.valueOf(character[24]));
powerLevel += Integer.valueOf(character[24]);
}
if (character.length > 34 && m.isInt(character[34])) {
Fishing.add(p, Integer.valueOf(character[34]));
powerLevel += Integer.valueOf(character[34]);
}
PowerLevel.add(p, powerLevel);
}
in.close();
}
catch (Exception e) {
plugin.getLogger().severe(("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()));
}
//Write the leader board files
leaderWrite(Mining.inOrder(), SkillType.MINING);
leaderWrite(WoodCutting.inOrder(), SkillType.WOODCUTTING);
leaderWrite(Repair.inOrder(), SkillType.REPAIR);
leaderWrite(Unarmed.inOrder(), SkillType.UNARMED);
leaderWrite(Herbalism.inOrder(), SkillType.HERBALISM);
leaderWrite(Excavation.inOrder(), SkillType.EXCAVATION);
leaderWrite(Archery.inOrder(), SkillType.ARCHERY);
leaderWrite(Swords.inOrder(), SkillType.SWORDS);
leaderWrite(Axes.inOrder(), SkillType.AXES);
leaderWrite(Acrobatics.inOrder(), SkillType.ACROBATICS);
leaderWrite(Taming.inOrder(), SkillType.TAMING);
leaderWrite(Fishing.inOrder(), SkillType.FISHING);
leaderWrite(PowerLevel.inOrder(), SkillType.ALL);
}
/**
* Write to the leaderboards.
*
* @param ps Stats to write to the leaderboard
* @param skillType Skill type to write the leaderboard of
*/
private static void leaderWrite(PlayerStat[] ps, SkillType skillType) {
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
File theDir = new File(theLocation);
//CHECK IF THE FILE EXISTS
if (!theDir.exists()) {
FileWriter writer = null;
try {
writer = new FileWriter(theLocation);
}
catch (Exception e) {
plugin.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
}
finally {
try {
if (writer != null) {
writer.close();
}
}
catch (IOException e) {
plugin.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
}
}
}
else {
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
for (PlayerStat p : ps) {
if (p.name.equals("$mcMMO_DummyInfo")) {
continue;
}
if (p.statVal == 0) {
continue;
}
writer.append(p.name + ":" + p.statVal);
writer.append("\r\n");
}
in.close();
FileWriter out = new FileWriter(theLocation);
out.write(writer.toString());
out.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}
/**
* Retrieve leaderboard info.
*
* @param skillName Skill to retrieve info on.
* @param pagenumber Which page in the leaderboards to retrieve
* @return the requested leaderboard information
*/
public static String[] retrieveInfo(String skillName, int pagenumber) {
String theLocation = leaderboardsDirectory + skillName.toLowerCase() + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
int destination;
//How many lines to skip through
if (pagenumber == 1) {
destination = 0;
}
else {
destination = (pagenumber * 10) - 9;
}
int x = 0; //how many lines we've gone through
int y = 0; //going through the lines
String line = "";
String[] info = new String[10]; //what to return
while ((line = in.readLine()) != null && y < 10) {
x++;
if (x >= destination && y < 10) {
info[y] = line.toString();
y++;
}
}
in.close();
return info;
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
return null; //Shouldn't get here
}
/**
* Update the leaderboards.
*
* @param ps Stats to update the leaderboard with.
* @param skillType Skill whose leaderboard is being updated.
*/
public static void updateLeaderboard(PlayerStat ps, SkillType skillType) {
if (Config.getInstance().getUseMySQL()) {
return;
}
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
Boolean inserted = false;
while ((line = in.readLine()) != null) {
//Insert the player into the line before it finds a smaller one
if (Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted) {
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
inserted = true;
}
//Write anything that isn't the player already in the file so we remove the duplicate
if (!line.split(":")[0].equalsIgnoreCase(ps.name)) {
writer.append(line).append("\r\n");
}
}
if(!inserted) {
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
}
in.close();
//Write the new file
FileWriter out = new FileWriter(theLocation);
out.write(writer.toString());
out.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}
package com.gmail.nossr50.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard {
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
private static String location = mcMMO.usersFile;
private static mcMMO plugin = mcMMO.p;
/**
* Create the leaderboards.
*/
public static void makeLeaderboards() {
//Make Trees
Tree Mining = new Tree();
Tree WoodCutting = new Tree();
Tree Herbalism = new Tree();
Tree Excavation = new Tree();
Tree Acrobatics = new Tree();
Tree Repair = new Tree();
Tree Swords = new Tree();
Tree Axes = new Tree();
Tree Archery = new Tree();
Tree Unarmed = new Tree();
Tree Taming = new Tree();
Tree Fishing = new Tree();
Tree PowerLevel = new Tree();
//Add Data To Trees
try {
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
ArrayList<String> players = new ArrayList<String>();
while ((line = in.readLine()) != null) {
String[] character = line.split(":");
String p = character[0];
int powerLevel = 0;
//Prevent the same player from being added multiple times
if (players.contains(p)) {
continue;
}
else {
players.add(p);
}
if (character.length > 1 && Misc.isInt(character[1])) {
Mining.add(p, Integer.valueOf(character[1]));
powerLevel += Integer.valueOf(character[1]);
}
if (character.length > 5 && Misc.isInt(character[5])) {
WoodCutting.add(p, Integer.valueOf(character[5]));
powerLevel += Integer.valueOf(character[5]);
}
if (character.length > 7 && Misc.isInt(character[7])) {
Repair.add(p, Integer.valueOf(character[7]));
powerLevel += Integer.valueOf(character[7]);
}
if (character.length > 8 && Misc.isInt(character[8])) {
Unarmed.add(p, Integer.valueOf(character[8]));
powerLevel += Integer.valueOf(character[8]);
}
if (character.length > 9 && Misc.isInt(character[9])) {
Herbalism.add(p, Integer.valueOf(character[9]));
powerLevel += Integer.valueOf(character[9]);
}
if (character.length > 10 && Misc.isInt(character[10])) {
Excavation.add(p, Integer.valueOf(character[10]));
powerLevel += Integer.valueOf(character[10]);
}
if (character.length > 11 && Misc.isInt(character[11])) {
Archery.add(p, Integer.valueOf(character[11]));
powerLevel += Integer.valueOf(character[11]);
}
if (character.length > 12 && Misc.isInt(character[12])) {
Swords.add(p, Integer.valueOf(character[12]));
powerLevel += Integer.valueOf(character[12]);
}
if (character.length > 13 && Misc.isInt(character[13])) {
Axes.add(p, Integer.valueOf(character[13]));
powerLevel += Integer.valueOf(character[13]);
}
if (character.length > 14 && Misc.isInt(character[14])) {
Acrobatics.add(p, Integer.valueOf(character[14]));
powerLevel += Integer.valueOf(character[14]);
}
if (character.length > 24 && Misc.isInt(character[24])) {
Taming.add(p, Integer.valueOf(character[24]));
powerLevel += Integer.valueOf(character[24]);
}
if (character.length > 34 && Misc.isInt(character[34])) {
Fishing.add(p, Integer.valueOf(character[34]));
powerLevel += Integer.valueOf(character[34]);
}
PowerLevel.add(p, powerLevel);
}
in.close();
}
catch (Exception e) {
plugin.getLogger().severe(("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()));
}
//Write the leader board files
leaderWrite(Mining.inOrder(), SkillType.MINING);
leaderWrite(WoodCutting.inOrder(), SkillType.WOODCUTTING);
leaderWrite(Repair.inOrder(), SkillType.REPAIR);
leaderWrite(Unarmed.inOrder(), SkillType.UNARMED);
leaderWrite(Herbalism.inOrder(), SkillType.HERBALISM);
leaderWrite(Excavation.inOrder(), SkillType.EXCAVATION);
leaderWrite(Archery.inOrder(), SkillType.ARCHERY);
leaderWrite(Swords.inOrder(), SkillType.SWORDS);
leaderWrite(Axes.inOrder(), SkillType.AXES);
leaderWrite(Acrobatics.inOrder(), SkillType.ACROBATICS);
leaderWrite(Taming.inOrder(), SkillType.TAMING);
leaderWrite(Fishing.inOrder(), SkillType.FISHING);
leaderWrite(PowerLevel.inOrder(), SkillType.ALL);
}
/**
* Write to the leaderboards.
*
* @param ps Stats to write to the leaderboard
* @param skillType Skill type to write the leaderboard of
*/
private static void leaderWrite(PlayerStat[] ps, SkillType skillType) {
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
File theDir = new File(theLocation);
//CHECK IF THE FILE EXISTS
if (!theDir.exists()) {
FileWriter writer = null;
try {
writer = new FileWriter(theLocation);
}
catch (Exception e) {
plugin.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
}
finally {
try {
if (writer != null) {
writer.close();
}
}
catch (IOException e) {
plugin.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
}
}
}
else {
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
for (PlayerStat p : ps) {
if (p.name.equals("$mcMMO_DummyInfo")) {
continue;
}
if (p.statVal == 0) {
continue;
}
writer.append(p.name + ":" + p.statVal);
writer.append("\r\n");
}
in.close();
FileWriter out = new FileWriter(theLocation);
out.write(writer.toString());
out.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}
/**
* Retrieve leaderboard info.
*
* @param skillName Skill to retrieve info on.
* @param pagenumber Which page in the leaderboards to retrieve
* @return the requested leaderboard information
*/
public static String[] retrieveInfo(String skillName, int pagenumber) {
String theLocation = leaderboardsDirectory + skillName.toLowerCase() + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
int destination;
//How many lines to skip through
if (pagenumber == 1) {
destination = 0;
}
else {
destination = (pagenumber * 10) - 9;
}
int x = 0; //how many lines we've gone through
int y = 0; //going through the lines
String line = "";
String[] info = new String[10]; //what to return
while ((line = in.readLine()) != null && y < 10) {
x++;
if (x >= destination && y < 10) {
info[y] = line.toString();
y++;
}
}
in.close();
return info;
}
catch (Exception e) {
plugin.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
return null; //Shouldn't get here
}
/**
* Update the leaderboards.
*
* @param ps Stats to update the leaderboard with.
* @param skillType Skill whose leaderboard is being updated.
*/
public static void updateLeaderboard(PlayerStat ps, SkillType skillType) {
if (Config.getInstance().getUseMySQL()) {
return;
}
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
Boolean inserted = false;
while ((line = in.readLine()) != null) {
//Insert the player into the line before it finds a smaller one
if (Integer.valueOf(line.split(":")[1]) < ps.statVal && !inserted) {
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
inserted = true;
}
//Write anything that isn't the player already in the file so we remove the duplicate
if (!line.split(":")[0].equalsIgnoreCase(ps.name)) {
writer.append(line).append("\r\n");
}
}
if(!inserted) {
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
}
in.close();
//Write the new file
FileWriter out = new FileWriter(theLocation);
out.write(writer.toString());
out.close();
}
catch (Exception e) {
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}

View File

@ -1,4 +1,4 @@
package com.gmail.nossr50;
package com.gmail.nossr50.util;
/*
* Copyright 2011 Tyler Blair. All rights reserved.
*

View File

@ -1,271 +1,272 @@
package com.gmail.nossr50;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
public class m {
private static Random random = new Random();
/**
* Gets a capitalized version of the target string.
*
* @param target String to capitalize
* @return the capitalized string
*/
public static String getCapitalized(String target) {
String firstLetter = target.substring(0,1);
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
}
/**
* Gets a nicely formatted string version of an item name from a given item ID.
*
* @param itemID The ID of the item to convert to string.
* @return the nicely formatting string
*/
public static String prettyItemString(int itemID) {
String baseString = Material.getMaterial(itemID).toString();
String[] substrings = baseString.split("_");
String prettyString = "";
int size = 1;
for (String s : substrings) {
prettyString = prettyString.concat(m.getCapitalized(s));
if (size < substrings.length) {
prettyString = prettyString.concat(" ");
}
size++;
}
return prettyString;
}
/**
* Gets the int represented by this string.
*
* @param string The string to parse
* @return the int represented by this string
*/
public static int getInt(String string) {
if (isInt(string)) {
return Integer.parseInt(string);
}
else {
return 0;
}
}
/**
* Checks to see if an entity is currently invincible.
*
* @param le The LivingEntity to check
* @param event The event the entity is involved in
* @return true if the entity is invincible, false otherwise
*/
public static boolean isInvincible(LivingEntity le, EntityDamageEvent event) {
/*
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
* So yeah, this is for that.
*/
if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) {
return true;
}
else {
return false;
}
}
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
* @return true if the event wasn't cancelled, false otherwise
*/
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
//Support for NoCheat
if (shouldArmSwing) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
}
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
return true;
}
else {
return false;
}
}
/**
* Get the upgrade tier of the item in hand.
*
* @param inHand The item to check the tier of
* @return the tier of the item
*/
public static int getTier(ItemStack inHand) {
int tier = 0;
if (ItemChecks.isWoodTool(inHand)) {
tier = 1;
}
else if (ItemChecks.isStoneTool(inHand)) {
tier = 2;
}
else if (ItemChecks.isIronTool(inHand)) {
tier = 3;
}
else if(ItemChecks.isGoldTool(inHand)) {
tier = 1;
}
else if(ItemChecks.isDiamondTool(inHand))
tier = 4;
return tier;
}
/**
* Determine if two locations are near each other.
*
* @param first The first location
* @param second The second location
* @param maxDistance The max distance apart
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
*/
public static boolean isNear(Location first, Location second, double maxDistance) {
if (!first.getWorld().equals(second.getWorld())) {
return false;
}
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
return true;
}
else {
return false;
}
}
/**
* Determine if a string represents an Integer
*
* @param string String to check
* @return true if the string is an Integer, false otherwise
*/
public static boolean isInt(String string) {
try {
Integer.parseInt(string);
return true;
}
catch (NumberFormatException nFE) {
return false;
}
}
/**
* Drop items at a given location.
*
* @param location The location to drop the items at
* @param is The items to drop
* @param quantity The amount of items to drop
*/
public static void mcDropItems(Location location, ItemStack is, int quantity) {
for (int i = 0; i < quantity; i++) {
mcDropItem(location, is);
}
}
/**
* Randomly drop an item at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
*/
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
if (random.nextInt(100) < chance) {
mcDropItem(location, is);
}
}
/**
* Randomly drop items at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
* @param quantity The amount of items to drop
*/
public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity) {
for(int i = 0; i < quantity; i++) {
mcRandomDropItem(location, is, chance);
}
}
/**
* Drop an item at a given location.
*
* @param location The location to drop the item at
* @param itemStack The item to drop
*/
public static void mcDropItem(Location location, ItemStack itemStack) {
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
location.getWorld().dropItemNaturally(location, itemStack);
}
/**
* Check if a skill level is higher than the max bonus level of the ability.
*
* @param skillLevel Skill level to check
* @param maxLevel Max level of the ability
* @return whichever value is lower
*/
public static int skillCheck(int skillLevel, int maxLevel) {
if (skillLevel > maxLevel) {
return maxLevel;
}
else {
return skillLevel;
}
}
public static int getPowerLevelCap() {
if (Config.getInstance().getPowerLevelCap() > 0) {
return Config.getInstance().getPowerLevelCap();
}
else {
return Integer.MAX_VALUE;
}
}
}
package com.gmail.nossr50.util;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
public class Misc {
private static Random random = new Random();
/**
* Gets a capitalized version of the target string.
*
* @param target String to capitalize
* @return the capitalized string
*/
public static String getCapitalized(String target) {
String firstLetter = target.substring(0,1);
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
}
/**
* Gets a nicely formatted string version of an item name from a given item ID.
*
* @param itemID The ID of the item to convert to string.
* @return the nicely formatting string
*/
public static String prettyItemString(int itemID) {
String baseString = Material.getMaterial(itemID).toString();
String[] substrings = baseString.split("_");
String prettyString = "";
int size = 1;
for (String s : substrings) {
prettyString = prettyString.concat(Misc.getCapitalized(s));
if (size < substrings.length) {
prettyString = prettyString.concat(" ");
}
size++;
}
return prettyString;
}
/**
* Gets the int represented by this string.
*
* @param string The string to parse
* @return the int represented by this string
*/
public static int getInt(String string) {
if (isInt(string)) {
return Integer.parseInt(string);
}
else {
return 0;
}
}
/**
* Checks to see if an entity is currently invincible.
*
* @param le The LivingEntity to check
* @param event The event the entity is involved in
* @return true if the entity is invincible, false otherwise
*/
public static boolean isInvincible(LivingEntity le, EntityDamageEvent event) {
/*
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
* So yeah, this is for that.
*/
if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) {
return true;
}
else {
return false;
}
}
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
* @return true if the event wasn't cancelled, false otherwise
*/
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
//Support for NoCheat
if (shouldArmSwing) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
}
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
return true;
}
else {
return false;
}
}
/**
* Get the upgrade tier of the item in hand.
*
* @param inHand The item to check the tier of
* @return the tier of the item
*/
public static int getTier(ItemStack inHand) {
int tier = 0;
if (ItemChecks.isWoodTool(inHand)) {
tier = 1;
}
else if (ItemChecks.isStoneTool(inHand)) {
tier = 2;
}
else if (ItemChecks.isIronTool(inHand)) {
tier = 3;
}
else if(ItemChecks.isGoldTool(inHand)) {
tier = 1;
}
else if(ItemChecks.isDiamondTool(inHand))
tier = 4;
return tier;
}
/**
* Determine if two locations are near each other.
*
* @param first The first location
* @param second The second location
* @param maxDistance The max distance apart
* @return true if the distance between <code>first</code> and <code>second</code> is less than <code>maxDistance</code>, false otherwise
*/
public static boolean isNear(Location first, Location second, double maxDistance) {
if (!first.getWorld().equals(second.getWorld())) {
return false;
}
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
return true;
}
else {
return false;
}
}
/**
* Determine if a string represents an Integer
*
* @param string String to check
* @return true if the string is an Integer, false otherwise
*/
public static boolean isInt(String string) {
try {
Integer.parseInt(string);
return true;
}
catch (NumberFormatException nFE) {
return false;
}
}
/**
* Drop items at a given location.
*
* @param location The location to drop the items at
* @param is The items to drop
* @param quantity The amount of items to drop
*/
public static void mcDropItems(Location location, ItemStack is, int quantity) {
for (int i = 0; i < quantity; i++) {
mcDropItem(location, is);
}
}
/**
* Randomly drop an item at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
*/
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
if (random.nextInt(100) < chance) {
mcDropItem(location, is);
}
}
/**
* Randomly drop items at a given location.
*
* @param location The location to drop the items at
* @param is The item to drop
* @param chance The percentage chance for the item to drop
* @param quantity The amount of items to drop
*/
public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity) {
for(int i = 0; i < quantity; i++) {
mcRandomDropItem(location, is, chance);
}
}
/**
* Drop an item at a given location.
*
* @param location The location to drop the item at
* @param itemStack The item to drop
*/
public static void mcDropItem(Location location, ItemStack itemStack) {
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
location.getWorld().dropItemNaturally(location, itemStack);
}
/**
* Check if a skill level is higher than the max bonus level of the ability.
*
* @param skillLevel Skill level to check
* @param maxLevel Max level of the ability
* @return whichever value is lower
*/
public static int skillCheck(int skillLevel, int maxLevel) {
if (skillLevel > maxLevel) {
return maxLevel;
}
else {
return skillLevel;
}
}
public static int getPowerLevelCap() {
if (Config.getInstance().getPowerLevelCap() > 0) {
return Config.getInstance().getPowerLevelCap();
}
else {
return Integer.MAX_VALUE;
}
}
}

View File

@ -5,15 +5,14 @@ import java.util.ArrayList;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.locale.LocaleLoader;
public class Page {
public static int getTotalPageNumber(String address)
{
String[] addressSplit = mcLocale.getString(address).split("\n");
String[] addressSplit = LocaleLoader.getString(address).split("\n");
if(addressSplit.length <= 8)
return 1;
else
@ -31,7 +30,7 @@ public class Page {
}
ArrayList<String> allStrings = new ArrayList<String>();
String split[] = mcLocale.getString(address).split("\n");
String split[] = LocaleLoader.getString(address).split("\n");
allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish
@ -59,7 +58,7 @@ public class Page {
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args)
{
String capitalized = m.getCapitalized(skilltype.toString());
String capitalized = Misc.getCapitalized(skilltype.toString());
player.sendMessage(ChatColor.DARK_AQUA+"Guide for "+capitalized+" available type /"+skilltype.toString().toLowerCase()+" ? [Page#]"); //TODO: Needs more locale.
if (args.length >= 1)
{
@ -68,10 +67,10 @@ public class Page {
String address = "Guides."+capitalized;
if(args.length > 1 && m.isInt(args[1]) && m.getInt(args[1]) <= Page.getTotalPageNumber(address))
if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
{
Page.clearChat(player);
for(String target : Page.grabPageContents(capitalized+" Guide", address, m.getInt(args[1])))
for(String target : Page.grabPageContents(capitalized+" Guide", address, Misc.getInt(args[1])))
{
player.sendMessage(target);
}
@ -83,11 +82,11 @@ public class Page {
player.sendMessage(target);
}
}
else if(args.length > 1 && m.getInt(args[1]) > Page.getTotalPageNumber(address))
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
{
player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale.
}
else if(args.length > 1 && !m.isInt(args[1]))
else if(args.length > 1 && !Misc.isInt(args[1]))
{
player.sendMessage("Not a valid page number!"); //TODO: Needs more locale.
}

View File

@ -1,418 +1,418 @@
package com.gmail.nossr50;
import org.bukkit.entity.Player;
public class mcPermissions {
private static volatile mcPermissions instance;
public boolean permission(Player player, String perm) {
return player.hasPermission(perm);
}
public static mcPermissions getInstance() {
if (instance == null) {
instance = new mcPermissions();
}
return instance;
}
/*
* GENERIC PERMISSIONS
*/
public boolean motd(Player player) {
return player.hasPermission("mcmmo.motd");
}
public boolean admin(Player player) {
return player.hasPermission("mcmmo.admin");
}
/*
* MCMMO.BYPASS.*
*/
public boolean arcaneBypass(Player player) {
return player.hasPermission("mcmmo.bypass.arcanebypass");
}
public boolean inspectDistanceBypass(Player player) {
return player.hasPermission("mcmmo.bypass.inspect.distance");
}
public boolean inspectOfflineBypass(Player player) {
return player.hasPermission("mcmmo.bypass.inspect.offline");
}
/*
* MCMMO.TOOLS.*
*/
public boolean mcrefresh(Player player) {
return player.hasPermission("mcmmo.tools.mcrefresh");
}
public boolean mcremove(Player player) {
return player.hasPermission("mcmmo.tools.mcremove");
}
public boolean mmoedit(Player player) {
return player.hasPermission("mcmmo.tools.mmoedit");
}
public boolean mcgod(Player player) {
return player.hasPermission("mcmmo.tools.mcgod");
}
/*
* MCMMO.ABILITY.TAMING.*
*/
public boolean fastFoodService(Player player) {
return player.hasPermission("mcmmo.ability.taming.fastfoodservice");
}
public boolean sharpenedclaws(Player player) {
return player.hasPermission("mcmmo.ability.taming.sharpenedclaws");
}
public boolean gore(Player player) {
return player.hasPermission("mcmmo.ability.taming.gore");
}
public boolean callOfTheWild(Player player) {
return player.hasPermission("mcmmo.ability.taming.callofthewild");
}
public boolean environmentallyAware(Player player) {
return player.hasPermission("mcmmo.ability.taming.environmentallyaware");
}
public boolean thickFur(Player player) {
return player.hasPermission("mcmmo.ability.taming.thickfur");
}
public boolean shockProof(Player player) {
return player.hasPermission("mcmmo.ability.taming.shockproof");
}
public boolean beastLore(Player player) {
return player.hasPermission("mcmmo.ability.taming.beastlore");
}
/*
* MCMMO.ABILITY.FISHING.*
*/
public boolean shakeMob(Player player) {
return player.hasPermission("mcmmo.ability.fishing.shakemob");
}
/*
* MCMMO.ABILITY.MINING.*
*/
public boolean superBreaker(Player player) {
return player.hasPermission("mcmmo.ability.mining.superbreaker");
}
public boolean miningDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.mining.doubledrops");
}
/*
* MCMMO.ABILITY.WOODCUTTING.*
*/
public boolean treeFeller(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.treefeller");
}
public boolean leafBlower(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.leafblower");
}
public boolean woodcuttingDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.doubledrops");
}
/*
* MCMMO.ABILITY.REPAIR.*
*/
public boolean repairBonus(Player player) {
return player.hasPermission("mcmmo.ability.repair.repairbonus");
}
public boolean arcaneForging(Player player) {
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
}
public boolean woodRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.woodrepair");
}
public boolean stoneRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.stonerepair");
}
public boolean leatherRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.leatherrepair");
}
public boolean ironRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.ironrepair");
}
public boolean goldRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.goldrepair");
}
public boolean diamondRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.diamondrepair");
}
public boolean armorRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.armorrepair");
}
public boolean toolRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.toolrepair");
}
public boolean stringRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.stringrepair");
}
/*
* MCMMO.ABILITY.UNARMED.*
*/
public boolean unarmedBonus(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.bonusdamage");
}
public boolean disarm(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.disarm");
}
public boolean berserk(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.berserk");
}
public boolean deflect(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.deflect");
}
/*
* MCMMO.ABILITY.ARCHERY.*
*/
public boolean trackArrows(Player player) {
return player.hasPermission("mcmmo.ability.archery.trackarrows");
}
public boolean ignition(Player player) {
return player.hasPermission("mcmmo.ability.archery.ignition");
}
public boolean daze(Player player) {
return player.hasPermission("mcmmo.ability.archery.daze");
}
/*
* MCMMO.ABILITY.HERBALISM.*
*/
public boolean herbalismDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.doubledrops");
}
public boolean greenTerra(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenterra");
}
public boolean greenThumbBlocks(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenthumbblocks");
}
public boolean greenThumbWheat(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenthumbwheat");
}
/*
* MCMMO.ABILITY.EXCAVATION.*
*/
public boolean gigaDrillBreaker(Player player) {
return player.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
}
public boolean excavationTreasures(Player player) {
return player.hasPermission("mcmmo.ability.excavation.treasures");
}
/*
* MCMMO.ABILITY.SWORDS.*
*/
public boolean swordsBleed(Player player) {
return player.hasPermission("mcmmo.ability.swords.bleed");
}
public boolean serratedStrikes(Player player) {
return player.hasPermission("mcmmo.ability.swords.serratedstrikes");
}
public boolean counterAttack(Player player) {
return player.hasPermission("mcmmo.ability.swords.counterattack");
}
/*
* MCMMO.ABILITY.AXES.*
*/
public boolean skullSplitter(Player player) {
return player.hasPermission("mcmmo.ability.axes.skullsplitter");
}
public boolean axeBonus(Player player) {
return player.hasPermission("mcmmo.ability.axes.bonusdamage");
}
public boolean criticalHit(Player player) {
return player.hasPermission("mcmmo.ability.axes.criticalhit");
}
public boolean impact(Player player) {
return player.hasPermission("mcmmo.ability.axes.impact");
}
/*
* MCMMO.ABILITY.ACROBATICS.*
*/
public boolean roll(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.roll");
}
public boolean gracefulRoll(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
}
public boolean dodge(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.dodge");
}
/*
* MCMMO.ABILITY.BLASTMINING.*
*/
public boolean biggerBombs(Player player) {
return player.hasPermission("mcmmo.ability.blastmining.biggerbombs");
}
public boolean demolitionsExpertise(Player player) {
return player.hasPermission("mcmmo.ability.blastmining.demolitionsexpertise");
}
/*
* MCMMO.ITEM.*
*/
public boolean chimaeraWing(Player player) {
return player.hasPermission("mcmmo.item.chimaerawing");
}
/*
* MCMMO.COMMANDS.*
*/
public boolean mcAbility(Player player) {
return player.hasPermission("mcmmo.commands.ability");
}
public boolean partyTeleport(Player player) {
return player.hasPermission("mcmmo.commands.ptp");
}
public boolean inspect(Player player) {
return player.hasPermission("mcmmo.commands.inspect");
}
public boolean party(Player player) {
return player.hasPermission("mcmmo.commands.party");
}
/*
* MCMMO.CHAT.*
*/
public boolean partyChat(Player player) {
return player.hasPermission("mcmmo.chat.partychat");
}
public boolean partyLock(Player player) {
return player.hasPermission("mcmmo.chat.partylock");
}
public boolean adminChat(Player player) {
return player.hasPermission("mcmmo.chat.adminchat");
}
/*
* MCMMO.SKILLS.*
*/
public boolean taming(Player player) {
return player.hasPermission("mcmmo.skills.taming");
}
public boolean mining(Player player) {
return player.hasPermission("mcmmo.skills.mining");
}
public boolean blastMining(Player player) {
return player.hasPermission("mcmmo.skills.blastmining");
}
public boolean fishing(Player player) {
return player.hasPermission("mcmmo.skills.fishing");
}
public boolean woodcutting(Player player) {
return player.hasPermission("mcmmo.skills.woodcutting");
}
public boolean repair(Player player) {
return player.hasPermission("mcmmo.skills.repair");
}
public boolean unarmed(Player player) {
return player.hasPermission("mcmmo.skills.unarmed");
}
public boolean archery(Player player) {
return player.hasPermission("mcmmo.skills.archery");
}
public boolean herbalism(Player player) {
return player.hasPermission("mcmmo.skills.herbalism");
}
public boolean excavation(Player player) {
return player.hasPermission("mcmmo.skills.excavation");
}
public boolean swords(Player player) {
return player.hasPermission("mcmmo.skills.swords");
}
public boolean axes(Player player) {
return player.hasPermission("mcmmo.skills.axes");
}
public boolean acrobatics(Player player) {
return player.hasPermission("mcmmo.skills.acrobatics");
}
}
package com.gmail.nossr50.util;
import org.bukkit.entity.Player;
public class Permissions {
private static volatile Permissions instance;
public boolean permission(Player player, String perm) {
return player.hasPermission(perm);
}
public static Permissions getInstance() {
if (instance == null) {
instance = new Permissions();
}
return instance;
}
/*
* GENERIC PERMISSIONS
*/
public boolean motd(Player player) {
return player.hasPermission("mcmmo.motd");
}
public boolean admin(Player player) {
return player.hasPermission("mcmmo.admin");
}
/*
* MCMMO.BYPASS.*
*/
public boolean arcaneBypass(Player player) {
return player.hasPermission("mcmmo.bypass.arcanebypass");
}
public boolean inspectDistanceBypass(Player player) {
return player.hasPermission("mcmmo.bypass.inspect.distance");
}
public boolean inspectOfflineBypass(Player player) {
return player.hasPermission("mcmmo.bypass.inspect.offline");
}
/*
* MCMMO.TOOLS.*
*/
public boolean mcrefresh(Player player) {
return player.hasPermission("mcmmo.tools.mcrefresh");
}
public boolean mcremove(Player player) {
return player.hasPermission("mcmmo.tools.mcremove");
}
public boolean mmoedit(Player player) {
return player.hasPermission("mcmmo.tools.mmoedit");
}
public boolean mcgod(Player player) {
return player.hasPermission("mcmmo.tools.mcgod");
}
/*
* MCMMO.ABILITY.TAMING.*
*/
public boolean fastFoodService(Player player) {
return player.hasPermission("mcmmo.ability.taming.fastfoodservice");
}
public boolean sharpenedclaws(Player player) {
return player.hasPermission("mcmmo.ability.taming.sharpenedclaws");
}
public boolean gore(Player player) {
return player.hasPermission("mcmmo.ability.taming.gore");
}
public boolean callOfTheWild(Player player) {
return player.hasPermission("mcmmo.ability.taming.callofthewild");
}
public boolean environmentallyAware(Player player) {
return player.hasPermission("mcmmo.ability.taming.environmentallyaware");
}
public boolean thickFur(Player player) {
return player.hasPermission("mcmmo.ability.taming.thickfur");
}
public boolean shockProof(Player player) {
return player.hasPermission("mcmmo.ability.taming.shockproof");
}
public boolean beastLore(Player player) {
return player.hasPermission("mcmmo.ability.taming.beastlore");
}
/*
* MCMMO.ABILITY.FISHING.*
*/
public boolean shakeMob(Player player) {
return player.hasPermission("mcmmo.ability.fishing.shakemob");
}
/*
* MCMMO.ABILITY.MINING.*
*/
public boolean superBreaker(Player player) {
return player.hasPermission("mcmmo.ability.mining.superbreaker");
}
public boolean miningDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.mining.doubledrops");
}
/*
* MCMMO.ABILITY.WOODCUTTING.*
*/
public boolean treeFeller(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.treefeller");
}
public boolean leafBlower(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.leafblower");
}
public boolean woodcuttingDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.woodcutting.doubledrops");
}
/*
* MCMMO.ABILITY.REPAIR.*
*/
public boolean repairBonus(Player player) {
return player.hasPermission("mcmmo.ability.repair.repairbonus");
}
public boolean arcaneForging(Player player) {
return player.hasPermission("mcmmo.ability.repair.arcaneforging");
}
public boolean woodRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.woodrepair");
}
public boolean stoneRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.stonerepair");
}
public boolean leatherRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.leatherrepair");
}
public boolean ironRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.ironrepair");
}
public boolean goldRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.goldrepair");
}
public boolean diamondRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.diamondrepair");
}
public boolean armorRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.armorrepair");
}
public boolean toolRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.toolrepair");
}
public boolean stringRepair(Player player) {
return player.hasPermission("mcmmo.ability.repair.stringrepair");
}
/*
* MCMMO.ABILITY.UNARMED.*
*/
public boolean unarmedBonus(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.bonusdamage");
}
public boolean disarm(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.disarm");
}
public boolean berserk(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.berserk");
}
public boolean deflect(Player player) {
return player.hasPermission("mcmmo.ability.unarmed.deflect");
}
/*
* MCMMO.ABILITY.ARCHERY.*
*/
public boolean trackArrows(Player player) {
return player.hasPermission("mcmmo.ability.archery.trackarrows");
}
public boolean ignition(Player player) {
return player.hasPermission("mcmmo.ability.archery.ignition");
}
public boolean daze(Player player) {
return player.hasPermission("mcmmo.ability.archery.daze");
}
/*
* MCMMO.ABILITY.HERBALISM.*
*/
public boolean herbalismDoubleDrops(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.doubledrops");
}
public boolean greenTerra(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenterra");
}
public boolean greenThumbBlocks(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenthumbblocks");
}
public boolean greenThumbWheat(Player player) {
return player.hasPermission("mcmmo.ability.herbalism.greenthumbwheat");
}
/*
* MCMMO.ABILITY.EXCAVATION.*
*/
public boolean gigaDrillBreaker(Player player) {
return player.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
}
public boolean excavationTreasures(Player player) {
return player.hasPermission("mcmmo.ability.excavation.treasures");
}
/*
* MCMMO.ABILITY.SWORDS.*
*/
public boolean swordsBleed(Player player) {
return player.hasPermission("mcmmo.ability.swords.bleed");
}
public boolean serratedStrikes(Player player) {
return player.hasPermission("mcmmo.ability.swords.serratedstrikes");
}
public boolean counterAttack(Player player) {
return player.hasPermission("mcmmo.ability.swords.counterattack");
}
/*
* MCMMO.ABILITY.AXES.*
*/
public boolean skullSplitter(Player player) {
return player.hasPermission("mcmmo.ability.axes.skullsplitter");
}
public boolean axeBonus(Player player) {
return player.hasPermission("mcmmo.ability.axes.bonusdamage");
}
public boolean criticalHit(Player player) {
return player.hasPermission("mcmmo.ability.axes.criticalhit");
}
public boolean impact(Player player) {
return player.hasPermission("mcmmo.ability.axes.impact");
}
/*
* MCMMO.ABILITY.ACROBATICS.*
*/
public boolean roll(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.roll");
}
public boolean gracefulRoll(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
}
public boolean dodge(Player player) {
return player.hasPermission("mcmmo.ability.acrobatics.dodge");
}
/*
* MCMMO.ABILITY.BLASTMINING.*
*/
public boolean biggerBombs(Player player) {
return player.hasPermission("mcmmo.ability.blastmining.biggerbombs");
}
public boolean demolitionsExpertise(Player player) {
return player.hasPermission("mcmmo.ability.blastmining.demolitionsexpertise");
}
/*
* MCMMO.ITEM.*
*/
public boolean chimaeraWing(Player player) {
return player.hasPermission("mcmmo.item.chimaerawing");
}
/*
* MCMMO.COMMANDS.*
*/
public boolean mcAbility(Player player) {
return player.hasPermission("mcmmo.commands.ability");
}
public boolean partyTeleport(Player player) {
return player.hasPermission("mcmmo.commands.ptp");
}
public boolean inspect(Player player) {
return player.hasPermission("mcmmo.commands.inspect");
}
public boolean party(Player player) {
return player.hasPermission("mcmmo.commands.party");
}
/*
* MCMMO.CHAT.*
*/
public boolean partyChat(Player player) {
return player.hasPermission("mcmmo.chat.partychat");
}
public boolean partyLock(Player player) {
return player.hasPermission("mcmmo.chat.partylock");
}
public boolean adminChat(Player player) {
return player.hasPermission("mcmmo.chat.adminchat");
}
/*
* MCMMO.SKILLS.*
*/
public boolean taming(Player player) {
return player.hasPermission("mcmmo.skills.taming");
}
public boolean mining(Player player) {
return player.hasPermission("mcmmo.skills.mining");
}
public boolean blastMining(Player player) {
return player.hasPermission("mcmmo.skills.blastmining");
}
public boolean fishing(Player player) {
return player.hasPermission("mcmmo.skills.fishing");
}
public boolean woodcutting(Player player) {
return player.hasPermission("mcmmo.skills.woodcutting");
}
public boolean repair(Player player) {
return player.hasPermission("mcmmo.skills.repair");
}
public boolean unarmed(Player player) {
return player.hasPermission("mcmmo.skills.unarmed");
}
public boolean archery(Player player) {
return player.hasPermission("mcmmo.skills.archery");
}
public boolean herbalism(Player player) {
return player.hasPermission("mcmmo.skills.herbalism");
}
public boolean excavation(Player player) {
return player.hasPermission("mcmmo.skills.excavation");
}
public boolean swords(Player player) {
return player.hasPermission("mcmmo.skills.swords");
}
public boolean axes(Player player) {
return player.hasPermission("mcmmo.skills.axes");
}
public boolean acrobatics(Player player) {
return player.hasPermission("mcmmo.skills.acrobatics");
}
}

View File

@ -1,119 +1,121 @@
package com.gmail.nossr50;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Users {
public static String location = mcMMO.usersFile;
public static String directory = mcMMO.flatFileDirectory;
public static String directoryb = mcMMO.leaderboardDirectory;
public static HashMap<String, PlayerProfile> players = new HashMap<String, PlayerProfile>();
/**
* Load users.
*/
public static void loadUsers() {
new File(directory).mkdir();
new File(directoryb).mkdir();
File theDir = new File(location);
if (!theDir.exists()) {
try {
FileWriter writer = new FileWriter(theDir);
writer.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Add a new user.
*
* @param player The player to create a user record for
*/
public static void addUser(Player player) {
if (!players.containsKey(player.getName().toLowerCase())) {
players.put(player.getName().toLowerCase(), new PlayerProfile(player.getName(), true));
}
}
/**
* Clear all users.
*/
public static void clearUsers() {
players.clear();
}
/**
* Get all PlayerProfiles.
*
* @return a HashMap containing the PlayerProfile of everyone in the database
*/
public static HashMap<String, PlayerProfile> getProfiles() {
return players;
}
/**
* Remove a user from the database.
*
* @param player The player to remove
*/
public static void removeUser(Player player) {
//Only remove PlayerProfile if user is offline and we have it in memory
if (!player.isOnline() && players.containsKey(player.getName().toLowerCase())) {
players.get(player.getName().toLowerCase()).save();
players.remove(player.getName().toLowerCase());
}
}
/**
* Remove a user from the DB by name.
*
* @param playerName The name of the player to remove
*/
public static void removeUserByName(String playerName) {
players.remove(playerName.toLowerCase());
}
/**
* Get the profile of a player.
*
* @param player The player whose profile to retrieve
* @return the player's profile
*/
public static PlayerProfile getProfile(OfflinePlayer player) {
return getProfileByName(player.getName());
}
/**
* Get the profile of a player by name.
*
* @param player The name of the player whose profile to retrieve
* @return the player's profile
*/
public static PlayerProfile getProfileByName(String playerName) {
if (mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
if (players.get(playerName.toLowerCase()) != null) {
return players.get(playerName.toLowerCase());
}
else {
players.put(playerName.toLowerCase(), new PlayerProfile(playerName, true));
return players.get(playerName.toLowerCase());
}
}
else {
return new PlayerProfile(playerName, false);
}
}
}
package com.gmail.nossr50.util;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Users {
public static String location = mcMMO.usersFile;
public static String directory = mcMMO.flatFileDirectory;
public static String directoryb = mcMMO.leaderboardDirectory;
public static HashMap<String, PlayerProfile> players = new HashMap<String, PlayerProfile>();
/**
* Load users.
*/
public static void loadUsers() {
new File(directory).mkdir();
new File(directoryb).mkdir();
File theDir = new File(location);
if (!theDir.exists()) {
try {
FileWriter writer = new FileWriter(theDir);
writer.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* Add a new user.
*
* @param player The player to create a user record for
*/
public static void addUser(Player player) {
if (!players.containsKey(player.getName().toLowerCase())) {
players.put(player.getName().toLowerCase(), new PlayerProfile(player.getName(), true));
}
}
/**
* Clear all users.
*/
public static void clearUsers() {
players.clear();
}
/**
* Get all PlayerProfiles.
*
* @return a HashMap containing the PlayerProfile of everyone in the database
*/
public static HashMap<String, PlayerProfile> getProfiles() {
return players;
}
/**
* Remove a user from the database.
*
* @param player The player to remove
*/
public static void removeUser(Player player) {
//Only remove PlayerProfile if user is offline and we have it in memory
if (!player.isOnline() && players.containsKey(player.getName().toLowerCase())) {
players.get(player.getName().toLowerCase()).save();
players.remove(player.getName().toLowerCase());
}
}
/**
* Remove a user from the DB by name.
*
* @param playerName The name of the player to remove
*/
public static void removeUserByName(String playerName) {
players.remove(playerName.toLowerCase());
}
/**
* Get the profile of a player.
*
* @param player The player whose profile to retrieve
* @return the player's profile
*/
public static PlayerProfile getProfile(OfflinePlayer player) {
return getProfileByName(player.getName());
}
/**
* Get the profile of a player by name.
*
* @param player The name of the player whose profile to retrieve
* @return the player's profile
*/
public static PlayerProfile getProfileByName(String playerName) {
if (mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
if (players.get(playerName.toLowerCase()) != null) {
return players.get(playerName.toLowerCase());
}
else {
players.put(playerName.toLowerCase(), new PlayerProfile(playerName, true));
return players.get(playerName.toLowerCase());
}
}
else {
return new PlayerProfile(playerName, false);
}
}
}