This commit is contained in:
GJ 2012-06-05 09:57:10 -04:00
parent 7ada587df3
commit 1cca4de9e5
33 changed files with 107 additions and 85 deletions

View File

@ -46,7 +46,7 @@ public abstract class SkillCommand implements CommandExecutor {
player = (Player) sender; player = (Player) sender;
profile = Users.getProfile(player); profile = Users.getProfile(player);
skillValue = (float) profile.getSkillLevel(skill); skillValue = profile.getSkillLevel(skill);
dataCalculations(); dataCalculations();
permissionsCheck(); permissionsCheck();

View File

@ -61,7 +61,7 @@ public class McrefreshCommand implements CommandExecutor {
return true; return true;
} }
PP.setRecentlyHurt((long) 0); PP.setRecentlyHurt(0);
PP.resetCooldowns(); PP.resetCooldowns();
PP.resetToolPrepMode(); PP.resetToolPrepMode();
PP.resetAbilityMode(); PP.resetAbilityMode();

View File

@ -19,7 +19,7 @@ public class MctopCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
if (!Config.getInstance().getUseMySQL()) { if (!Config.getInstance().getUseMySQL()) {
switch (args.length) { switch (args.length) {

View File

@ -187,7 +187,7 @@ public class PartyCommand implements CommandExecutor {
PlayerProfile PPt = Users.getProfile(target); PlayerProfile PPt = Users.getProfile(target);
String targetName = target.getName(); String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) { if (!partyInstance.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName })); player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true; return true;
} }
@ -219,7 +219,7 @@ public class PartyCommand implements CommandExecutor {
String targetName = target.getName(); String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) { if (!partyInstance.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName })); player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true; return true;
} }

View File

@ -195,7 +195,7 @@ public class Config extends ConfigLoader {
} }
/* Mining */ /* Mining */
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); } public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); } public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); } public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); } public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }

View File

@ -290,7 +290,7 @@ public class HUDmmo {
return; return;
} }
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png"); xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true); xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD))); ((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));

View File

