Misc. cleanup, removed old Logger.getLogger stuff.

Logger.getLogger() replaced with Bukkit.getLogger()
This commit is contained in:
GJ 2012-03-12 17:28:13 -04:00
parent 787ee0220a
commit 49bb3e0a3c
19 changed files with 413 additions and 361 deletions

View File

@ -9,19 +9,19 @@ import java.util.HashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
import org.bukkit.Bukkit;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.DatabaseUpdate; import com.gmail.nossr50.datatypes.DatabaseUpdate;
public class Database { public class Database {
private mcMMO plugin;
private String connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass; private String connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass;
private boolean isConnected; private boolean isConnected;
private Connection conn = null; private Connection conn = null;
public Database(mcMMO instance) { public Database(mcMMO instance) {
connect(); //Connect to MySQL connect(); //Connect to MySQL
this.plugin = instance;
// Load the driver instance // Load the driver instance
try { try {
@ -29,10 +29,10 @@ public class Database {
DriverManager.getConnection(connectionString); DriverManager.getConnection(connectionString);
} }
catch (ClassNotFoundException e) { catch (ClassNotFoundException e) {
plugin.getServer().getLogger().warning(e.getLocalizedMessage()); Bukkit.getLogger().warning(e.getLocalizedMessage());
} }
catch (SQLException ex) { catch (SQLException ex) {
plugin.getServer().getLogger().warning(ex.getLocalizedMessage()); Bukkit.getLogger().warning(ex.getLocalizedMessage());
printErrors(ex); printErrors(ex);
} }
} }

View File

@ -6,8 +6,8 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger; import org.bukkit.Bukkit;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerStat; import com.gmail.nossr50.datatypes.PlayerStat;
@ -16,7 +16,6 @@ import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard { public class Leaderboard {
static String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users"; static String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
protected static final Logger log = Logger.getLogger("Minecraft");
/** /**
* Create the leaderboards. * Create the leaderboards.
@ -122,7 +121,7 @@ public class Leaderboard {
in.close(); in.close();
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe(("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString()));
} }
//Write the leader board files //Write the leader board files
@ -159,7 +158,7 @@ public class Leaderboard {
writer = new FileWriter(theLocation); writer = new FileWriter(theLocation);
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while creating " + theLocation, e); Bukkit.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
} }
finally { finally {
try { try {
@ -168,7 +167,7 @@ public class Leaderboard {
} }
} }
catch (IOException e) { catch (IOException e) {
log.log(Level.SEVERE, "Exception while closing writer for " + theLocation, e); Bukkit.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
} }
} }
} }
@ -197,7 +196,7 @@ public class Leaderboard {
out.close(); out.close();
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
} }
} }
} }
@ -234,7 +233,7 @@ public class Leaderboard {
return info; return info;
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
} }
return null; //Shouldn't get here return null; //Shouldn't get here
@ -286,7 +285,7 @@ public class Leaderboard {
out.close(); out.close();
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
} }
} }
} }

View File

@ -1,7 +1,8 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import java.io.*; import java.io.File;
import java.util.logging.Logger; import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -9,7 +10,6 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
public class Users { public class Users {
private static volatile Users instance; private static volatile Users instance;
protected static final Logger log = Logger.getLogger("Minecraft");
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users"; String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
String directory = "plugins/mcMMO/FlatFileStuff/"; String directory = "plugins/mcMMO/FlatFileStuff/";

View File

@ -1,8 +1,5 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -17,11 +14,8 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class ACommand implements CommandExecutor { public class ACommand implements CommandExecutor {
private Logger log;
public ACommand() { public ACommand() {}
this.log = Logger.getLogger("Minecraft");
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -35,7 +29,7 @@ public class ACommand implements CommandExecutor {
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
log.log(Level.INFO, "[A]<*Console*> " + aMessage); Bukkit.getLogger().info("[A]<*Console*> " + aMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
@ -64,7 +58,7 @@ public class ACommand implements CommandExecutor {
String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName(); String name = (LoadProperties.aDisplayNames) ? player.getDisplayName() : player.getName();
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} "; String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + name + ChatColor.AQUA + "} ";
log.log(Level.INFO, "[A]<" + name + "> " + aMessage); Bukkit.getLogger().info("[A]<" + name + "> " + aMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
herp.sendMessage(aPrefix + aMessage); herp.sendMessage(aPrefix + aMessage);
@ -83,10 +77,8 @@ public class ACommand implements CommandExecutor {
if (PP.getAdminChatMode()) { if (PP.getAdminChatMode()) {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn")); player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.GREEN + "On");
} else { } else {
player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff")); player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff"));
// player.sendMessage(ChatColor.AQUA + "Admin chat toggled " + ChatColor.RED + "Off");
} }
} }
return true; return true;

View File

@ -1,8 +1,5 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -18,11 +15,7 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
public class PCommand implements CommandExecutor { public class PCommand implements CommandExecutor {
private Logger log; public PCommand() {}
public PCommand() {
this.log = Logger.getLogger("Minecraft");
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -38,7 +31,7 @@ public class PCommand implements CommandExecutor {
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") "; String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
log.log(Level.INFO, "[P](" + args[0] + ")" + "<*Console*> " + pMessage); Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (Users.getProfile(herp).inParty()) { if (Users.getProfile(herp).inParty()) {
@ -73,7 +66,7 @@ public class PCommand implements CommandExecutor {
String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName(); String name = (LoadProperties.pDisplayNames) ? player.getDisplayName() : player.getName();
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") "; String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + name + ChatColor.GREEN + ") ";
log.log(Level.INFO, "[P](" + PP.getParty() + ")<" + name + "> " + pMessage); Bukkit.getLogger().info("[P](" + PP.getParty() + ")<" + name + "> " + pMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) { for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
if (Users.getProfile(herp).inParty()) { if (Users.getProfile(herp).inParty()) {
@ -91,10 +84,8 @@ public class PCommand implements CommandExecutor {
PP.togglePartyChat(); PP.togglePartyChat();
if (PP.getPartyChatMode()) { if (PP.getPartyChatMode()) {
// player.sendMessage(ChatColor.GREEN + "Party Chat Toggled On");
player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOn")); player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOn"));
} else { } else {
// player.sendMessage(ChatColor.GREEN + "Party Chat Toggled " + ChatColor.RED + "Off");
player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOff")); player.sendMessage(mcLocale.getString("mcPlayerListener.PartyChatOff"));
} }

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import com.gmail.nossr50.datatypes.HUDType; import com.gmail.nossr50.datatypes.HUDType;
@ -123,7 +124,7 @@ public class LoadProperties {
} }
private void loadKeys() { private void loadKeys() {
plugin.getLogger().info("Loading mcMMO config.yml File..."); plugin.getLogger().info("Loading mcMMO config.yml File...");
// Setup default HUD // Setup default HUD
String temp = readString("Spout.HUD.Default", "STANDARD"); String temp = readString("Spout.HUD.Default", "STANDARD");

View File

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -210,7 +211,7 @@ public class LoadTreasures {
if(issues.isEmpty()) return true; if(issues.isEmpty()) return true;
for(String issue : issues) { for(String issue : issues) {
plugin.getLogger().warning(issue); Bukkit.getLogger().warning(issue);
} }
return false; return false;

View File

@ -1,7 +1,8 @@
package com.gmail.nossr50.config; package com.gmail.nossr50.config;
import java.util.*; import java.util.ArrayList;
import java.util.logging.Logger; import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -14,8 +15,6 @@ public class Misc
{ {
String location = "mcmmo.properties"; String location = "mcmmo.properties";
protected static final Logger log = Logger.getLogger("Minecraft");
public ArrayList<Integer> mobSpawnerList = new ArrayList<Integer>(); public ArrayList<Integer> mobSpawnerList = new ArrayList<Integer>();
public HashSet<Block> blockWatchList = new HashSet<Block>(); public HashSet<Block> blockWatchList = new HashSet<Block>();
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>(); public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();

View File

@ -6,8 +6,6 @@ import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.util.HashMap; import java.util.HashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -21,8 +19,6 @@ import com.gmail.nossr50.mcMMO;
public class PlayerProfile public class PlayerProfile
{ {
protected final Logger log = Logger.getLogger("Minecraft");
//HUD //HUD
private HUDType hud; private HUDType hud;
@ -317,8 +313,7 @@ public class PlayerProfile
} }
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
+ location + " (Are you sure you formatted it correctly?)", e);
} }
return false; return false;
} }
@ -440,7 +435,7 @@ public class PlayerProfile
out.write(writer.toString()); out.write(writer.toString());
out.close(); out.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
} }
} }
} }
@ -518,7 +513,7 @@ public class PlayerProfile
out.newLine(); out.newLine();
out.close(); out.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
} }
} }
public void togglePartyHUD() public void togglePartyHUD()

View File

@ -1,8 +1,5 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -47,7 +44,6 @@ import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming; import com.gmail.nossr50.skills.Taming;
public class mcPlayerListener implements Listener { public class mcPlayerListener implements Listener {
protected static final Logger log = Logger.getLogger("Minecraft");
private mcMMO plugin; private mcMMO plugin;
public mcPlayerListener(mcMMO instance) { public mcPlayerListener(mcMMO instance) {
@ -333,7 +329,7 @@ public class mcPlayerListener implements Listener {
} }
} }
log.log(Level.INFO, logHeader + name + ">" + event.getMessage()); Bukkit.getLogger().info(logHeader + name + ">" + event.getMessage());
} }
} }

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50; package com.gmail.nossr50;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -19,7 +17,6 @@ import com.gmail.nossr50.runnables.SQLConversionTask;
import com.gmail.nossr50.skills.Repair; import com.gmail.nossr50.skills.Repair;
public class m { public class m {
public static final Logger log = Logger.getLogger("Minecraft");
/** /**
* Gets a capitalized version of the target string. * Gets a capitalized version of the target string.
@ -250,6 +247,15 @@ public class m {
return; return;
} }
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(log), 1); Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(), 1);
}
public static int skillCheck(int skillLevel, int maxLevel) {
if (skillLevel > maxLevel) {
return maxLevel;
}
else {
return skillLevel;
}
} }
} }

View File

@ -30,8 +30,6 @@ import java.io.InputStream;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -50,7 +48,6 @@ public class mcMMO extends JavaPlugin {
public static String maindirectory = "plugins" + File.separator + "mcMMO"; public static String maindirectory = "plugins" + File.separator + "mcMMO";
public static File file = new File(maindirectory + File.separator + "config.yml"); public static File file = new File(maindirectory + File.separator + "config.yml");
public static File versionFile = new File(maindirectory + File.separator + "VERSION"); public static File versionFile = new File(maindirectory + File.separator + "VERSION");
public static final Logger log = Logger.getLogger("Minecraft");
private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcPlayerListener playerListener = new mcPlayerListener(this);
private final mcBlockListener blockListener = new mcBlockListener(this); private final mcBlockListener blockListener = new mcBlockListener(this);
@ -276,7 +273,7 @@ public class mcMMO extends JavaPlugin {
in.close(); in.close();
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
} }
return parties; return parties;
} }
@ -572,7 +569,7 @@ public class mcMMO extends JavaPlugin {
treasuresConfig.save(treasuresConfigFile); treasuresConfig.save(treasuresConfigFile);
} }
catch (IOException ex) { catch (IOException ex) {
log.log(Level.SEVERE, "Could not save config to " + treasuresConfigFile, ex); Bukkit.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
} }
} }
} }

View File

@ -377,7 +377,7 @@ public class Party
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile)); ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPlayersFile));
this.partyPlayers = (HashMap<String, HashMap<String, Boolean>>)obj.readObject(); this.partyPlayers = (HashMap<String, HashMap<String, Boolean>>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { mcMMO.log.info("partyPlayersFile empty."); } catch (EOFException e) { Bukkit.getLogger().info("partyPlayersFile empty.");
} catch (IOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); }
} }
@ -387,7 +387,7 @@ public class Party
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile)); ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyLocksFile));
this.partyLocks = (HashMap<String, Boolean>)obj.readObject(); this.partyLocks = (HashMap<String, Boolean>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { mcMMO.log.info("partyLocksFile empty."); } catch (EOFException e) { Bukkit.getLogger().info("partyLocksFile empty.");
} catch (IOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); }
} }
@ -397,7 +397,7 @@ public class Party
ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile)); ObjectInputStream obj = new ObjectInputStream(new FileInputStream(partyPasswordsFile));
this.partyPasswords = (HashMap<String, String>)obj.readObject(); this.partyPasswords = (HashMap<String, String>)obj.readObject();
} catch (FileNotFoundException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace();
} catch (EOFException e) { mcMMO.log.info("partyPasswordsFile empty."); } catch (EOFException e) { Bukkit.getLogger().info("partyPasswordsFile empty.");
} catch (IOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace();
} catch (ClassNotFoundException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); }
} }

View File

@ -2,19 +2,15 @@ package com.gmail.nossr50.runnables;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileReader; import java.io.FileReader;
import java.util.logging.Level;
import java.util.logging.Logger; import org.bukkit.Bukkit;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
public class SQLConversionTask implements Runnable { public class SQLConversionTask implements Runnable {
private Logger log; public SQLConversionTask() {}
public SQLConversionTask(Logger log) {
this.log = log;
}
@Override @Override
public void run() { public void run() {
@ -282,7 +278,7 @@ public class SQLConversionTask implements Runnable {
in.close(); in.close();
} }
catch (Exception e) { catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " + location + " (Are you sure you formatted it correctly?)", e); Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
} }
} }
} }

View File

@ -5,6 +5,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
@ -96,11 +97,7 @@ public class Acrobatics {
if (mcPermissions.getInstance().acrobatics(defender)) { if (mcPermissions.getInstance().acrobatics(defender)) {
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS); int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
int skillCheck = skillLevel; int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (skillLevel > MAX_BONUS_LEVEL) {
skillCheck = MAX_BONUS_LEVEL;
}
if (Math.random() * 4000 <= skillCheck) { if (Math.random() * 4000 <= skillCheck) {
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge")); defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));

View File

@ -56,6 +56,8 @@ public class Archery {
if (Math.random() * 100 <= IGNITION_CHANCE) { if (Math.random() * 100 <= IGNITION_CHANCE) {
int ignition = 20; int ignition = 20;
/* Add 20 ticks for every 200 skill levels */
ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20; ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20;
if (ignition > MAX_IGNITION_TICKS) { if (ignition > MAX_IGNITION_TICKS) {
@ -89,7 +91,7 @@ public class Archery {
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY); int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
Location loc = defender.getLocation(); Location loc = defender.getLocation();
int skillCheck = skillLevel; int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (Math.random() * 10 > 5) { if (Math.random() * 10 > 5) {
loc.setPitch(90); loc.setPitch(90);
@ -98,10 +100,6 @@ public class Archery {
loc.setPitch(-90); loc.setPitch(-90);
} }
if (skillLevel > MAX_BONUS_LEVEL) {
skillCheck = MAX_BONUS_LEVEL;
}
if (Math.random() * 2000 <= skillCheck) { if (Math.random() * 2000 <= skillCheck) {
defender.teleport(loc); defender.teleport(loc);
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));

View File

@ -1,118 +1,159 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import org.bukkit.Material; import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.ItemChecks;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
public class Axes { public class Axes {
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event)
{ /**
* Apply bonus to damage done by axes.
*
* @param attacker The attacking player
* @param event The event to modify
*/
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) {
final int MAX_BONUS = 4;
int bonus = 0; int bonus = 0;
//Add 1 DMG for every 50 skill levels /* Add 1 DMG for every 50 skill levels */
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/50; bonus += Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / 50;
if(bonus > 4) if (bonus > MAX_BONUS) {
bonus = 4; bonus = MAX_BONUS;
}
event.setDamage(event.getDamage() + bonus); event.setDamage(event.getDamage() + bonus);
} }
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event)
{
Entity x = event.getEntity();
if(x instanceof Wolf){ /**
Wolf wolf = (Wolf)x; * Check for critical chances on axe damage.
if(wolf.getOwner() instanceof Player) *
{ * @param attacker The attacking player
Player owner = (Player) wolf.getOwner(); * @param event The event to modify
if(owner == attacker) */
return; public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) {
if(Party.getInstance().inSameParty(attacker, owner)) Entity entity = event.getEntity();
return;
} if (entity instanceof Wolf) {
} Wolf wolf = (Wolf) entity;
PlayerProfile PPa = Users.getProfile(attacker);
if(ItemChecks.isAxe(attacker.getItemInHand()) && mcPermissions.getInstance().axes(attacker)){ if (wolf.isTamed()) {
if(PPa.getSkillLevel(SkillType.AXES) >= 750){ AnimalTamer tamer = wolf.getOwner();
if(Math.random() * 2000 <= 750 && !x.isDead()){
if(x instanceof Player){ if (tamer instanceof Player) {
int damage = (event.getDamage() * 2) - (event.getDamage() / 2); Player owner = (Player) tamer;
event.setDamage(damage);
Player player = (Player)x; if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
player.sendMessage(mcLocale.getString("Axes.HitCritically")); return;
} }
else { }
int damage = event.getDamage() * 2; }
event.setDamage(damage); }
}
attacker.sendMessage(mcLocale.getString("Axes.CriticalHit")); final int MAX_BONUS_LEVEL = 750;
} final double PVP_MODIFIER = 1.5;
} else if(Math.random() * 2000 <= PPa.getSkillLevel(SkillType.AXES) && !x.isDead()){ final int PVE_MODIFIER = 2;
if(x instanceof Player){
int damage = (event.getDamage() * 2) - (event.getDamage() / 2); PlayerProfile PPa = Users.getProfile(attacker);
event.setDamage(damage); int skillLevel = PPa.getSkillLevel(SkillType.AXES);
Player player = (Player)x; int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
player.sendMessage(mcLocale.getString("Axes.HitCritically"));
} if (Math.random() * 2000 <= skillCheck && !entity.isDead()){
else { int damage = event.getDamage();
int damage = event.getDamage() * 2;
event.setDamage(damage); if (entity instanceof Player){
} event.setDamage((int) (damage * PVP_MODIFIER));
attacker.sendMessage(mcLocale.getString("Axes.CriticalHit")); Player player = (Player) entity;
} player.sendMessage(mcLocale.getString("Axes.HitCritically"));
} }
else {
event.setDamage(damage * PVE_MODIFIER);
}
attacker.sendMessage(mcLocale.getString("Axes.CriticalHit"));
}
} }
public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) /**
{ * Check for Impact ability.
//TODO: Finish this skill, the idea is you will greatly damage an opponents armor and when they are armor less you have a proc that will stun them and deal additional damage. *
if(target instanceof Player) * @param attacker The attacking player
{ * @param target The defending entity
Player targetPlayer = (Player) target; * @param event The event to modify
int emptySlots = 0; */
short durDmg = 5; //Start with 5 durability dmg public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
durDmg+=Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/30; //Every 30 Skill Levels you gain 1 durability dmg /*
* TODO: Finish this skill. The idea is you will greatly damage an opponents armor.
* When they are unarmored, you have a proc that will stun them and deal additional damage.
*/
if (target instanceof Player) {
Player targetPlayer = (Player) target;
short durabilityDamage = 5; //Start with 5 durability damage
for(ItemStack x : targetPlayer.getInventory().getArmorContents()) /* Every 30 Skill Levels you gain 1 durability damage */
{ durabilityDamage += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/30;
if(x.getType() == Material.AIR)
{
emptySlots++;
} else {
x.setDurability((short) (x.getDurability()+durDmg)); //Damage armor piece
}
}
if(emptySlots == 4) if (!hasArmor(targetPlayer)) {
applyImpact(attacker, target, event); applyImpact(attacker, target, event);
} }
else else {
//Since mobs are technically unarmored this will always trigger for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
applyImpact(attacker, target, event); armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
} }
targetPlayer.updateInventory();
}
}
else {
applyImpact(attacker, target, event); //Since mobs are technically unarmored, this will always trigger
}
}
public static void applyImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) /**
{ * Apply impact ability.
if(Math.random() * 100 > 75) *
{ * @param attacker The attacking player
event.setDamage(event.getDamage()+2); * @param target The defending entity
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(1.5D)); * @param event The event to modify
*/
private static void applyImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
final int GREATER_IMPACT_CHANCE = 25;
final double GREATER_IMPACT_MULTIPLIER = 1.5;
if (Math.random() * 100 <= GREATER_IMPACT_CHANCE) {
event.setDamage(event.getDamage() + 2);
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy")); attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy"));
} }
} }
/**
* Check if a player has armor.
*
* @param player Player whose armor to check
* @return true if the player has armor, false otherwise
*/
private static boolean hasArmor(Player player) {
PlayerInventory inventory = player.getInventory();
if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) {
return true;
}
else {
return false;
}
}
} }

