Making our file path strings more user friendly.

This commit is contained in:
GJ 2012-04-21 14:05:39 -04:00
parent f94a617d94
commit c45cd56c78
19 changed files with 122 additions and 133 deletions

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
@ -248,7 +247,7 @@ public class Combat {
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (LoadProperties.eventCallback) {
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
Bukkit.getPluginManager().callEvent(ede);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
@ -271,7 +270,7 @@ public class Combat {
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (LoadProperties.eventCallback) {
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
Bukkit.getPluginManager().callEvent(ede);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
@ -474,7 +473,7 @@ public class Combat {
}
if (baseXP != 0) {
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(pluginx, new GainXp(attacker, PP, skillType, baseXP, target), 0);
}
}
}

View File

@ -7,15 +7,15 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerStat;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.Tree;
public class Leaderboard {
static String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
private static String leaderboardsDirectory = mcMMO.leaderboardDirectory;
private static String location = mcMMO.usersFile;
private static mcMMO plugin = mcMMO.p;
/**
* Create the leaderboards.
@ -121,7 +121,7 @@ public class Leaderboard {
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()));
}
//Write the leader board files
@ -147,8 +147,8 @@ public class Leaderboard {
* @param skillType Skill type to write the leaderboard of
*/
private static void leaderWrite(PlayerStat[] ps, SkillType skillType) {
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo";
File theDir = new File(theLocation);
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
File theDir = new File(theLocation);
//CHECK IF THE FILE EXISTS
if (!theDir.exists()) {
@ -158,7 +158,7 @@ public class Leaderboard {
writer = new FileWriter(theLocation);
}
catch (Exception e) {
Bukkit.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
plugin.getLogger().severe(("Exception while creating " + theLocation + e.toString()));
}
finally {
try {
@ -167,7 +167,7 @@ public class Leaderboard {
}
}
catch (IOException e) {
Bukkit.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
plugin.getLogger().severe("Exception while closing writer for " + theLocation + e.toString());
}
}
}
@ -196,7 +196,7 @@ public class Leaderboard {
out.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}
@ -209,7 +209,7 @@ public class Leaderboard {
* @return the requested leaderboard information
*/
public static String[] retrieveInfo(String skillName, int pagenumber) {
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillName + ".mcmmo"; //$NON-NLS-1$ //$NON-NLS-2$
String theLocation = leaderboardsDirectory + skillName + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
@ -242,7 +242,7 @@ public class Leaderboard {
return info;
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
plugin.getLogger().severe("Exception while reading " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
return null; //Shouldn't get here
@ -259,7 +259,7 @@ public class Leaderboard {
return;
}
String theLocation = "plugins/mcMMO/FlatFileStuff/Leaderboards/" + skillType + ".mcmmo";
String theLocation = leaderboardsDirectory + skillType.toString().toLowerCase() + ".mcmmo";
try {
FileReader file = new FileReader(theLocation);
@ -294,7 +294,7 @@ public class Leaderboard {
out.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
plugin.getLogger().severe("Exception while writing to " + theLocation + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@ -44,7 +43,7 @@ public class Metrics {
/**
* The file where guid and opt out is stored in
*/
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
private static final String CONFIG_FILE = "plugins" + File.separator + "PluginMetrics" + File.separator + "config.yml";
/**
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
@ -200,7 +199,7 @@ public class Metrics {
String data = encode("guid") + '=' + encode(guid)
+ encodeDataPair("authors", authors)
+ encodeDataPair("version", description.getVersion())
+ encodeDataPair("server", Bukkit.getVersion())
+ encodeDataPair("server", plugin.getServer().getVersion())
+ encodeDataPair("players", Integer.toString(plugin.getServer().getOnlinePlayers().length))
+ encodeDataPair("revision", String.valueOf(REVISION));

View File

@ -5,24 +5,22 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
public class Users {
private static volatile Users instance;
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
String directory = "plugins/mcMMO/FlatFileStuff/";
String directoryb = "plugins/mcMMO/FlatFileStuff/Leaderboards/";
public static String location = mcMMO.usersFile;
public static String directory = mcMMO.flatFileDirectory;
public static String directoryb = mcMMO.leaderboardDirectory;
public static HashMap<String, PlayerProfile> players = new HashMap<String, PlayerProfile>();
/**
* Load users.
*/
public void loadUsers() {
public static void loadUsers() {
new File(directory).mkdir();
new File(directoryb).mkdir();
File theDir = new File(location);
@ -105,7 +103,7 @@ public class Users {
* @return the player's profile
*/
public static PlayerProfile getProfileByName(String playerName) {
if (Bukkit.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
if (mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline() || players.containsKey(playerName.toLowerCase())) {
if (players.get(playerName.toLowerCase()) != null) {
return players.get(playerName.toLowerCase());
}
@ -118,16 +116,4 @@ public class Users {
return new PlayerProfile(playerName, false);
}
}
/**
* Get an instance of this class.
*
* @return an instance of this class
*/
public static Users getInstance() {
if (instance == null) {
instance = new Users();
}
return instance;
}
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.api;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
@ -21,7 +21,7 @@ public class ChatAPI {
*/
public void sendPartyChat(String sender, String party, String message) {
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
Bukkit.getPluginManager().callEvent(chatEvent);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
@ -29,9 +29,9 @@ public class ChatAPI {
String pPrefix = ChatColor.GREEN + "(" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.GREEN + ") ";
Bukkit.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
mcMMO.p.getLogger().info("[P](" + chatEvent.getParty() + ")" + "<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Users.getProfile(player).inParty()) {
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
player.sendMessage(pPrefix + chatEvent.getMessage());
@ -50,7 +50,7 @@ public class ChatAPI {
*/
public void sendAdminChat(String sender, String message) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
Bukkit.getPluginManager().callEvent(chatEvent);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
@ -58,9 +58,9 @@ public class ChatAPI {
String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + chatEvent.getSender() + ChatColor.AQUA + "} ";
Bukkit.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
mcMMO.p.getLogger().info("[A]<" + chatEvent.getSender() + "> " + chatEvent.getMessage());
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (mcPermissions.getInstance().adminChat(player) || player.isOp())
player.sendMessage(aPrefix + chatEvent.getMessage());
}

View File

@ -4,10 +4,10 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.Party;
public class PartyAPI {
@ -57,7 +57,7 @@ public class PartyAPI {
* @return the list of parties.
*/
public ArrayList<String> getParties() {
String location = "plugins/mcMMO/mcmmo.users";
String location = mcMMO.usersFile;
ArrayList<String> parties = new ArrayList<String>();
try {
@ -83,7 +83,7 @@ public class PartyAPI {
in.close();
}
catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return parties;
}

View File

@ -17,7 +17,7 @@ import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.locale.mcLocale;
public class McremoveCommand implements CommandExecutor {
private final String LOCATION = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
private final String location = mcMMO.usersFile;
private final mcMMO plugin;
public McremoveCommand (mcMMO plugin) {
@ -107,7 +107,7 @@ public class McremoveCommand implements CommandExecutor {
boolean worked = false;
try {
FileReader file = new FileReader(LOCATION);
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
StringBuilder writer = new StringBuilder();
String line = "";
@ -126,14 +126,14 @@ public class McremoveCommand implements CommandExecutor {
}
in.close();
FileWriter out = new FileWriter(LOCATION); //Write out the new file
FileWriter out = new FileWriter(location); //Write out the new file
out.write(writer.toString());
out.close();
return worked;
}
catch (Exception e) {
plugin.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

@ -7,7 +7,6 @@ import java.io.FileWriter;
import java.util.HashMap;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@ -61,7 +60,7 @@ public class PlayerProfile {
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private String playerName;
private String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
private String location = mcMMO.usersFile;
public PlayerProfile(String name, boolean addNew) {
hud = LoadProperties.defaulthud;
@ -282,7 +281,7 @@ public class PlayerProfile {
}
in.close();
} catch (Exception e) {
Bukkit.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
return false;
}
@ -404,7 +403,7 @@ public class PlayerProfile {
out.write(writer.toString());
out.close();
} catch (Exception e) {
Bukkit.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
}
@ -479,7 +478,7 @@ public class PlayerProfile {
out.newLine();
out.close();
} catch (Exception e) {
Bukkit.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
}
}
@ -993,7 +992,7 @@ public class PlayerProfile {
* @param newValue The amount of XP to add
*/
public void addXPOverride(SkillType skillType, int newValue) {
Player player = Bukkit.getPlayer(playerName);
Player player = mcMMO.p.getServer().getPlayer(playerName);
if (skillType.equals(SkillType.ALL)) {
for (SkillType x : SkillType.values()) {
@ -1147,7 +1146,7 @@ public class PlayerProfile {
* @return the power level of the player
*/
public int getPowerLevel() {
Player player = Bukkit.getPlayer(playerName);
Player player = mcMMO.p.getServer().getPlayer(playerName);
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
@ -1166,7 +1165,7 @@ public class PlayerProfile {
* @return the party bonus multiplier
*/
private double partyModifier(SkillType skillType) {
Player player = Bukkit.getPlayer(playerName);
Player player = mcMMO.p.getServer().getPlayer(playerName);
double bonusModifier = 0.0;
for (Player x : Party.getInstance().getPartyMembers(player)) {

View File

@ -22,7 +22,6 @@ import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.bukkit.Bukkit;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -268,7 +267,7 @@ public class mcBlockListener implements Listener {
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inhand.getType().equals(Material.AIR)) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
plugin.getServer().getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
}

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -108,11 +107,11 @@ public class m {
//Support for NoCheat
if (shouldArmSwing) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
}
FakeBlockBreakEvent event = new FakeBlockBreakEvent(block, player);
Bukkit.getPluginManager().callEvent(event);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
return true;
@ -236,7 +235,7 @@ public class m {
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);
Bukkit.getPluginManager().callEvent(event);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
@ -37,20 +36,16 @@ import org.bukkit.entity.Player;
public class mcMMO extends JavaPlugin {
public static String maindirectory = "plugins" + File.separator + "mcMMO";
public static File file = new File(maindirectory + File.separator + "config.yml");
public static File versionFile = new File(maindirectory + File.separator + "VERSION");
private final mcPlayerListener playerListener = new mcPlayerListener(this);
private final mcBlockListener blockListener = new mcBlockListener(this);
private final mcEntityListener entityListener = new mcEntityListener(this);
//Alias - Command
public HashMap<String, String> aliasMap = new HashMap<String, String>();
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
public static Database database = null;
public static File versionFile;
public static Database database;
public static mcMMO p;
//Config file stuff
@ -60,13 +55,24 @@ public class mcMMO extends JavaPlugin {
//Jar stuff
public static File mcmmo;
//File Paths
public static String mainDirectory;
public static String flatFileDirectory;
public static String usersFile;
public static String leaderboardDirectory;
/**
* Things to be run when the plugin is enabled.
*/
public void onEnable() {
p = this;
mcmmo = this.getFile();
new File(maindirectory).mkdir();
mcmmo = getFile();
versionFile = new File(getDataFolder(), "VERSION");
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
if (!versionFile.exists()) {
updateVersion();
@ -97,13 +103,11 @@ public class mcMMO extends JavaPlugin {
new Party(this);
if (!LoadProperties.useMySQL) {
Users.getInstance().loadUsers();
Users.loadUsers();
}
PluginManager pm = getServer().getPluginManager();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new SpoutStart(this), 20); //Schedule Spout Activation 1 second after start-up
//Register events
pm.registerEvents(playerListener, this);
pm.registerEvents(blockListener, this);
@ -128,6 +132,8 @@ public class mcMMO extends JavaPlugin {
BukkitScheduler scheduler = getServer().getScheduler();
//Schedule Spout Activation 1 second after start-up
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
//Periodic save timer (Saves every 10 minutes)
scheduler.scheduleSyncRepeatingTask(this, new mcSaveTimer(this), 0, LoadProperties.saveInterval * 1200);
//Regen & Cooldown timer (Runs every second)
@ -202,7 +208,7 @@ public class mcMMO extends JavaPlugin {
x.save();
}
Bukkit.getServer().getScheduler().cancelTasks(this); //This removes our tasks
this.getServer().getScheduler().cancelTasks(this); //This removes our tasks
System.out.println("mcMMO was disabled."); //How informative!
}
@ -457,7 +463,7 @@ public class mcMMO extends JavaPlugin {
treasuresConfig.save(treasuresConfigFile);
}
catch (IOException ex) {
Bukkit.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
this.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
}
}
}

View File

@ -18,9 +18,10 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
public class Party {
public static String partyPlayersFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
public static String partyLocksFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
public static String partyPasswordsFile = mcMMO.maindirectory + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
public static String pluginPath;
public static String partyPlayersFile;
public static String partyLocksFile;
public static String partyPasswordsFile;
HashMap<String, HashMap<String, Boolean>> partyPlayers = new HashMap<String, HashMap<String, Boolean>>();
HashMap<String, Boolean> partyLocks = new HashMap<String, Boolean>();
@ -30,8 +31,12 @@ public class Party {
private static volatile Party instance;
public Party(mcMMO instance) {
new File(mcMMO.maindirectory + File.separator + "FlatFileStuff").mkdir();
plugin = instance;
pluginPath = plugin.getDataFolder().getPath();
partyPlayersFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPlayers";
partyLocksFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyLocks";
partyPasswordsFile = pluginPath + File.separator + "FlatFileStuff" + File.separator + "partyPasswords";
new File(pluginPath + File.separator + "FlatFileStuff").mkdir();
}
public static Party getInstance() {

View File

@ -16,7 +16,7 @@ public class SQLConversionTask implements Runnable {
@Override
public void run() {
String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
String location = mcMMO.usersFile;
try {
FileReader file = new FileReader(location);

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -14,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.config.LoadTreasures;
@ -135,7 +135,7 @@ public class Excavation {
if (!block.hasMetadata("mcmmoPlacedBlock")) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
Excavation.excavationProcCheck(block, player);
Excavation.excavationProcCheck(block, player);

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.CropState;
import org.bukkit.Location;
import org.bukkit.Material;
@ -279,7 +278,7 @@ public class Herbalism {
m.mcDropItem(loc, new ItemStack(Material.WHEAT));
m.mcRandomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
inventory.removeItem(new ItemStack(Material.SEEDS));
player.updateInventory();

View File

@ -4,7 +4,6 @@ import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -430,7 +429,7 @@ public class Repair {
PlayerInventory inventory = player.getInventory();
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (initialDurability - newDurability), repairMaterial, item);
Bukkit.getPluginManager().callEvent(event);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;

View File

@ -10,11 +10,11 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.Bukkit;
import com.gmail.nossr50.Combat;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile;
@ -313,7 +313,7 @@ public class WoodCutting {
*/
public static void leafBlower(Player player, Block block) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
Bukkit.getPluginManager().callEvent(armswing);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
if (LoadProperties.woodcuttingrequiresaxe) {
Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);

View File

@ -12,10 +12,10 @@ import java.util.HashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.keyboard.Keyboard;
import org.getspout.spoutapi.player.SpoutPlayer;
@ -32,7 +32,13 @@ import com.gmail.nossr50.listeners.mcSpoutListener;
import com.gmail.nossr50.listeners.mcSpoutScreenListener;
public class SpoutStuff {
static mcMMO plugin = mcMMO.p;
private static mcMMO plugin = mcMMO.p;
public final static String spoutDirectory = mcMMO.mainDirectory + "Resources" + File.separator;
public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
private final static mcSpoutListener spoutListener = new mcSpoutListener(plugin);
private final static mcSpoutInputListener spoutInputListener = new mcSpoutInputListener(plugin);
@ -49,12 +55,11 @@ public class SpoutStuff {
* @param theFileName The name of the file
* @param theFilePath The name of the file path
*/
public static void writeFile(String theFileName, String theFilePath) {
private static void writeFile(String theFileName, String theFilePath) {
try {
File currentFile = new File("plugins/mcMMO/Resources/" + theFilePath + theFileName);
File currentFile = new File(theFilePath + theFileName);
@SuppressWarnings("static-access")
JarFile jar = new JarFile(plugin.mcmmo);
JarFile jar = new JarFile(mcMMO.mcmmo);
JarEntry entry = jar.getJarEntry("resources/" + theFileName);
InputStream is = jar.getInputStream(entry);
@ -84,15 +89,14 @@ public class SpoutStuff {
public static void extractFiles() {
//Setup directories
new File("plugins/mcMMO/Resources/").mkdir();
new File("plugins/mcMMO/Resources/HUD/").mkdir();
new File("plugins/mcMMO/Resources/HUD/Standard/").mkdir();
new File("plugins/mcMMO/Resources/HUD/Retro/").mkdir();
new File("plugins/mcMMO/Resources/Sound/").mkdir();
new File(spoutDirectory).mkdir();
new File(hudDirectory).mkdir();
new File(hudStandardDirectory).mkdir();
new File(hudRetroDirectory).mkdir();
new File(soundDirectory).mkdir();
//XP Bar images
for (int x = 0; x < 255; x++) {
String theFilePath = "HUD/Standard/";
String theFileName;
if (x < 10) {
@ -105,13 +109,10 @@ public class SpoutStuff {
theFileName = "xpbar_inc" + x + ".png";
}
writeFile(theFileName, theFilePath);
writeFile(theFileName, hudStandardDirectory);
}
//Standard XP Icons
String standardFilePath = "HUD/Standard/";
String retroFilePath = "HUD/Retro/";
for (SkillType y : SkillType.values()) {
if (y.equals(SkillType.ALL)) {
continue;
@ -120,19 +121,17 @@ public class SpoutStuff {
String standardFileName = m.getCapitalized(y.toString())+".png";
String retroFileName = m.getCapitalized(y.toString())+"_r.png";
writeFile(standardFileName, standardFilePath);
writeFile(retroFileName, retroFilePath);
writeFile(standardFileName, hudStandardDirectory);
writeFile(retroFileName, hudRetroDirectory);
}
//Blank icons
writeFile("Icon.png", standardFilePath);
writeFile("Icon_r.png", retroFilePath);
writeFile("Icon.png", hudStandardDirectory);
writeFile("Icon_r.png", hudRetroDirectory);
//Sound FX
String theSoundFilePath = "Sound/";
writeFile("repair.wav", theSoundFilePath);
writeFile("level.wav", theSoundFilePath);
writeFile("repair.wav", soundDirectory);
writeFile("level.wav", soundDirectory);
}
/**
@ -160,18 +159,17 @@ public class SpoutStuff {
*/
public static ArrayList<File> getFiles() {
ArrayList<File> files = new ArrayList<File>();
String dir = "plugins/mcMMO/Resources/";
/* XP BAR */
for (int x = 0; x < 255; x++) {
if (x < 10) {
files.add(new File(dir + "HUD/Standard/xpbar_inc00" + x + ".png"));
files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png"));
}
else if (x < 100) {
files.add(new File(dir + "HUD/Standard/xpbar_inc0" + x + ".png"));
files.add(new File(hudStandardDirectory + "xpbar_inc0" + x + ".png"));
}
else {
files.add(new File(dir + "HUD/Standard/xpbar_inc" + x + ".png"));
files.add(new File(hudStandardDirectory + "xpbar_inc" + x + ".png"));
}
}
@ -181,19 +179,19 @@ public class SpoutStuff {
continue;
}
files.add(new File(dir + "HUD/Standard/" + m.getCapitalized(y.toString()) + ".png"));
files.add(new File(dir + "HUD/Retro/" + m.getCapitalized(y.toString()) + "_r.png"));
files.add(new File(hudStandardDirectory + m.getCapitalized(y.toString()) + ".png"));
files.add(new File(hudRetroDirectory + m.getCapitalized(y.toString()) + "_r.png"));
}
/* Blank icons */
files.add(new File(dir + "HUD/Standard/Icon.png"));
files.add(new File(dir + "HUD/Retro/Icon_r.png"));
files.add(new File(hudStandardDirectory + "Icon.png"));
files.add(new File(hudRetroDirectory + "Icon_r.png"));
//Repair SFX
files.add(new File(dir + "Sound/repair.wav"));
files.add(new File(soundDirectory + "repair.wav"));
//Level SFX
files.add(new File(dir + "Sound/level.wav"));
files.add(new File(soundDirectory + "level.wav"));
return files;
}
@ -202,9 +200,9 @@ public class SpoutStuff {
* Register custom Spout events.
*/
public static void registerCustomEvent() {
Bukkit.getServer().getPluginManager().registerEvents(spoutListener, plugin);
Bukkit.getServer().getPluginManager().registerEvents(spoutInputListener, plugin);
Bukkit.getServer().getPluginManager().registerEvents(spoutScreenListener, plugin);
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
plugin.getServer().getPluginManager().registerEvents(spoutInputListener, plugin);
plugin.getServer().getPluginManager().registerEvents(spoutScreenListener, plugin);
}
/**
@ -214,7 +212,7 @@ public class SpoutStuff {
* @return the SpoutPlayer related to this player name, null if there's no player online with that name.
*/
public static SpoutPlayer getSpoutPlayer(String playerName) {
for (Player x : Bukkit.getServer().getOnlinePlayers()) {
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.getName().equalsIgnoreCase(playerName)) {
return SpoutManager.getPlayer(x);
}

View File

@ -1,4 +1,5 @@
name: mcMMO
website: mcmmo.org
main: com.gmail.nossr50.mcMMO
version: ${project.version}-b${BUILD_NUMBER}
softdepend: [Spout]