Cleanup & refactoring, part 1.

This commit is contained in:
GJ 2012-04-20 18:09:50 -04:00
parent 153ecf4d13
commit f94a617d94
32 changed files with 224 additions and 188 deletions

View File

@ -9,7 +9,6 @@ import java.util.HashMap;
import java.util.ArrayList;
import java.util.Properties;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.LoadProperties;
@ -33,10 +32,10 @@ public class Database {
DriverManager.getConnection(connectionString);
}
catch (ClassNotFoundException e) {
Bukkit.getLogger().warning(e.getLocalizedMessage());
plugin.getLogger().warning(e.getLocalizedMessage());
}
catch (SQLException ex) {
Bukkit.getLogger().warning(ex.getLocalizedMessage());
plugin.getLogger().warning(ex.getLocalizedMessage());
printErrors(ex);
}
}
@ -250,7 +249,7 @@ public class Database {
{
System.out.println("[mcMMO] Connection to MySQL was lost! Attempting to reconnect in 60 seconds...");
reconnectTimestamp = System.currentTimeMillis();
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin,
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
new Runnable() {
public void run() {
if (!isConnected()) {
@ -260,7 +259,7 @@ public class Database {
x.save(); //Save all profiles
}
Users.players.clear(); //Clear the profiles
for(Player x : Bukkit.getOnlinePlayers()) {
for(Player x : plugin.getServer().getOnlinePlayers()) {
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
}
}

View File

@ -201,7 +201,7 @@ public class Metrics {
+ encodeDataPair("authors", authors)
+ encodeDataPair("version", description.getVersion())
+ encodeDataPair("server", Bukkit.getVersion())
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
+ encodeDataPair("players", Integer.toString(plugin.getServer().getOnlinePlayers().length))
+ encodeDataPair("revision", String.valueOf(REVISION));
// If we're pinging, append it

View File

@ -19,8 +19,8 @@ import com.gmail.nossr50.skills.Skills;
public class AddlevelsCommand implements CommandExecutor{
private final mcMMO plugin;
public AddlevelsCommand(mcMMO instance) {
this.plugin = instance;
public AddlevelsCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override

View File

@ -17,8 +17,8 @@ import com.gmail.nossr50.skills.Skills;
public class AddxpCommand implements CommandExecutor {
private final mcMMO plugin;
public AddxpCommand(mcMMO instance) {
this.plugin = instance;
public AddxpCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override

View File

@ -17,8 +17,8 @@ import com.gmail.nossr50.locale.mcLocale;
public class InspectCommand implements CommandExecutor {
private final mcMMO plugin;
public InspectCommand(mcMMO instance) {
this.plugin = instance;
public InspectCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override

View File

@ -19,8 +19,8 @@ import com.gmail.nossr50.skills.Skills;
public class MmoeditCommand implements CommandExecutor {
private final mcMMO plugin;
public MmoeditCommand(mcMMO instance) {
this.plugin = instance;
public MmoeditCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,11 +7,17 @@ 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.LoadProperties;
import com.gmail.nossr50.runnables.SQLConversionTask;
public class MmoupdateCommand implements CommandExecutor {
private final mcMMO plugin;
public MmoupdateCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -24,7 +29,7 @@ public class MmoupdateCommand implements CommandExecutor {
Users.clearUsers();
convertToMySQL();
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
Users.addUser(x);
}
@ -41,6 +46,6 @@ public class MmoupdateCommand implements CommandExecutor {
return;
}
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new SQLConversionTask(), 1);
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new SQLConversionTask(plugin), 1);
}
}

View File

@ -1,20 +1,25 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
public class XprateCommand implements CommandExecutor {
private final mcMMO plugin;
private static int oldrate = LoadProperties.xpGainMultiplier;
public static boolean xpevent = false;
public XprateCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage1 = mcLocale.getString("Commands.xprate.proper");
@ -29,7 +34,7 @@ public class XprateCommand implements CommandExecutor {
case 1:
if (args[0].equalsIgnoreCase("reset")) {
if (xpevent) {
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(mcLocale.getString("Commands.xprate.over"));
}
@ -63,7 +68,7 @@ public class XprateCommand implements CommandExecutor {
LoadProperties.xpGainMultiplier = m.getInt(args[0]);
if (xpevent) {
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
x.sendMessage(mcLocale.getString("Commands.xprate.started"));
x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier}));
}

View File

@ -33,7 +33,7 @@ public class MccCommand implements CommandExecutor {
}
player.sendMessage("/invite " + mcLocale.getString("Commands.Party.Invite"));
player.sendMessage("/invite " + mcLocale.getString("Commands.Party.Accept"));
player.sendMessage("/accept " + mcLocale.getString("Commands.Party.Accept"));
if (mcPermissions.getInstance().partyTeleport(player)) {
player.sendMessage("/ptp " + mcLocale.getString("Commands.Party.Teleport"));

View File

@ -4,7 +4,6 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -19,6 +18,11 @@ import com.gmail.nossr50.locale.mcLocale;
public class McremoveCommand implements CommandExecutor {
private final String LOCATION = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
private final mcMMO plugin;
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -89,7 +93,7 @@ public class McremoveCommand implements CommandExecutor {
}
//Force PlayerProfile stuff to update
Player player = Bukkit.getServer().getPlayer(playerName);
Player player = plugin.getServer().getPlayer(playerName);
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
Users.removeUser(player);
@ -129,7 +133,7 @@ public class McremoveCommand implements CommandExecutor {
return worked;
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + LOCATION + " (Are you sure you formatted it correctly?)" + e.toString());
plugin.getLogger().severe("Exception while reading " + LOCATION + " (Are you sure you formatted it correctly?)" + e.toString());
return worked;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,14 +7,18 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.locale.mcLocale;
public class ACommand implements CommandExecutor {
private final mcMMO plugin;
public ACommand() {}
public ACommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -28,7 +31,7 @@ public class ACommand implements CommandExecutor {
}
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage);
Bukkit.getPluginManager().callEvent(chatEvent);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return true;
@ -36,9 +39,9 @@ public class ACommand implements CommandExecutor {
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} ";
Bukkit.getLogger().info("[A]<*Console*> " + aMessage);
plugin.getLogger().info("[A]<*Console*> " + aMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
for (Player herp : plugin.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(herp) || herp.isOp())
herp.sendMessage(aPrefix + aMessage);
}

View File

@ -1,14 +1,13 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
@ -16,48 +15,53 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class AcceptCommand implements CommandExecutor {
private final mcMMO plugin;
public AcceptCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale.
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (!mcPermissions.getInstance().party(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (PP.hasPartyInvite()) {
Party Pinstance = Party.getInstance();
Party partyInstance = Party.getInstance();
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), PP.getInvite(), EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
Pinstance.removeFromParty(player, PP);
partyInstance.removeFromParty(player, PP);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, PP.getInvite(), EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
}
PP.acceptInvite();
Pinstance.addToParty(player, PP, PP.getParty(), true, null);
partyInstance.addToParty(player, PP, PP.getParty(), true, null);
} else {
player.sendMessage(mcLocale.getString("mcPlayerListener.NoInvites"));
}
else {
player.sendMessage(mcLocale.getString("mcMMO.NoInvites"));
}
return true;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,13 +7,18 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.mcLocale;
public class PCommand implements CommandExecutor {
public PCommand() {}
private final mcMMO plugin;
public PCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -29,7 +33,7 @@ public class PCommand implements CommandExecutor {
}
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], pMessage);
Bukkit.getPluginManager().callEvent(chatEvent);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return true;
@ -37,9 +41,9 @@ public class PCommand implements CommandExecutor {
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + "*Console*" + ChatColor.GREEN + ") ";
Bukkit.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + pMessage);
for (Player herp : Bukkit.getServer().getOnlinePlayers()) {
for (Player herp : plugin.getServer().getOnlinePlayers()) {
if (Users.getProfile(herp).inParty()) {
if (Users.getProfile(herp).getParty().equalsIgnoreCase(args[0])) {
herp.sendMessage(pPrefix + pMessage);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,6 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
@ -16,6 +16,12 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party;
public class PartyCommand implements CommandExecutor {
private final mcMMO plugin;
public PartyCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -46,7 +52,7 @@ public class PartyCommand implements CommandExecutor {
} else if (args.length == 0 && PP.inParty()) {
String tempList = "";
int x = 0;
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (PP.getParty().equals(Users.getProfile(p).getParty())) {
if (p != null && x + 1 >= Pinstance.partyCount(player)) {
if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) {
@ -113,7 +119,7 @@ public class PartyCommand implements CommandExecutor {
if (args[0].equals("q") && PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), null, EventReason.LEFT_PARTY);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
@ -159,7 +165,7 @@ public class PartyCommand implements CommandExecutor {
} else {
if (PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
@ -169,7 +175,7 @@ public class PartyCommand implements CommandExecutor {
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
@ -194,8 +200,8 @@ public class PartyCommand implements CommandExecutor {
if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) {
if (Pinstance.isPartyLocked(PP.getParty())) {
Player tPlayer = null;
if (Bukkit.getServer().getPlayer(args[1]) != null)
tPlayer = Bukkit.getServer().getPlayer(args[1]);
if (plugin.getServer().getPlayer(args[1]) != null)
tPlayer = plugin.getServer().getPlayer(args[1]);
if (tPlayer == null) {
player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] }));
}
@ -212,7 +218,7 @@ public class PartyCommand implements CommandExecutor {
PlayerProfile tPP = Users.getProfile(tPlayer);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, tPP.getParty(), null, EventReason.KICKED_FROM_PARTY);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
@ -231,8 +237,8 @@ public class PartyCommand implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("owner")) {
if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) {
Player tPlayer = null;
if (Bukkit.getServer().getPlayer(args[1]) != null)
tPlayer = Bukkit.getServer().getPlayer(args[1]);
if (plugin.getServer().getPlayer(args[1]) != null)
tPlayer = plugin.getServer().getPlayer(args[1]);
if (tPlayer == null) {
player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner", new Object[] { args[1] }));
}
@ -246,7 +252,7 @@ public class PartyCommand implements CommandExecutor {
}
} else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
@ -256,7 +262,7 @@ public class PartyCommand implements CommandExecutor {
}
} else if (args.length == 2 && !PP.inParty()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -71,7 +70,7 @@ public class PtpCommand implements CommandExecutor {
if (PP.getParty().equals(PPt.getParty())) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
Bukkit.getPluginManager().callEvent(event);
plugin.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
player.teleport(target);

View File

@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
@ -13,6 +14,12 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.spout.SpoutStuff;
public class MchudCommand implements CommandExecutor {
private final mcMMO plugin;
public MchudCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!LoadProperties.spoutEnabled) {
@ -39,7 +46,7 @@ public class MchudCommand implements CommandExecutor {
SpoutStuff.playerHUDs.get(player).resetHUD();
SpoutStuff.playerHUDs.remove(player);
PP.setHUDType(x);
SpoutStuff.playerHUDs.put(player, new HUDmmo(player));
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
}
}
}

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@ -278,7 +277,7 @@ public class LoadTreasures extends ConfigLoader{
}
else {
for (String issue : issues) {
Bukkit.getLogger().warning(issue);
plugin.getLogger().warning(issue);
}
return false;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.Color;
@ -19,7 +18,8 @@ import com.gmail.nossr50.spout.SpoutStuff;
public class HUDmmo {
private int center_x = 427 / 2;
private String playerName = null;
private String playerName;
private final mcMMO plugin;
private Widget xpbar = null;
private GenericGradient xpfill = null;
@ -28,10 +28,9 @@ public class HUDmmo {
private GenericGradient xpicon_border = null;
private GenericTexture xpicon = null;
private mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO");
public HUDmmo(Player player) {
playerName = player.getName();
public HUDmmo(Player player, mcMMO plugin) {
this.playerName = player.getName();
this.plugin = plugin;
initializeHUD(player);
}

View File

@ -1001,12 +1001,12 @@ public class PlayerProfile {
continue;
}
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
skillsXp.put(x, skillsXp.get(x) + newValue);
}
}
else {
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
lastgained = skillType;
}
@ -1031,7 +1031,7 @@ public class PlayerProfile {
* @param player The player to add XP to
*/
public void addXP(SkillType skillType, int newValue) {
Player player = Bukkit.getPlayer(playerName);
Player player = mcMMO.p.getServer().getPlayer(playerName);
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
return;
@ -1055,7 +1055,7 @@ public class PlayerProfile {
xp += trueBonus;
}
Bukkit.getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
lastgained = skillType;
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -51,10 +50,10 @@ import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
public class mcPlayerListener implements Listener {
private mcMMO plugin;
private final mcMMO plugin;
public mcPlayerListener(mcMMO instance) {
plugin = instance;
public mcPlayerListener(final mcMMO plugin) {
this.plugin = plugin;
}
/**
@ -152,11 +151,11 @@ public class mcPlayerListener implements Listener {
//Bleed it out
if(PP.getBleedTicks() > 0) {
Combat.dealDamage(player, PP.getBleedTicks()*2);
Combat.dealDamage(player, PP.getBleedTicks() * 2);
}
//Schedule PlayerProfile removal 2 minutes after quitting
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player), 2400);
}
/**

View File

@ -38,7 +38,7 @@ public class mcSpoutListener implements Listener {
}
if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
PPs.toggleSpoutEnabled();
}

View File

@ -61,7 +61,7 @@ public class mcSpoutScreenListener implements Listener {
break;
}
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer));
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
}
}

View File

@ -26,7 +26,6 @@ import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
@ -52,6 +51,7 @@ public class mcMMO extends JavaPlugin {
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
public static Database database = null;
public static mcMMO p;
//Config file stuff
LoadProperties config;
@ -64,7 +64,7 @@ public class mcMMO extends JavaPlugin {
* Things to be run when the plugin is enabled.
*/
public void onEnable() {
final Plugin thisPlugin = this;
p = this;
mcmmo = this.getFile();
new File(maindirectory).mkdir();
@ -146,7 +146,7 @@ public class mcMMO extends JavaPlugin {
Metrics metrics = new Metrics();
// 'this' in this context is the Plugin object
metrics.beginMeasuringPlugin(thisPlugin);
metrics.beginMeasuringPlugin(p);
}
catch (IOException e) {
System.out.println("Failed to submit stats.");
@ -243,7 +243,7 @@ public class mcMMO extends JavaPlugin {
//mc* commands
if (LoadProperties.mcremoveEnable) {
getCommand("mcremove").setExecutor(new McremoveCommand());
getCommand("mcremove").setExecutor(new McremoveCommand(this));
}
if (LoadProperties.mcabilityEnable) {
@ -276,11 +276,11 @@ public class mcMMO extends JavaPlugin {
//Party commands
if (LoadProperties.acceptEnable) {
getCommand("accept").setExecutor(new AcceptCommand());
getCommand("accept").setExecutor(new AcceptCommand(this));
}
if (LoadProperties.aEnable) {
getCommand("a").setExecutor(new ACommand());
getCommand("a").setExecutor(new ACommand(this));
}
if (LoadProperties.inviteEnable) {
@ -288,11 +288,11 @@ public class mcMMO extends JavaPlugin {
}
if (LoadProperties.partyEnable) {
getCommand("party").setExecutor(new PartyCommand());
getCommand("party").setExecutor(new PartyCommand(this));
}
if (LoadProperties.pEnable) {
getCommand("p").setExecutor(new PCommand());
getCommand("p").setExecutor(new PCommand(this));
}
if (LoadProperties.ptpEnable) {
@ -317,17 +317,17 @@ public class mcMMO extends JavaPlugin {
}
if (LoadProperties.xprateEnable) {
getCommand("xprate").setExecutor(new XprateCommand());
getCommand("xprate").setExecutor(new XprateCommand(this));
}
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
//Spout commands
if (LoadProperties.xplockEnable) {
getCommand("xplock").setExecutor(new XplockCommand());
}
getCommand("mchud").setExecutor(new MchudCommand());
getCommand("mchud").setExecutor(new MchudCommand(this));
}
/**

View File

@ -10,7 +10,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
@ -72,7 +71,7 @@ public class Party {
PlayerProfile PP = Users.getProfile(player);
int partyMembers = 0;
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (player != null && p != null) { //Is this even possible?
if (PP.getParty().equals(Users.getProfile(p).getParty())) {
partyMembers++;
@ -86,7 +85,7 @@ public class Party {
private void informPartyMembers(Player player) {
String playerName = player.getName();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (player != null && p != null) {
if (inSameParty(player, p) && !p.getName().equals(playerName)) {
p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName}));
@ -104,7 +103,7 @@ public class Party {
public ArrayList<Player> getPartyMembers(Player player) {
ArrayList<Player> players = new ArrayList<Player>();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (p.isOnline() && player != null && p != null) {
if (inSameParty(player, p) && !p.getName().equals(player.getName())) {
players.add(p);
@ -122,7 +121,7 @@ public class Party {
private void informPartyMembersOwnerChange(String newOwnerName) {
Player newOwner = plugin.getServer().getPlayer(newOwnerName);
for (Player p : Bukkit.getServer().getOnlinePlayers()){
for (Player p : plugin.getServer().getOnlinePlayers()){
if (newOwner != null && p != null) {
if (inSameParty(newOwner, p)) {
p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale
@ -139,7 +138,7 @@ public class Party {
private void informPartyMembersQuit(Player player) {
String playerName = player.getName();
for (Player p : Bukkit.getServer().getOnlinePlayers()){
for (Player p : plugin.getServer().getOnlinePlayers()){
if (player != null && p != null){
if (inSameParty(player, p) && !p.getName().equals(playerName)) {
p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName}));
@ -458,7 +457,7 @@ public class Party {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyPlayersFile empty.");
plugin.getLogger().info("partyPlayersFile empty.");
}
catch (IOException e) {
e.printStackTrace();
@ -477,7 +476,7 @@ public class Party {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyLocksFile empty.");
plugin.getLogger().info("partyLocksFile empty.");
}
catch (IOException e) {
e.printStackTrace();
@ -496,7 +495,7 @@ public class Party {
e.printStackTrace();
}
catch (EOFException e) {
Bukkit.getLogger().info("partyPasswordsFile empty.");
plugin.getLogger().info("partyPasswordsFile empty.");
}
catch (IOException e) {
e.printStackTrace();

View File

@ -3,13 +3,16 @@ package com.gmail.nossr50.runnables;
import java.io.BufferedReader;
import java.io.FileReader;
import org.bukkit.Bukkit;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.LoadProperties;
public class SQLConversionTask implements Runnable {
private final mcMMO plugin;
public SQLConversionTask(mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
@ -273,7 +276,7 @@ public class SQLConversionTask implements Runnable {
in.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Bukkit;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager;
@ -11,13 +10,13 @@ import com.gmail.nossr50.spout.SpoutStuff;
public class SpoutStart implements Runnable{
private final mcMMO plugin;
public SpoutStart(mcMMO m) {
this.plugin = m;
public SpoutStart(final mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
if (Bukkit.getPluginManager().getPlugin("Spout") != null) {
if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) {
LoadProperties.spoutEnabled = true;
}
else {

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.CoalType;
import org.bukkit.Location;
import org.bukkit.Material;
@ -14,6 +13,7 @@ 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.config.LoadProperties;
import com.gmail.nossr50.spout.SpoutSounds;
@ -254,7 +254,7 @@ public class Mining {
return;
}
Bukkit.getPluginManager().callEvent(armswing);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
miningBlockCheck(player, block);

View File

@ -18,6 +18,7 @@ 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.LoadProperties;
import com.gmail.nossr50.spout.SpoutSounds;
@ -143,7 +144,7 @@ public class Repair {
//CLANG CLANG
if (LoadProperties.spoutEnabled) {
SpoutSounds.playRepairNoise(player);
SpoutSounds.playRepairNoise(player, mcMMO.p);
}
}

View File

@ -1,17 +1,18 @@
package com.gmail.nossr50.skills;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
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.LoadProperties;
import com.gmail.nossr50.spout.SpoutStuff;
@ -193,7 +194,7 @@ public class Skills {
PP.skillUp(skillType, 1);
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
Bukkit.getPluginManager().callEvent(eventToFire);
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
}
else {
PP.addLevels(skillType, 0);

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.spout;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -9,6 +8,8 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import org.getspout.spoutapi.sound.SoundEffect;
import org.getspout.spoutapi.sound.SoundManager;
import com.gmail.nossr50.mcMMO;
public class SpoutSounds {
/**
@ -30,12 +31,12 @@ public class SpoutSounds {
*
* @param player The player who repaired an item
*/
public static void playRepairNoise(Player player) {
public static void playRepairNoise(Player player, mcMMO plugin) {
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
//If this is pulling from online, why have it in the jar?
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "repair.wav", false);
SM.playCustomSoundEffect(plugin, sPlayer, "repair.wav", false);
}
/**
@ -43,11 +44,11 @@ public class SpoutSounds {
*
* @param player The player who leveled up
*/
protected static void playLevelUpNoise(Player player) {
protected static void playLevelUpNoise(Player player, mcMMO plugin) {
SoundManager SM = SpoutManager.getSoundManager();
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
//If this is pulling from online, why have it in the jar?
SM.playCustomSoundEffect(Bukkit.getServer().getPluginManager().getPlugin("mcMMO"), sPlayer, "level.wav", false);
SM.playCustomSoundEffect(plugin, sPlayer, "level.wav", false);
}
}

View File

@ -32,8 +32,7 @@ import com.gmail.nossr50.listeners.mcSpoutListener;
import com.gmail.nossr50.listeners.mcSpoutScreenListener;
public class SpoutStuff {
static mcMMO plugin = (mcMMO) Bukkit.getServer().getPluginManager().getPlugin("mcMMO");
static mcMMO plugin = mcMMO.p;
private final static mcSpoutListener spoutListener = new mcSpoutListener(plugin);
private final static mcSpoutInputListener spoutInputListener = new mcSpoutInputListener(plugin);
@ -548,7 +547,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);
SpoutSounds.playLevelUpNoise(sPlayer);
SpoutSounds.playLevelUpNoise(sPlayer, plugin);
}
/**

View File

@ -405,6 +405,7 @@ Commands.Party.Toggle=[[RED]]- Toggle Party Chat
Commands.Party=<partyname> [[RED]]- Create/Join designated party
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
Commands.SkillInfo=/<skillname> [[RED]]- View detailed information about a skill
Commands.Stats.Self=YOUR STATS
Commands.Stats=[[RED]]- View your mcMMO stats
@ -498,7 +499,6 @@ Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW]
#SKILLS
Skills.Disarmed=[[DARK_RED]]You have been disarmed!
Skills.Header=[[RED]]-----[][[GREEN]]{0}[[RED]][]-----
Skills.Leaderboard.Listener=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
Skills.NeedMore=[[DARK_RED]]You need more
Skills.Stats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]])
Skills.TooTired=[[RED]]You are too tired to use that ability again.