mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-26 18:47:57 +01:00
Cleanup!
This commit is contained in:
parent
7ada587df3
commit
1cca4de9e5
@ -46,7 +46,7 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
skillValue = (float) profile.getSkillLevel(skill);
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PP.setRecentlyHurt((long) 0);
|
||||
PP.setRecentlyHurt(0);
|
||||
PP.resetCooldowns();
|
||||
PP.resetToolPrepMode();
|
||||
PP.resetAbilityMode();
|
||||
|
@ -19,7 +19,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
|
||||
|
||||
|
||||
if (!Config.getInstance().getUseMySQL()) {
|
||||
|
||||
switch (args.length) {
|
||||
|
@ -187,7 +187,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
PlayerProfile PPt = Users.getProfile(target);
|
||||
String targetName = target.getName();
|
||||
|
||||
if (!partyInstance.inSameParty(player, (Player) target)) {
|
||||
if (!partyInstance.inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
|
||||
return true;
|
||||
}
|
||||
@ -219,7 +219,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
|
||||
String targetName = target.getName();
|
||||
|
||||
if (!partyInstance.inSameParty(player, (Player) target)) {
|
||||
if (!partyInstance.inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
|
||||
return true;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class Config extends ConfigLoader {
|
||||
}
|
||||
|
||||
/* Mining */
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
|
||||
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
|
||||
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
|
||||
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
|
||||
|
@ -290,7 +290,7 @@ public class HUDmmo {
|
||||
return;
|
||||
}
|
||||
|
||||
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
|
||||
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
|
||||
xpicon.setDirty(true);
|
||||
|
||||
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
|
||||
|
@ -102,9 +102,9 @@ public class PlayerProfile {
|
||||
public boolean loadMySQL() {
|
||||
int id = 0;
|
||||
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
||||
|
||||
|
||||
this.userid = id;
|
||||
|
||||
|
||||
if (id > 0) {
|
||||
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
|
||||
if(huds.get(1) == null)
|
||||
@ -204,7 +204,7 @@ public class PlayerProfile {
|
||||
String[] character = line.split(":");
|
||||
|
||||
if(!character[0].equals(playerName)){continue;}
|
||||
|
||||
|
||||
//Get Mining
|
||||
if(character.length > 1 && Misc.isInt(character[1]))
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
@ -299,7 +299,7 @@ public class PlayerProfile {
|
||||
Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds
|
||||
// if we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
|
||||
|
||||
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
|
||||
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
|
||||
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
|
||||
@ -440,7 +440,7 @@ public class PlayerProfile {
|
||||
//Open the file to write the player
|
||||
FileWriter file = new FileWriter(location, true);
|
||||
BufferedWriter out = new BufferedWriter(file);
|
||||
|
||||
|
||||
//Add the player to the end
|
||||
out.append(playerName + ":");
|
||||
out.append(0 + ":"); //mining
|
||||
@ -481,7 +481,7 @@ public class PlayerProfile {
|
||||
out.append(0+":"); //Blast Mining
|
||||
|
||||
//Add more in the same format as the line above
|
||||
|
||||
|
||||
out.newLine();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
@ -1039,7 +1039,7 @@ public class PlayerProfile {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
} else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
|
@ -58,10 +58,11 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
@ -264,11 +264,11 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
|
||||
if (event instanceof FakeBlockDamageEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
@ -24,7 +24,7 @@ public class HardcoreListener implements Listener {
|
||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() instanceof Player) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(((Player)player.getKiller()), player);
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,13 +158,14 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
||||
//TODO: Locale ALL the things.
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
String prefix = ChatColor.GOLD+"[mcMMO] ";
|
||||
String perkPrefix = ChatColor.RED+"[mcMMO Perks] ";
|
||||
|
||||
|
||||
player.sendMessage(prefix+ChatColor.YELLOW+"Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
|
||||
|
||||
|
||||
if(Config.getInstance().getHardcoreEnabled()) {
|
||||
if(Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(prefix+ChatColor.DARK_RED+"Hardcore & Vampirism enabled.");
|
||||
@ -174,7 +175,7 @@ public class PlayerListener implements Listener {
|
||||
player.sendMessage(prefix+ChatColor.DARK_AQUA+"Skill Death Penalty: "+ChatColor.DARK_RED+Config.getInstance().getHardcoreDeathStatPenaltyPercentage()+"%");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Quadruple XP - Receive 4x XP.");
|
||||
} else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
@ -182,7 +183,7 @@ public class PlayerListener implements Listener {
|
||||
} else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
player.sendMessage(perkPrefix+ChatColor.DARK_AQUA+"Double XP - Receive 2x XP.");
|
||||
}
|
||||
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GREEN+ "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
|
||||
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
|
||||
@ -192,8 +193,8 @@ public class PlayerListener implements Listener {
|
||||
if (XprateCommand.xpevent) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ public class SpoutListener implements Listener {
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
|
||||
|
||||
|
||||
PPs.toggleSpoutEnabled();
|
||||
}
|
||||
}
|
||||
@ -60,12 +60,12 @@ public class SpoutListener implements Listener {
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
|
||||
|
||||
if (event.getButton() instanceof ButtonHUDStyle) {
|
||||
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
||||
|
||||
|
||||
switch (PP.getHUDType()) {
|
||||
case RETRO:
|
||||
PP.setHUDType(HUDType.STANDARD);
|
||||
|
@ -76,6 +76,7 @@ public class mcMMO extends JavaPlugin {
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
p = this;
|
||||
setupFilePaths();
|
||||
@ -238,6 +239,7 @@ public class mcMMO extends JavaPlugin {
|
||||
/**
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
//Make sure to save player information if the server shuts down
|
||||
for (PlayerProfile x : Users.getProfiles().values()) {
|
||||
|
@ -74,7 +74,7 @@ public class Party {
|
||||
* Get the number of players in this player's party.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @param players A list of players to
|
||||
* @param players A list of players to
|
||||
* @return the number of players in this player's party
|
||||
*/
|
||||
public int partyCount(Player player) {
|
||||
|
@ -84,7 +84,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Instantly Bleed out a LivingEntity
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to bleed out
|
||||
*/
|
||||
public static void bleedOut(LivingEntity entity) {
|
||||
@ -96,7 +96,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Remove a LivingEntity from the bleedList if it is in it
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to remove
|
||||
*/
|
||||
public static void remove(LivingEntity entity) {
|
||||
@ -168,7 +168,7 @@ public class BleedTimer implements Runnable {
|
||||
|
||||
/**
|
||||
* Check to see if a LivingEntity is in the bleedList
|
||||
*
|
||||
*
|
||||
* @param entity LivingEntity to check if in the bleedList
|
||||
* @return true if in the list, false if not
|
||||
*/
|
||||
|
@ -61,7 +61,7 @@ public class Swords {
|
||||
else {
|
||||
bleedTicks = 2;
|
||||
}
|
||||
|
||||
|
||||
BleedTimer.add(defender, bleedTicks);
|
||||
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class Taming {
|
||||
*
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param theWolf The wolf using the ability
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
*/
|
||||
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) {
|
||||
final int SKILL_ACTIVATION_LEVEL = 50;
|
||||
|
@ -276,7 +276,7 @@ public class Fishing {
|
||||
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) le;
|
||||
|
||||
|
||||
if (!sheep.isSheared()) {
|
||||
Wool wool = new Wool();
|
||||
wool.setColor(sheep.getColor());
|
||||
|
@ -48,10 +48,10 @@ public class Herbalism {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void greenTerraConvert(Player player, Block block) {
|
||||
Material type = block.getType();
|
||||
|
||||
|
||||
if (Misc.blockBreakSimulate(block, player, false)) {
|
||||
if (Config.getInstance().getHerbalismGreenThumbSmoothbrickToMossy() && type == Material.SMOOTH_BRICK && block.getData() == 0) {
|
||||
block.setTypeIdAndData(block.getTypeId(), (byte) 1, false); //Set type of the brick to mossy, force the client update
|
||||
|
@ -213,7 +213,7 @@ public class Mining {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
Material type = block.getType();
|
||||
int xp = 0;
|
||||
|
||||
|
||||
switch (type) {
|
||||
case COAL_ORE:
|
||||
xp += Config.getInstance().getMiningXPCoalOre();
|
||||
|
@ -100,7 +100,7 @@ public class WoodCutting {
|
||||
ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.REDWOOD.getData());
|
||||
ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.BIRCH.getData());
|
||||
ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0, TreeSpecies.JUNGLE.getData());
|
||||
|
||||
|
||||
for (Block x : toBeFelled) {
|
||||
if (Misc.blockBreakSimulate(x, player, true)) {
|
||||
if (Config.getInstance().getBlockModsEnabled()) {
|
||||
@ -215,7 +215,7 @@ public class WoodCutting {
|
||||
*/
|
||||
private static void processTreeFelling(Block currentBlock, ArrayList<Block> toBeFelled) {
|
||||
Material type = currentBlock.getType();
|
||||
|
||||
|
||||
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
return;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class SpoutStuff {
|
||||
files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png"));
|
||||
files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png"));
|
||||
}
|
||||
|
||||
|
||||
/* Blank icons */
|
||||
files.add(new File(hudStandardDirectory + "Icon.png"));
|
||||
files.add(new File(hudRetroDirectory + "Icon_r.png"));
|
||||
|
@ -113,7 +113,7 @@ public class Combat {
|
||||
if (permInstance.impact(attacker)) {
|
||||
Axes.impact(attacker, target, event);
|
||||
}
|
||||
|
||||
|
||||
if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER) && permInstance.skullSplitter(attacker)) {
|
||||
applyAbilityAoE(attacker, target, event.getDamage() / 2, plugin, SkillType.AXES);
|
||||
}
|
||||
@ -319,7 +319,7 @@ public class Combat {
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg);
|
||||
EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
@ -342,7 +342,7 @@ public class Combat {
|
||||
*/
|
||||
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
|
||||
if (configInstance.getEventCallbackEnabled()) {
|
||||
EntityDamageEvent ede = (EntityDamageByEntityEvent) new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||
|
||||
if (ede.isCancelled()) {
|
||||
|
@ -222,23 +222,23 @@ public class Database {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get connection status
|
||||
*
|
||||
*
|
||||
* @return the boolean value for whether or not we are connected
|
||||
*/
|
||||
public static boolean isConnected() {
|
||||
if(conn == null)
|
||||
return false;
|
||||
|
||||
|
||||
try {
|
||||
return conn.isValid(3);
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Schedules a Sync Delayed Task with the Bukkit Scheduler to attempt reconnection after a minute has elapsed
|
||||
* This will check for a connection being present or not to prevent unneeded reconnection attempts
|
||||
|
@ -11,56 +11,56 @@ public class Hardcore {
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0)
|
||||
return;
|
||||
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
|
||||
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
|
||||
int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D)));
|
||||
|
||||
|
||||
if(newValue < 0)
|
||||
newValue = 0;
|
||||
|
||||
|
||||
totalCount+=PP.getSkillLevel(st)-newValue;
|
||||
|
||||
|
||||
PP.modifySkill(st, newValue);
|
||||
}
|
||||
|
||||
|
||||
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death.");
|
||||
}
|
||||
|
||||
|
||||
public static void invokeVampirism(Player killer, Player defender) {
|
||||
if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0)
|
||||
return;
|
||||
|
||||
|
||||
PlayerProfile PPk = Users.getProfile(killer);
|
||||
PlayerProfile PPd = Users.getProfile(defender);
|
||||
|
||||
|
||||
int totalCount = 0;
|
||||
|
||||
|
||||
for(SkillType st : SkillType.values()) {
|
||||
if(st.equals(SkillType.ALL))
|
||||
continue;
|
||||
|
||||
|
||||
if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2))
|
||||
continue;
|
||||
|
||||
|
||||
int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
|
||||
|
||||
|
||||
if(newValue <= 0)
|
||||
newValue = 1;
|
||||
|
||||
|
||||
totalCount+=1;
|
||||
|
||||
|
||||
PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
|
||||
PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue);
|
||||
}
|
||||
|
||||
|
||||
if(totalCount >= 1) {
|
||||
killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player.");
|
||||
defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!");
|
||||
|
@ -74,7 +74,7 @@ public class ItemChecks {
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return true if the item is a shovel, false otherwise
|
||||
*/
|
||||
*/
|
||||
public static boolean isShovel(ItemStack is) {
|
||||
switch (is.getType()) {
|
||||
case DIAMOND_SPADE:
|
||||
|
@ -116,7 +116,7 @@ public class Metrics {
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
@ -225,6 +225,7 @@ public class Metrics {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
|
@ -96,7 +96,7 @@ public class Misc {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
|
@ -9,7 +9,7 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class Page {
|
||||
|
||||
|
||||
public static int getTotalPageNumber(String address)
|
||||
{
|
||||
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
||||
@ -18,24 +18,24 @@ public class Page {
|
||||
else
|
||||
return (addressSplit.length/8)+1;
|
||||
}
|
||||
|
||||
|
||||
public static ArrayList<String> grabPageContents(String header, String address, int pagenum)
|
||||
{
|
||||
int pageIndexStart = 0;
|
||||
|
||||
|
||||
//Determine what string to start at
|
||||
if(pagenum > 1)
|
||||
{
|
||||
pageIndexStart = 8*(pagenum-1);
|
||||
}
|
||||
|
||||
|
||||
ArrayList<String> allStrings = new ArrayList<String>();
|
||||
String split[] = LocaleLoader.getString(address).split("\n");
|
||||
|
||||
|
||||
allStrings.add(ChatColor.GOLD+"-="+ChatColor.GREEN+header+ChatColor.GOLD+"=-"); //So stylish
|
||||
|
||||
|
||||
//Add targeted strings
|
||||
|
||||
|
||||
while(allStrings.size() < 9)
|
||||
{
|
||||
if(pageIndexStart+allStrings.size() > split.length)
|
||||
@ -43,11 +43,11 @@ public class Page {
|
||||
else
|
||||
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
|
||||
}
|
||||
|
||||
|
||||
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
|
||||
return allStrings;
|
||||
}
|
||||
|
||||
|
||||
public static void clearChat(Player player)
|
||||
{
|
||||
for(int x = 0; x < 20; x++)
|
||||
@ -55,7 +55,7 @@ public class Page {
|
||||
player.sendMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void grabGuidePageForSkill(SkillType skilltype, Player player, String[] args)
|
||||
{
|
||||
String capitalized = Misc.getCapitalized(skilltype.toString());
|
||||
@ -64,9 +64,9 @@ public class Page {
|
||||
{
|
||||
if(args[0].equals("?"))
|
||||
{
|
||||
|
||||
|
||||
String address = "Guides."+capitalized;
|
||||
|
||||
|
||||
if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
|
||||
{
|
||||
Page.clearChat(player);
|
||||
@ -82,7 +82,7 @@ public class Page {
|
||||
player.sendMessage(target);
|
||||
}
|
||||
}
|
||||
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
{
|
||||
player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale.
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class Users {
|
||||
* Load users.
|
||||
*/
|
||||
public static void loadUsers() {
|
||||
|
||||
|
||||
|
||||
new File(plugin.flatFileDirectory).mkdir();
|
||||
new File(plugin.leaderboardDirectory).mkdir();
|
||||
|
@ -18,6 +18,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
public class HashChunkletManager implements ChunkletManager {
|
||||
private HashMap<String, ChunkletStore> store = new HashMap<String, ChunkletStore>();
|
||||
|
||||
@Override
|
||||
public void chunkLoaded(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
@ -38,6 +39,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chunkUnloaded(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
|
||||
@ -56,6 +58,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(World world) {
|
||||
String worldName = world.getName();
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
@ -74,6 +77,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadWorld(World world) {
|
||||
saveWorld(world);
|
||||
|
||||
@ -87,12 +91,14 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadAll() {
|
||||
saveAll();
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
@ -100,6 +106,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -114,10 +121,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
return check.isTrue(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrue(Block block) {
|
||||
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -137,10 +146,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
cStore.setTrue(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(Block block) {
|
||||
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(int x, int y, int z, World world) {
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
@ -159,10 +170,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
cStore.setFalse(ix, iy, iz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(Block block) {
|
||||
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
for(String key : store.keySet()) {
|
||||
if(store.get(key).isEmpty()) {
|
||||
|
@ -6,18 +6,22 @@ public class PrimitiveChunkletStore implements ChunkletStore {
|
||||
/** X, Z, Y */
|
||||
private boolean[][][] store = new boolean[16][16][64];
|
||||
|
||||
@Override
|
||||
public boolean isTrue(int x, int y, int z) {
|
||||
return store[x][z][y];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrue(int x, int y, int z) {
|
||||
store[x][z][y] = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFalse(int x, int y, int z) {
|
||||
store[x][z][y] = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
|
@ -120,7 +120,7 @@ public class ZipLibrary {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
byte[] buffer = new byte[4092];
|
||||
int byteCount = 0;
|
||||
|
||||
|
||||
while ((byteCount = fis.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, byteCount);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user