View File

@ -23,186 +23,233 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
public class BlastMining{ public class BlastMining {
/** /**
* Handler for what blocks drop from the explosion. * Handler for what blocks drop from the explosion.
* *
* @param ores List of ore blocks destroyed by the explosion * @param ores List of ore blocks destroyed by the explosion
* @param debris List of non-ore blocks destroyed by the explosion * @param debris List of non-ore blocks destroyed by the explosion
* @param yield Percentage of blocks to drop * @param yield Percentage of blocks to drop
* @param oreBonus Percentage bonus for ore drops * @param oreBonus Percentage bonus for ore drops
* @param debrisReduction Percentage reduction for non-ore drops * @param debrisReduction Percentage reduction for non-ore drops
* @param extraDrops Number of times to drop each block * @param extraDrops Number of times to drop each block
* @param plugin mcMMO plugin instance * @param plugin mcMMO plugin instance
* @return A list of blocks dropped from the explosion * @return A list of blocks dropped from the explosion
*/ */
private static List<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, int extraDrops, mcMMO plugin) private static List<Block> explosionYields(List<Block> ores, List<Block> debris, float yield, float oreBonus, float debrisReduction, int extraDrops, mcMMO plugin) {
{ Iterator<Block> iterator2 = ores.iterator();
Iterator<Block> iterator2 = ores.iterator(); List<Block> blocksDropped = new ArrayList<Block>();
List<Block> blocksDropped = new ArrayList<Block>();
while(iterator2.hasNext())
{
Block temp = iterator2.next();
if((float)Math.random() < (yield + oreBonus))
{
blocksDropped.add(temp);
Mining.miningDrops(temp);
if(temp.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(temp))
{
if(extraDrops == 2)
{
blocksDropped.add(temp);
Mining.miningDrops(temp);
}
if(extraDrops == 3)
{
blocksDropped.add(temp);
Mining.miningDrops(temp);
}
}
}
}
if(yield - debrisReduction != 0) while (iterator2.hasNext()) {
{ Block temp = iterator2.next();
Iterator<Block> iterator3 = debris.iterator();
while(iterator3.hasNext())
{
Block temp = iterator3.next();
if((float)Math.random() < (yield - debrisReduction))
Mining.miningDrops(temp);
}
}
return blocksDropped;
}
/** if ((float) Math.random() < (yield + oreBonus)) {
* Handler for explosion drops and XP gain. blocksDropped.add(temp);
* @param player Player triggering the explosion Mining.miningDrops(temp);
* @param event Event whose explosion is being processed
* @param plugin mcMMO plugin instance
*/
public static void dropProcessing(Player player, EntityExplodeEvent event, mcMMO plugin)
{
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
float yield = event.getYield();
List<Block> blocks = event.blockList();
Iterator<Block> iterator = blocks.iterator();
List<Block> ores = new ArrayList<Block>(); if (temp.getData() != (byte) 0x5 && !plugin.misc.blockWatchList.contains(temp)) {
List<Block> debris = new ArrayList<Block>(); if (extraDrops == 2) {
List<Block> xp = new ArrayList<Block>(); blocksDropped.add(temp);
Mining.miningDrops(temp);
}
if (extraDrops == 3) {
blocksDropped.add(temp);
Mining.miningDrops(temp);
}
}
}
}
while(iterator.hasNext()) if (yield - debrisReduction != 0) {
{ Iterator<Block> iterator3 = debris.iterator();
Block temp = iterator.next();
if(BlockChecks.isOre(temp.getType()))
ores.add(temp);
else
debris.add(temp);
}
//Normal explosion while (iterator3.hasNext()) {
if(skillLevel < 125) Block temp = iterator3.next();
return;
event.setYield(0); if ((float) Math.random() < (yield - debrisReduction))
Mining.miningDrops(temp);
}
}
//+35% ores, -10% debris return blocksDropped;
if(skillLevel >= 125 && skillLevel < 250) }
xp = explosionYields(ores, debris, yield, .35f, .10f, 1, plugin);
//+40% ores, -20% debris /**
if(skillLevel >= 250 && skillLevel < 375) * Handler for explosion drops and XP gain.
xp = explosionYields(ores, debris, yield, .40f, .20f, 1, plugin); *
* @param player Player triggering the explosion
* @param event Event whose explosion is being processed
* @param plugin mcMMO plugin instance
*/
public static void dropProcessing(Player player, EntityExplodeEvent event, mcMMO plugin) {
final int RANK_1_LEVEL = 125;
final int RANK_2_LEVEL = 250;
final int RANK_3_LEVEL = 375;
final int RANK_4_LEVEL = 500;
final int RANK_5_LEVEL = 625;
final int RANK_6_LEVEL = 750;
final int RANK_7_LEVEL = 875;
final int RANK_8_LEVEL = 1000;
//No debris, +45% ores int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
if(skillLevel >= 375 && skillLevel < 500) float yield = event.getYield();
xp = explosionYields(ores, debris, yield, .45f, .30f, 1, plugin); List<Block> blocks = event.blockList();
Iterator<Block> iterator = blocks.iterator();
//No debris, +50% ores List<Block> ores = new ArrayList<Block>();
if(skillLevel >= 500 && skillLevel < 625) List<Block> debris = new ArrayList<Block>();
xp = explosionYields(ores, debris, yield, .50f, .30f, 1, plugin); List<Block> xp = new ArrayList<Block>();
//Double Drops, No Debris, +55% ores while (iterator.hasNext()) {
if(skillLevel >= 625 && skillLevel < 750) Block temp = iterator.next();
xp = explosionYields(ores, debris, yield, .55f, .30f, 2, plugin);
//Double Drops, No Debris, +60% ores if (BlockChecks.isOre(temp.getType())) {
if(skillLevel >= 750 && skillLevel < 875) ores.add(temp);
xp = explosionYields(ores, debris, yield, .60f, .30f, 2, plugin); }
else {
debris.add(temp);
}
}
//Triple Drops, No debris, +65% ores //Normal explosion
if(skillLevel >= 875 && skillLevel < 1000) if (skillLevel < RANK_1_LEVEL) {
xp = explosionYields(ores, debris, yield, .65f, .30f, 3, plugin); return;
}
//Triple Drops, No debris, +70% ores event.setYield(0);
if(skillLevel >= 1000)
xp = explosionYields(ores, debris, yield, .70f, .30f, 3, plugin);
for(Block block : xp) //Triple Drops, No debris, +70% ores
{ if (skillLevel >= RANK_8_LEVEL) {
if(block.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(block)) xp = explosionYields(ores, debris, yield, .70f, .30f, 3, plugin);
Mining.miningXP(player, block); }
}
} //Triple Drops, No debris, +65% ores
else if (skillLevel >= RANK_7_LEVEL) {
xp = explosionYields(ores, debris, yield, .65f, .30f, 3, plugin);
}
/** //Double Drops, No Debris, +60% ores
* Increases the blast radius of the explosion. else if (skillLevel >= RANK_6_LEVEL) {
* xp = explosionYields(ores, debris, yield, .60f, .30f, 2, plugin);
* @param player Player triggering the explosion }
* @param event Event whose explosion radius is being changed
*/
public static void biggerBombs(Player player, ExplosionPrimeEvent event)
{
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
float radius = event.getRadius();
if(skillLevel < 250)
return;
if(skillLevel >= 250)
radius++;
if(skillLevel >= 500)
radius++;
if(skillLevel >= 750)
radius++;
if(skillLevel >= 1000)
radius++;
event.setRadius(radius);
}
/** //Double Drops, No Debris, +55% ores
* Decreases damage dealt by the explosion. else if (skillLevel >= RANK_5_LEVEL) {
* xp = explosionYields(ores, debris, yield, .55f, .30f, 2, plugin);
* @param player Player triggering the explosion }
* @param event Event whose explosion damage is being reduced
*/ //No debris, +50% ores
public static void demolitionsExpertise(Player player, EntityDamageEvent event) else if (skillLevel >= RANK_4_LEVEL) {
{ xp = explosionYields(ores, debris, yield, .50f, .30f, 1, plugin);
int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING); }
int damage = event.getDamage();
if(skill < 500) //No debris, +45% ores
return; else if (skillLevel >= RANK_3_LEVEL) {
if(skill >= 500 && skill < 750) xp = explosionYields(ores, debris, yield, .45f, .30f, 1, plugin);
damage = damage/4; }
if(skill >= 750 && skill < 1000)
damage = damage/2; //+40% ores, -20% debris
if(skill >= 1000) else if (skillLevel >= RANK_2_LEVEL) {
damage = 0; xp = explosionYields(ores, debris, yield, .40f, .20f, 1, plugin);
event.setDamage(damage); }
}
//+35% ores, -10% debris
else if (skillLevel >= RANK_1_LEVEL) {
xp = explosionYields(ores, debris, yield, .35f, .10f, 1, plugin);
}
for (Block block : xp) {
if (block.getData() != (byte)5 && !plugin.misc.blockWatchList.contains(block)) {
Mining.miningXP(player, block);
}
}
}
/**
* Increases the blast radius of the explosion.
*
* @param player Player triggering the explosion
* @param event Event whose explosion radius is being changed
*/
public static void biggerBombs(Player player, ExplosionPrimeEvent event) {
final int RANK_1_LEVEL = 250;
final int RANK_2_LEVEL = 500;
final int RANK_3_LEVEL = 750;
final int RANK_4_LEVEL = 1000;
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
float radius = event.getRadius();
if (skillLevel < RANK_1_LEVEL) {
return;
}
if (skillLevel >= RANK_1_LEVEL) {
radius++;
}
if (skillLevel >= RANK_2_LEVEL) {
radius++;
}
if (skillLevel >= RANK_3_LEVEL) {
radius++;
}
if (skillLevel >= RANK_4_LEVEL) {
radius++;
}
event.setRadius(radius);
}
/**
* Decreases damage dealt by the explosion.
*
* @param player Player triggering the explosion
* @param event Event whose explosion damage is being reduced
*/
public static void demolitionsExpertise(Player player, EntityDamageEvent event) {
final int RANK_1_LEVEL = 500;
final int RANK_2_LEVEL = 750;
final int RANK_3_LEVEL = 1000;
int skill = Users.getProfile(player).getSkillLevel(SkillType.MINING);
int damage = event.getDamage();
if (skill < RANK_1_LEVEL) {
return;
}
if (skill >= RANK_3_LEVEL) {
damage = 0;
}
else if (skill >= RANK_2_LEVEL) {
damage = damage / 2;
}
else if (skill >= RANK_1_LEVEL) {
damage = damage/4;
}
event.setDamage(damage);
}
public static void remoteDetonation(Player player, mcMMO plugin) { public static void remoteDetonation(Player player, mcMMO plugin) {
final byte SNOW = 78;
final byte AIR = 0;
final int BLOCKS_AWAY = 100;
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
HashSet<Byte> transparent = new HashSet<Byte>(); HashSet<Byte> transparent = new HashSet<Byte>();
transparent.add((byte) 78); //SNOW transparent.add(SNOW);
transparent.add((byte) 0); //AIR transparent.add(AIR);
Block b = player.getTargetBlock(transparent, 100); Block block = player.getTargetBlock(transparent, BLOCKS_AWAY);
if(b.getType().equals(Material.TNT) && m.blockBreakSimulate(b, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) { if (block.getType().equals(Material.TNT) && m.blockBreakSimulate(block, player, true) && PP.getSkillLevel(SkillType.MINING) >= 125) {
final int MAX_DISTANCE_AWAY = 10;
AbilityType ability = AbilityType.BLAST_MINING; AbilityType ability = AbilityType.BLAST_MINING;
/* Check Cooldown */ /* Check Cooldown */
@ -213,7 +260,7 @@ public class BlastMining{
/* Send message to nearby players */ /* Send message to nearby players */
for(Player y : player.getWorld().getPlayers()) { for(Player y : player.getWorld().getPlayers()) {
if(y != player && m.isNear(player.getLocation(), y.getLocation(), 10)) { if(y != player && m.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
y.sendMessage(ability.getAbilityPlayer(player)); y.sendMessage(ability.getAbilityPlayer(player));
} }
} }
@ -221,9 +268,9 @@ public class BlastMining{
player.sendMessage(mcLocale.getString("BlastMining.Boom")); player.sendMessage(mcLocale.getString("BlastMining.Boom"));
/* Create the TNT entity */ /* Create the TNT entity */
TNTPrimed tnt = player.getWorld().spawn(b.getLocation(), TNTPrimed.class); TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
plugin.misc.tntTracker.put(tnt.getEntityId(), player); plugin.misc.tntTracker.put(tnt.getEntityId(), player);
b.setType(Material.AIR); block.setType(Material.AIR);
tnt.setFuseTicks(0); tnt.setFuseTicks(0);
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -27,8 +25,6 @@ import com.gmail.nossr50.locale.mcLocale;
public class Skills public class Skills
{ {
protected static final Logger log = Logger.getLogger("Minecraft");
public static boolean cooldownOver(Player player, long oldTime, int cooldown){ public static boolean cooldownOver(Player player, long oldTime, int cooldown){
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if(currentTime - oldTime >= (cooldown * 1000)) if(currentTime - oldTime >= (cooldown * 1000))