@ -102,9 +102,9 @@ public class PlayerProfile {
public boolean loadMySQL() { public boolean loadMySQL() {
int id = 0; int id = 0;
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'"); id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
this.userid = id; this.userid = id;
if (id > 0) { if (id > 0) {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"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) if(huds.get(1) == null)
@ -204,7 +204,7 @@ public class PlayerProfile {
String[] character = line.split(":"); String[] character = line.split(":");
if(!character[0].equals(playerName)){continue;} if(!character[0].equals(playerName)){continue;}
//Get Mining //Get Mining
if(character.length > 1 && Misc.isInt(character[1])) if(character.length > 1 && Misc.isInt(character[1]))
skills.put(SkillType.MINING, Integer.valueOf(character[1])); skills.put(SkillType.MINING, Integer.valueOf(character[1]));
@ -299,7 +299,7 @@ public class PlayerProfile {
Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds 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()) { if (Config.getInstance().getUseMySQL()) {
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid); mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
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 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()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
@ -440,7 +440,7 @@ public class PlayerProfile {
//Open the file to write the player //Open the file to write the player
FileWriter file = new FileWriter(location, true); FileWriter file = new FileWriter(location, true);
BufferedWriter out = new BufferedWriter(file); BufferedWriter out = new BufferedWriter(file);
//Add the player to the end //Add the player to the end
out.append(playerName + ":"); out.append(playerName + ":");
out.append(0 + ":"); //mining out.append(0 + ":"); //mining
@ -481,7 +481,7 @@ public class PlayerProfile {
out.append(0+":"); //Blast Mining out.append(0+":"); //Blast Mining
//Add more in the same format as the line above //Add more in the same format as the line above
out.newLine(); out.newLine();
out.close(); out.close();
} catch (Exception e) { } catch (Exception e) {
@ -1039,7 +1039,7 @@ public class PlayerProfile {
xp = (int) (xp * tool.getXpMultiplier()); xp = (int) (xp * tool.getXpMultiplier());
} }
} }
if(player.hasPermission("mcmmo.perks.xp.quadruple")) { if(player.hasPermission("mcmmo.perks.xp.quadruple")) {
xp = xp * 4; xp = xp * 4;
} else if (player.hasPermission("mcmmo.perks.xp.triple")) { } else if (player.hasPermission("mcmmo.perks.xp.triple")) {

View File

@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/ /** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }

View File

@ -264,11 +264,11 @@ public class BlockListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) { public void onBlockDamage(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) { if (event instanceof FakeBlockDamageEvent) {
return; return;
} }
final int LEAF_BLOWER_LEVEL = 100; final int LEAF_BLOWER_LEVEL = 100;
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -24,7 +24,7 @@ public class HardcoreListener implements Listener {
if (!Permissions.getInstance().hardcoremodeBypass(player)) { if (!Permissions.getInstance().hardcoremodeBypass(player)) {
if (player.getKiller() instanceof Player) { if (player.getKiller() instanceof Player) {
if (Config.getInstance().getHardcoreVampirismEnabled()) { if (Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(((Player)player.getKiller()), player); Hardcore.invokeVampirism(player.getKiller(), player);
} }
} }

View File

@ -158,13 +158,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
//TODO: Locale ALL the things.
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) { if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
String prefix = ChatColor.GOLD+"[mcMMO] "; String prefix = ChatColor.GOLD+"[mcMMO] ";
String perkPrefix = ChatColor.RED+"[mcMMO Perks] "; String perkPrefix = ChatColor.RED+"[mcMMO Perks] ";
player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
if(Config.getInstance().getHardcoreEnabled()) { if(Config.getInstance().getHardcoreEnabled()) {
if(Config.getInstance().getHardcoreVampirismEnabled()) { if(Config.getInstance().getHardcoreVampirismEnabled()) {
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled."); player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled.");
@ -174,7 +175,7 @@ public class PlayerListener implements Listener {
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%"); player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%");
} }
} }
if(player.hasPermission("mcmmo.perks.xp.quadruple")) { if(player.hasPermission("mcmmo.perks.xp.quadruple")) {
player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Quadruple XP - Receive 4x XP."); player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Quadruple XP - Receive 4x XP.");
} else if (player.hasPermission("mcmmo.perks.xp.triple")) { } else if (player.hasPermission("mcmmo.perks.xp.triple")) {
@ -182,7 +183,7 @@ public class PlayerListener implements Listener {
} else if (player.hasPermission("mcmmo.perks.xp.double")) { } else if (player.hasPermission("mcmmo.perks.xp.double")) {
player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Double XP - Receive 2x XP."); player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Double XP - Receive 2x XP.");
} }
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()})); //player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
//player.sendMessage(LocaleLoader.getString("mcMMO.Website")); //player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
@ -192,8 +193,8 @@ public class PlayerListener implements Listener {
if (XprateCommand.xpevent) { if (XprateCommand.xpevent) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier})); player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
} }
} }
/** /**

View File

@ -46,7 +46,7 @@ public class SpoutListener implements Listener {
if (sPlayer.isSpoutCraftEnabled()) { if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
PPs.toggleSpoutEnabled(); PPs.toggleSpoutEnabled();
} }
} }
@ -60,12 +60,12 @@ public class SpoutListener implements Listener {
public void onButtonClick(ButtonClickEvent event) { public void onButtonClick(ButtonClickEvent event) {
SpoutPlayer sPlayer = event.getPlayer(); SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer); PlayerProfile PP = Users.getProfile(sPlayer);
if (event.getButton() instanceof ButtonHUDStyle) { if (event.getButton() instanceof ButtonHUDStyle) {
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) { if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD(); SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer); SpoutStuff.playerHUDs.remove(sPlayer);
switch (PP.getHUDType()) { switch (PP.getHUDType()) {
case RETRO: case RETRO:
PP.setHUDType(HUDType.STANDARD); PP.setHUDType(HUDType.STANDARD);

View File

@ -76,6 +76,7 @@ public class mcMMO extends JavaPlugin {
/** /**
* Things to be run when the plugin is enabled. * Things to be run when the plugin is enabled.
*/ */
@Override
public void onEnable() { public void onEnable() {
p = this; p = this;
setupFilePaths(); setupFilePaths();
@ -238,6 +239,7 @@ public class mcMMO extends JavaPlugin {
/** /**
* Things to be run when the plugin is disabled. * Things to be run when the plugin is disabled.
*/ */
@Override
public void onDisable() { public void onDisable() {
//Make sure to save player information if the server shuts down //Make sure to save player information if the server shuts down
for (PlayerProfile x : Users.getProfiles().values()) { for (PlayerProfile x : Users.getProfiles().values()) {

View File

@ -74,7 +74,7 @@ public class Party {
* Get the number of players in this player's party. * Get the number of players in this player's party.
* *
* @param player The player to check * @param player The player to check
* @param players A list of players to * @param players A list of players to
* @return the number of players in this player's party * @return the number of players in this player's party
*/ */
public int partyCount(Player player) { public int partyCount(Player player) {

View File

@ -84,7 +84,7 @@ public class BleedTimer implements Runnable {
/** /**
* Instantly Bleed out a LivingEntity * Instantly Bleed out a LivingEntity
* *
* @param entity LivingEntity to bleed out * @param entity LivingEntity to bleed out
*/ */
public static void bleedOut(LivingEntity entity) { public static void bleedOut(LivingEntity entity) {
@ -96,7 +96,7 @@ public class BleedTimer implements Runnable {
/** /**
* Remove a LivingEntity from the bleedList if it is in it * Remove a LivingEntity from the bleedList if it is in it
* *
* @param entity LivingEntity to remove * @param entity LivingEntity to remove
*/ */
public static void remove(LivingEntity entity) { public static void remove(LivingEntity entity) {
@ -168,7 +168,7 @@ public class BleedTimer implements Runnable {
/** /**
* Check to see if a LivingEntity is in the bleedList * Check to see if a LivingEntity is in the bleedList
* *
* @param entity LivingEntity to check if in the bleedList * @param entity LivingEntity to check if in the bleedList
* @return true if in the list, false if not * @return true if in the list, false if not
*/ */

View File

@ -61,7 +61,7 @@ public class Swords {
else { else {
bleedTicks = 2; bleedTicks = 2;
} }
BleedTimer.add(defender, bleedTicks); BleedTimer.add(defender, bleedTicks);
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding")); attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
} }

View File

@ -36,7 +36,7 @@ public class Taming {
* *
* @param PPo The PlayerProfile of the wolf's owner * @param PPo The PlayerProfile of the wolf's owner
* @param theWolf The wolf using the ability * @param theWolf The wolf using the ability
* @param damage The damage being absorbed by the wolf * @param damage The damage being absorbed by the wolf
*/ */
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) { public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) {
final int SKILL_ACTIVATION_LEVEL = 50; final int SKILL_ACTIVATION_LEVEL = 50;

View File

@ -276,7 +276,7 @@ public class Fishing {
case SHEEP: case SHEEP:
Sheep sheep = (Sheep) le; Sheep sheep = (Sheep) le;
if (!sheep.isSheared()) { if (!sheep.isSheared()) {
Wool wool = new Wool(); Wool wool = new Wool();
wool.setColor(sheep.getColor()); wool.setColor(sheep.getColor());

View File

@ -48,10 +48,10 @@ public class Herbalism {
greenTerraConvert(player, block); greenTerraConvert(player, block);
} }
} }
public static void greenTerraConvert(Player player, Block block) { public static void greenTerraConvert(Player player, Block block) {
Material type = block.getType(); Material type = block.getType();
if (Misc.blockBreakSimulate(block, player, false)) { if (Misc.blockBreakSimulate(block, player, false)) {
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) { if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) {
block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update

View File

@ -213,7 +213,7 @@ public class Mining {
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
Material type = block.getType(); Material type = block.getType();
int xp = 0; int xp = 0;
switch (type) { switch (type) {
case COAL_ORE: case COAL_ORE:
xp += Config.getInstance().getMiningXPCoalOre(); xp += Config.getInstance().getMiningXPCoalOre();

View File

@ -100,7 +100,7 @@ public class WoodCutting {
ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData()); ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData());
ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData()); ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData());
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData()); ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData());
for (Block x : toBeFelled) { for (Block x : toBeFelled) {
if (Misc.blockBreakSimulate(x, player, true)) { if (Misc.blockBreakSimulate(x, player, true)) {
if (Config.getInstance().getBlockModsEnabled()) { if (Config.getInstance().getBlockModsEnabled()) {
@ -215,7 +215,7 @@ public class WoodCutting {
*/ */
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) { private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
Material type = currentBlock.getType(); Material type = currentBlock.getType();
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) { if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
return; return;
} }

View File

@ -179,7 +179,7 @@ public class SpoutStuff {
files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png")); files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png"));
files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png")); files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png"));
} }
/* Blank icons */ /* Blank icons */
files.add(new File(hudStandardDirectory + "Icon.png")); files.add(new File(hudStandardDirectory + "Icon.png"));
files.add(new File(hudRetroDirectory + "Icon_r.png")); files.add(new File(hudRetroDirectory + "Icon_r.png"));

View File

@ -113,7 +113,7 @@ public class Combat {
if (permInstance.impact(attacker)) { if (permInstance.impact(attacker)) {
Axes.impact(attacker, target, event); Axes.impact(attacker, target, event);
} }
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) { if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES); applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
} }
@ -319,7 +319,7 @@ public class Combat {
*/ */
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (configInstance.getEventCallbackEnabled()) { if (configInstance.getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg); EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) { if (ede.isCancelled()) {
@ -342,7 +342,7 @@ public class Combat {
*/ */
private static void dealDamage(LivingEntity target, int dmg, Player attacker) { private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (configInstance.getEventCallbackEnabled()) { if (configInstance.getEventCallbackEnabled()) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg); EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede); mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) { if (ede.isCancelled()) {

View File

@ -222,23 +222,23 @@ public class Database {
} }
return result; return result;
} }
/** /**
* Get connection status * Get connection status
* *
* @return the boolean value for whether or not we are connected * @return the boolean value for whether or not we are connected
*/ */
public static boolean isConnected() { public static boolean isConnected() {
if(conn == null) if(conn == null)
return false; return false;
try { try {
return conn.isValid(3); return conn.isValid(3);
} catch (SQLException e) { } catch (SQLException e) {
return false; return false;
} }
} }
/** /**
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed * 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 * This will check for a connection being present or not to prevent unneeded reconnection attempts

View File

@ -11,56 +11,56 @@ public class Hardcore {
public static void invokeStatPenalty(Player player) { public static void invokeStatPenalty(Player player) {
if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0) if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0)
return; return;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
int totalCount = 0; int totalCount = 0;
for(SkillType st : SkillType.values()) { for(SkillType st : SkillType.values()) {
if(st.equals(SkillType.ALL)) if(st.equals(SkillType.ALL))
continue; continue;
int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D))); int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D)));
if(newValue < 0) if(newValue < 0)
newValue = 0; newValue = 0;
totalCount+=PP.getSkillLevel(st)-newValue; totalCount+=PP.getSkillLevel(st)-newValue;
PP.modifySkill(st, newValue); PP.modifySkill(st, newValue);
} }
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death."); player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death.");
} }
public static void invokeVampirism(Player killer, Player defender) { public static void invokeVampirism(Player killer, Player defender) {
if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0) if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0)
return; return;
PlayerProfile PPk = Users.getProfile(killer); PlayerProfile PPk = Users.getProfile(killer);
PlayerProfile PPd = Users.getProfile(defender); PlayerProfile PPd = Users.getProfile(defender);
int totalCount = 0; int totalCount = 0;
for(SkillType st : SkillType.values()) { for(SkillType st : SkillType.values()) {
if(st.equals(SkillType.ALL)) if(st.equals(SkillType.ALL))
continue; continue;
if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2)) if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2))
continue; continue;
int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D)); int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
if(newValue <= 0) if(newValue <= 0)
newValue = 1; newValue = 1;
totalCount+=1; totalCount+=1;
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st)); PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue); PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue);
} }
if(totalCount >= 1) { if(totalCount >= 1) {
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player."); killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player.");
defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!"); defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!");

View File

@ -74,7 +74,7 @@ public class ItemChecks {
* *
* @param is Item to check * @param is Item to check
* @return true if the item is a shovel, false otherwise * @return true if the item is a shovel, false otherwise
*/ */
public static boolean isShovel(ItemStack is) { public static boolean isShovel(ItemStack is) {
switch (is.getType()) { switch (is.getType()) {
case DIAMOND_SPADE: case DIAMOND_SPADE:

View File

@ -116,7 +116,7 @@ public class Metrics {
* The plugin configuration file * The plugin configuration file
*/ */
private final YamlConfiguration configuration; private final YamlConfiguration configuration;
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
@ -225,6 +225,7 @@ public class Metrics {
private boolean firstPost = true; private boolean firstPost = true;
@Override
public void run() { public void run() {
try { try {
// This has to be synchronized or it can collide with the disable method. // This has to be synchronized or it can collide with the disable method.

View File

@ -96,7 +96,7 @@ public class Misc {
return false; return false;
} }
} }
/** /**
* Simulate a block break event. * Simulate a block break event.
* *

View File

@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public class Page { public class Page {
public static int getTotalPageNumber(String address) public static int getTotalPageNumber(String address)
{ {
String[] addressSplit = LocaleLoader.getString(address).split("\n"); String[] addressSplit = LocaleLoader.getString(address).split("\n");
@ -18,24 +18,24 @@ public class Page {
else else
return (addressSplit.length/8)+1; return (addressSplit.length/8)+1;
} }
public static ArrayList<String> grabPageContents(String header, String address, int pagenum) public static ArrayList<String> grabPageContents(String header, String address, int pagenum)
{ {
int pageIndexStart = 0; int pageIndexStart = 0;
//Determine what string to start at //Determine what string to start at
if(pagenum > 1) if(pagenum > 1)
{ {
pageIndexStart = 8*(pagenum-1); pageIndexStart = 8*(pagenum-1);
} }
ArrayList<String> allStrings = new ArrayList<String>(); ArrayList<String> allStrings = new ArrayList<String>();
String split[] = LocaleLoader.getString(address).split("\n"); String split[] = LocaleLoader.getString(address).split("\n");
allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish
//Add targeted strings //Add targeted strings
while(allStrings.size() < 9) while(allStrings.size() < 9)
{ {
if(pageIndexStart+allStrings.size() > split.length) if(pageIndexStart+allStrings.size() > split.length)
@ -43,11 +43,11 @@ public class Page {
else else
allStrings.add(split[pageIndexStart+allStrings.size()-1]); allStrings.add(split[pageIndexStart+allStrings.size()-1]);
} }
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address)); allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
return allStrings; return allStrings;
} }
public static void clearChat(Player player) public static void clearChat(Player player)
{ {
for(int x = 0; x < 20; x++) for(int x = 0; x < 20; x++)
@ -55,7 +55,7 @@ public class Page {
player.sendMessage(""); player.sendMessage("");
} }
} }
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args)
{ {
String capitalized = Misc.getCapitalized(skilltype.toString()); String capitalized = Misc.getCapitalized(skilltype.toString());
@ -64,9 +64,9 @@ public class Page {
{ {
if(args[0].equals("?")) if(args[0].equals("?"))
{ {
String address = "Guides."+capitalized; String address = "Guides."+capitalized;
if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address)) if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
{ {
Page.clearChat(player); Page.clearChat(player);
@ -82,7 +82,7 @@ public class Page {
player.sendMessage(target); player.sendMessage(target);
} }
} }
else if(args.length > 1 && Misc.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. player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale.
} }

View File

@ -20,7 +20,7 @@ public class Users {
* Load users. * Load users.
*/ */
public static void loadUsers() { public static void loadUsers() {
new File(plugin.flatFileDirectory).mkdir(); new File(plugin.flatFileDirectory).mkdir();
new File(plugin.leaderboardDirectory).mkdir(); new File(plugin.leaderboardDirectory).mkdir();

View File

@ -18,6 +18,7 @@ import com.gmail.nossr50.mcMMO;
public class HashChunkletManager implements ChunkletManager { public class HashChunkletManager implements ChunkletManager {
private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>(); private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
@Override
public void chunkLoaded(int cx, int cz, World world) { public void chunkLoaded(int cx, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
File cxDir = new File(dataDir, "" + cx); File cxDir = new File(dataDir, "" + cx);
@ -38,6 +39,7 @@ public class HashChunkletManager implements ChunkletManager {
} }
} }
@Override
public void chunkUnloaded(int cx, int cz, World world) { public void chunkUnloaded(int cx, int cz, World world) {
File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
@ -56,6 +58,7 @@ public class HashChunkletManager implements ChunkletManager {
} }
} }
@Override
public void saveWorld(World world) { public void saveWorld(World world) {
String worldName = world.getName(); String worldName = world.getName();
File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
@ -74,6 +77,7 @@ public class HashChunkletManager implements ChunkletManager {
} }
} }
@Override
public void unloadWorld(World world) { public void unloadWorld(World world) {
saveWorld(world); saveWorld(world);
@ -87,12 +91,14 @@ public class HashChunkletManager implements ChunkletManager {
} }
} }
@Override
public void saveAll() { public void saveAll() {
for(World world : Bukkit.getWorlds()) { for(World world : Bukkit.getWorlds()) {
saveWorld(world); saveWorld(world);
} }
} }
@Override
public void unloadAll() { public void unloadAll() {
saveAll(); saveAll();
for(World world : Bukkit.getWorlds()) { for(World world : Bukkit.getWorlds()) {
@ -100,6 +106,7 @@ public class HashChunkletManager implements ChunkletManager {
} }
} }
@Override
public boolean isTrue(int x, int y, int z, World world) { public boolean isTrue(int x, int y, int z, World world) {
int cx = x / 16; int cx = x / 16;
int cz = z / 16; int cz = z / 16;
@ -114,10 +121,12 @@ public class HashChunkletManager implements ChunkletManager {
return check.isTrue(ix, iy, iz); return check.isTrue(ix, iy, iz);
} }
@Override
public boolean isTrue(Block block) { public boolean isTrue(Block block) {
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
} }
@Override
public void setTrue(int x, int y, int z, World world) { public void setTrue(int x, int y, int z, World world) {
int cx = x / 16; int cx = x / 16;
int cz = z / 16; int cz = z / 16;
@ -137,10 +146,12 @@ public class HashChunkletManager implements ChunkletManager {
cStore.setTrue(ix, iy, iz); cStore.setTrue(ix, iy, iz);
} }
@Override
public void setTrue(Block block) { public void setTrue(Block block) {
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld()); setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
} }
@Override
public void setFalse(int x, int y, int z, World world) { public void setFalse(int x, int y, int z, World world) {
int cx = x / 16; int cx = x / 16;
int cz = z / 16; int cz = z / 16;
@ -159,10 +170,12 @@ public class HashChunkletManager implements ChunkletManager {
cStore.setFalse(ix, iy, iz); cStore.setFalse(ix, iy, iz);
} }
@Override
public void setFalse(Block block) { public void setFalse(Block block) {
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld()); setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
} }
@Override
public void cleanUp() { public void cleanUp() {
for(String key : store.keySet()) { for(String key : store.keySet()) {
if(store.get(key).isEmpty()) { if(store.get(key).isEmpty()) {

View File

@ -6,18 +6,22 @@ public class PrimitiveChunkletStore implements ChunkletStore {
/** X, Z, Y */ /** X, Z, Y */
private boolean[][][] store = new boolean[16][16][64]; private boolean[][][] store = new boolean[16][16][64];
@Override
public boolean isTrue(int x, int y, int z) { public boolean isTrue(int x, int y, int z) {
return store[x][z][y]; return store[x][z][y];
} }
@Override
public void setTrue(int x, int y, int z) { public void setTrue(int x, int y, int z) {
store[x][z][y] = true; store[x][z][y] = true;
} }
@Override
public void setFalse(int x, int y, int z) { public void setFalse(int x, int y, int z) {
store[x][z][y] = false; store[x][z][y] = false;
} }
@Override
public boolean isEmpty() { public boolean isEmpty() {
for(int x = 0; x < 16; x++) { for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) { for(int z = 0; z < 16; z++) {

View File

@ -120,7 +120,7 @@ public class ZipLibrary {
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
byte[] buffer = new byte[4092]; byte[] buffer = new byte[4092];
int byteCount = 0; int byteCount = 0;
while ((byteCount = fis.read(buffer)) != -1) { while ((byteCount = fis.read(buffer)) != -1) {
zos.write(buffer, 0, byteCount); zos.write(buffer, 0, byteCount);
} }