Reintroduced logging.

This commit is contained in:
garbagemule 2012-03-07 23:51:00 +01:00
parent 5e7287d03f
commit 48acd00d47
5 changed files with 41 additions and 15 deletions

Binary file not shown.

View File

@ -1,7 +1,7 @@
name: MobArena name: MobArena
author: garbagemule author: garbagemule
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.94.4.57 version: 0.94.4.58
softdepend: [Spout,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells,Vault] softdepend: [Spout,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells,Vault]
commands: commands:
ma: ma:

View File

@ -1,5 +1,6 @@
package com.garbagemule.MobArena; package com.garbagemule.MobArena;
import java.io.File;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.PriorityBlockingQueue;
@ -29,6 +30,11 @@ import org.bukkit.potion.PotionEffect;
import com.garbagemule.MobArena.events.*; import com.garbagemule.MobArena.events.*;
import com.garbagemule.MobArena.framework.Arena; import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.leaderboards.Leaderboard; import com.garbagemule.MobArena.leaderboards.Leaderboard;
import com.garbagemule.MobArena.log.ArenaLog;
import com.garbagemule.MobArena.log.LogSessionBuilder;
import com.garbagemule.MobArena.log.LogTotalsBuilder;
import com.garbagemule.MobArena.log.YMLSessionBuilder;
import com.garbagemule.MobArena.log.YMLTotalsBuilder;
import com.garbagemule.MobArena.region.ArenaRegion; import com.garbagemule.MobArena.region.ArenaRegion;
import com.garbagemule.MobArena.repairable.*; import com.garbagemule.MobArena.repairable.*;
import com.garbagemule.MobArena.spout.Spouty; import com.garbagemule.MobArena.spout.Spouty;
@ -49,6 +55,7 @@ public class ArenaImpl implements Arena
private MobArena plugin; private MobArena plugin;
private String name; private String name;
private World world; private World world;
private File dir;
// Settings section of the config-file for this arena. // Settings section of the config-file for this arena.
private ConfigSection settings; private ConfigSection settings;
@ -92,10 +99,14 @@ public class ArenaImpl implements Arena
private SheepBouncer sheepBouncer; private SheepBouncer sheepBouncer;
private Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap; private Map<Integer,List<ItemStack>> everyWaveMap, afterWaveMap;
// Logging
private ArenaLog log;
private LogSessionBuilder sessionBuilder;
private LogTotalsBuilder totalsBuilder;
// Misc // Misc
private ArenaListener eventListener; private ArenaListener eventListener;
private List<ItemStack> entryFee; private List<ItemStack> entryFee;
//private ArenaLog log;
private TimeStrategy timeStrategy; private TimeStrategy timeStrategy;
/** /**
@ -158,6 +169,12 @@ public class ArenaImpl implements Arena
String timeString = settings.getString("player-time-in-arena", "world"); String timeString = settings.getString("player-time-in-arena", "world");
Time time = Enums.getEnumFromString(Time.class, timeString); Time time = Enums.getEnumFromString(Time.class, timeString);
this.timeStrategy = (time != null ? new TimeStrategyLocked(time) : new TimeStrategyNull()); this.timeStrategy = (time != null ? new TimeStrategyLocked(time) : new TimeStrategyNull());
this.dir = new File(plugin.getDataFolder() + File.separator + "arenas" + File.separator + name);
this.sessionBuilder = new YMLSessionBuilder(new File(dir, "log_session.yml"));
this.totalsBuilder = new YMLTotalsBuilder(new File(dir, "log_totals.yml"));
this.log = new ArenaLog(this, sessionBuilder, totalsBuilder);
} }
@ -284,11 +301,6 @@ public class ArenaImpl implements Arena
return waveManager; return waveManager;
} }
/*@Override
public ArenaLog getLog() {
return log;
}*/
@Override @Override
public Location getPlayerEntry(Player p) { public Location getPlayerEntry(Player p) {
PlayerData mp = playerData.get(p); PlayerData mp = playerData.get(p);
@ -355,6 +367,11 @@ public class ArenaImpl implements Arena
return monsterManager; return monsterManager;
} }
@Override
public ArenaLog getLog() {
return log;
}
@ -419,8 +436,7 @@ public class ArenaImpl implements Arena
// Start logging // Start logging
rewardManager.reset(); rewardManager.reset();
//log = new ArenaLog(plugin, this); log.start();
//log.start();
// Initialize leaderboards and start displaying info. // Initialize leaderboards and start displaying info.
leaderboard.initialize(); leaderboard.initialize();
@ -455,12 +471,7 @@ public class ArenaImpl implements Arena
leaderboard.update(); leaderboard.update();
// Finish logging // Finish logging
//log.end(); log.end();
/*if (logging != null) { TODO: FIX LOGGING!
log.saveSessionData();
log.updateArenaTotals();
}*/
//log.clearSessionData();
// Stop spawning. // Stop spawning.
stopSpawner(); stopSpawner();
@ -568,6 +579,9 @@ public class ArenaImpl implements Arena
removeClassPermissions(p); removeClassPermissions(p);
removePotionEffects(p); removePotionEffects(p);
ArenaPlayer ap = arenaPlayerMap.get(p);
if (ap != null) log.playerLeave(ap);
if (inLobby(p) || inArena(p)) { if (inLobby(p) || inArena(p)) {
inventoryManager.clearInventory(p); inventoryManager.clearInventory(p);
inventoryManager.restoreInventory(p); inventoryManager.restoreInventory(p);
@ -594,6 +608,9 @@ public class ArenaImpl implements Arena
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this); ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
ArenaPlayer ap = arenaPlayerMap.get(p);
if (ap != null) log.playerLeave(ap);
arenaPlayers.remove(p); arenaPlayers.remove(p);
if (!settings.getBoolean("auto-respawn", true)) { if (!settings.getBoolean("auto-respawn", true)) {

View File

@ -1,6 +1,7 @@
package com.garbagemule.MobArena; package com.garbagemule.MobArena;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -39,6 +40,11 @@ public class RewardManager
players.get(p).add(stack); players.get(p).add(stack);
} }
public List<ItemStack> getRewards(Player p) {
List<ItemStack> rewards = players.get(p);
return (rewards == null ? new ArrayList<ItemStack>(1) : Collections.unmodifiableList(rewards));
}
public void grantRewards(Player p) { public void grantRewards(Player p) {
if (rewarded.contains(p)) return; if (rewarded.contains(p)) return;

View File

@ -18,6 +18,7 @@ import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.MonsterManager; import com.garbagemule.MobArena.MonsterManager;
import com.garbagemule.MobArena.RewardManager; import com.garbagemule.MobArena.RewardManager;
import com.garbagemule.MobArena.leaderboards.Leaderboard; import com.garbagemule.MobArena.leaderboards.Leaderboard;
import com.garbagemule.MobArena.log.ArenaLog;
import com.garbagemule.MobArena.region.ArenaRegion; import com.garbagemule.MobArena.region.ArenaRegion;
import com.garbagemule.MobArena.repairable.Repairable; import com.garbagemule.MobArena.repairable.Repairable;
import com.garbagemule.MobArena.util.config.ConfigSection; import com.garbagemule.MobArena.util.config.ConfigSection;
@ -101,6 +102,8 @@ public interface Arena
public void revivePlayer(Player p); public void revivePlayer(Player p);
public ArenaLog getLog();