Rewrite CombatLogModule

This commit is contained in:
samczsun 2016-10-08 22:46:40 -04:00
parent 70ed2e4fbb
commit 0c1f6cbedc
8 changed files with 453 additions and 290 deletions

View File

@ -312,4 +312,12 @@ public abstract class TeamGame extends Game
return players;
}
protected void removePlayerFromRejoin(String name)
{
RejoinTimes.remove(name);
RejoinKit.remove(name);
RejoinTeam.remove(name);
RejoinHealth.remove(name);
}
}

View File

@ -41,6 +41,9 @@ import nautilus.game.arcade.game.modules.SafezoneModule;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.game.modules.combatlog.CombatLogModule;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPC;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCExpiredEvent;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCKilledEvent;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPCPreSpawnEvent;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
@ -50,6 +53,7 @@ import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -403,6 +407,37 @@ public class UHC extends TeamGame
UtilPlayer.message(caller, F.main("Debug", "Cleaned up!"));
}
});
registerDebugCommand(new DebugCommand("setcombatlogtimeout", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
CombatLogModule module = getModule(CombatLogModule.class);
if (module == null)
{
UtilPlayer.message(caller, F.main("Debug", "The combat log module has not been loaded yet"));
return;
}
if (args.length == 0)
{
UtilPlayer.message(caller, F.main("Debug", "No timeout specified"));
return;
}
try
{
int timeout = Integer.parseInt(args[0]);
module.setCombatLogTime(timeout);
RejoinTime = timeout;
UtilPlayer.message(caller, F.main("Debug", "Set the new timeout to " + timeout));
}
catch (NumberFormatException ex)
{
UtilPlayer.message(caller, F.main("Debug", "That's not a number!"));
}
}
});
}
@ -726,73 +761,83 @@ public class UHC extends TeamGame
getModule(CompassModule.class)
.setGiveCompass(true);
new CombatLogModule()
.setSpawnForCreative(false)
.setCombatLogTime(300000)
.setOnDeathAction(npc ->
{
if (npc.getLastDamager() instanceof Player)
{
Player killer = (Player) npc.getLastDamager();
Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName()
+ C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer)
+ C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out.");
}
else
{
String cause = UtilParser.parseDamageCause(npc.getLastDamageCause());
if (npc.getLastDamager() != null)
{
cause = npc.getLastDamager().getName();
}
Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName()
+ C.cGray + C.Bold + " was killed by " + cause + " while logged out.");
}
ItemStack stack = new ItemBuilder(Material.SKULL_ITEM)
.setData((byte) 3)
.setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head")
.setPlayerHead(npc.getPlayerInfo().getName())
.build();
npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack);
Location location = npc.getNPC().getLocation();
for (ItemStack item : npc.getPlayerInfo().getItems())
{
location.getWorld().dropItemNaturally(location, item);
}
RejoinTimes.remove(npc.getPlayerInfo().getName());
RejoinKit.remove(npc.getPlayerInfo().getName());
RejoinTeam.remove(npc.getPlayerInfo().getName());
RejoinHealth.remove(npc.getPlayerInfo().getName());
})
.setOnExpireAction(npc ->
{
ItemStack stack = new ItemBuilder(Material.SKULL_ITEM)
.setData((byte) 3)
.setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head")
.setPlayerHead(npc.getPlayerInfo().getName())
.build();
npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack);
Location location = npc.getNPC().getLocation();
for (ItemStack item : npc.getPlayerInfo().getItems())
{
location.getWorld().dropItemNaturally(location, item);
}
RejoinTimes.remove(npc.getPlayerInfo().getName());
RejoinKit.remove(npc.getPlayerInfo().getName());
RejoinTeam.remove(npc.getPlayerInfo().getName());
RejoinHealth.remove(npc.getPlayerInfo().getName());
})
.setCombatLogTime((int) RejoinTime)
.register(this);
}
@EventHandler
public void preSpawnCombatLogNPC(CombatLogNPCPreSpawnEvent event)
{
if (event.getPlayer().getGameMode() == GameMode.CREATIVE)
{
event.setCancelled(true);
}
}
@EventHandler
public void combatLogNPCDeathEvent(CombatLogNPCKilledEvent event)
{
CombatLogNPC npc = event.getNpc();
if (npc.getLastDamager() instanceof Player)
{
Player killer = (Player) npc.getLastDamager();
Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName()
+ C.cGray + C.Bold + " was killed by " + getArcadeManager().GetColor(killer)
+ C.Bold + npc.getLastDamager().getName() + C.cGray + C.Bold + " while logged out.");
}
else
{
String cause = UtilParser.parseDamageCause(npc.getLastDamageCause());
if (npc.getLastDamager() != null)
{
cause = npc.getLastDamager().getName();
}
Announce(npc.getPlayerInfo().getTeamColor() + C.Bold + npc.getPlayerInfo().getName()
+ C.cGray + C.Bold + " was killed by " + cause + " while logged out.");
}
ItemStack stack = new ItemBuilder(Material.SKULL_ITEM)
.setData((byte) 3)
.setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head")
.setPlayerHead(npc.getPlayerInfo().getName())
.build();
npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack);
Location location = npc.getNPC().getLocation();
for (ItemStack item : npc.getPlayerInfo().getItems())
{
location.getWorld().dropItemNaturally(location, item);
}
removePlayerFromRejoin(npc.getPlayerInfo().getName());
}
@EventHandler
public void combatLogNpcExpireEvent(CombatLogNPCExpiredEvent event)
{
CombatLogNPC npc = event.getNpc();
ItemStack stack = new ItemBuilder(Material.SKULL_ITEM)
.setData((byte) 3)
.setTitle(npc.getPlayerInfo().getTeamColor() + npc.getPlayerInfo().getName() + "'s Head")
.setPlayerHead(npc.getPlayerInfo().getName())
.build();
npc.getNPC().getWorld().dropItemNaturally(npc.getNPC().getLocation(), stack);
Location location = npc.getNPC().getLocation();
for (ItemStack item : npc.getPlayerInfo().getItems())
{
location.getWorld().dropItemNaturally(location, item);
}
removePlayerFromRejoin(npc.getPlayerInfo().getName());
}
@EventHandler
public void EarlyGameUpdate(UpdateEvent event)
{

View File

@ -1,21 +1,14 @@
package nautilus.game.arcade.game.modules.combatlog;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParser;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -28,43 +21,49 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilParser;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/*
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
/**
* This module will spawn combat log NPCs for players who disconnect
*/
public class CombatLogModule extends Module
{
// The map of player UUIDs to their combat log NPCs
/**
* Map of UUIDs of players who are now offline, to their CombatLogNPCs
*/
private Map<UUID, CombatLogNPC> _logoutNpcs = new HashMap<>();
// The map of player UUIDs and who killed their combat logged NPC
/**
* Map of UUIDs of players who are now offline, and who killed them
*/
private Map<UUID, String> _killedBy = new HashMap<>();
// The time that combat log npcs will stay spawned for, in milliseconds
/**
* How long combat log NPCs will stay spawned in for, measured in milliseconds
*/
private int _spawnTime = 60000;
// Whether to notify the combat logged player on join if they have been killed
/**
* Whether to notify the combat logged player on join if they have been killed
*/
private boolean _notifyPlayer = true;
// Whether to spawn a combat log NPC for creative players
private boolean _spawnForCreative = true;
// The action to take once a combat logged NPC has died
private Consumer<CombatLogNPC> _onKill = npc ->
{
};
// The action to take once a combat logged NPC has expired
private Consumer<CombatLogNPC> _onExpire = npc ->
{
};
/**
* Whether to integrate with {@link CompassModule}
*/
private boolean _integrateWithCompassModule = true;
private int _locationTaskId = -1;
@ -85,8 +84,17 @@ public class CombatLogModule extends Module
if (compassModule != null)
{
compassModule.addSupplier(() ->
getAllNPCs()
getAllNPCs()
.stream()
.filter(ent ->
{
if (ent.getNPC() == null)
{
System.out.println("Null npc entity? " + ent.getPlayerInfo().getName() + " " + ent.getPlayerInfo().getUniqueId());
return false;
}
return true;
})
.map(npc -> new CompassEntry(npc.getNPC(), npc.getPlayerInfo().getName(), npc.getPlayerInfo().getName() + " (Disconnected)", npc.getPlayerInfo().getTeam(), npc.getPlayerInfo().getKit()))
.collect(Collectors.toList())
);
@ -110,44 +118,124 @@ public class CombatLogModule extends Module
return this;
}
public CombatLogModule setSpawnForCreative(boolean spawnForCreative)
{
this._spawnForCreative = spawnForCreative;
return this;
}
public CombatLogModule setOnDeathAction(Consumer<CombatLogNPC> action)
{
this._onKill = action;
return this;
}
public CombatLogModule setOnExpireAction(Consumer<CombatLogNPC> action)
{
this._onExpire = action;
return this;
}
public CombatLogModule setCombatLogTime(int time)
{
this._spawnTime = time;
return this;
}
/*
* Spawns a combat log NPC for the given player if that player does not already have one
*/
public void spawnLogoutNpc(Player player)
@EventHandler(priority = EventPriority.LOWEST)
public void on(PlayerQuitEvent event)
{
if (hasLogoutNpc(player))
return;
if (player.getGameMode() == GameMode.CREATIVE && !_spawnForCreative)
Player player = event.getPlayer();
if (getGame().InProgress() && getGame().IsAlive(player))
{
if (hasLogoutNpc(player))
return;
CombatLogNPCPreSpawnEvent preSpawnEvent = new CombatLogNPCPreSpawnEvent(player);
UtilServer.CallEvent(preSpawnEvent);
if (preSpawnEvent.isCancelled())
return;
CombatLogNPC npc = new CombatLogNPC(this, player);
_logoutNpcs.put(player.getUniqueId(), npc);
System.out.println(String.format("Spawned combat log NPC for %s!", player.getName()));
}
}
@EventHandler
public void onJoin(PlayerJoinEvent event)
{
if (hasLogoutNpc(event.getPlayer()))
{
despawnLogoutNpc(event.getPlayer());
}
if (_killedBy.containsKey(event.getPlayer().getUniqueId()))
{
String name = _killedBy.remove(event.getPlayer().getUniqueId());
if (_notifyPlayer && name != null)
{
UtilPlayer.message(event.getPlayer(), F.main("Combat Log", "While you were gone, you were killed by " + ChatColor.GREEN + name + C.mBody + "."));
}
}
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
if (logoutNpc == null)
return;
CombatLogNPC npc = new CombatLogNPC(this, player, getGame().getArcadeManager());
npc.spawn();
_logoutNpcs.put(player.getUniqueId(), npc);
System.out.println(String.format("Spawned combat log NPC for %s!", player.getName()));
CombatLogNPCKilledEvent npcKilledEvent = new CombatLogNPCKilledEvent(logoutNpc);
UtilServer.CallEvent(npcKilledEvent);
logoutNpc.despawn();
_logoutNpcs.remove(logoutNpc.getPlayerInfo().getUniqueId());
event.getDrops().clear(); // Clear the entity's item drops. If drops are wanted they should be dropped in the event
if (logoutNpc.getLastDamager() != null)
{
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), logoutNpc.getLastDamager().getName());
}
else
{
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), UtilParser.parseDamageCause(logoutNpc.getLastDamageCause()));
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamaged(EntityDamageEvent event)
{
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
if (logoutNpc == null)
return;
LivingEntity damager = UtilEvent.GetDamagerEntity(event, true);
Player damagerPlayer = null;
if (damager instanceof Player)
{
damagerPlayer = (Player) damager;
}
if (getGame() instanceof TeamGame && damagerPlayer != null)
{
GameTeam damagerTeam = getGame().GetTeam(damagerPlayer);
if (damagerTeam == logoutNpc.getPlayerInfo().getTeam())
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void recordDamage(EntityDamageEvent event)
{
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
if (logoutNpc == null)
return;
logoutNpc.getNPC().getWorld().playSound(logoutNpc.getNPC().getLocation(), Sound.HURT_FLESH, 1, 1);
logoutNpc.recordDamage(event);
if (getGame() instanceof TeamGame)
{
getGame().getArcadeManager().runSync(() ->
{
CombatLogNPC npc = getLogoutNpc(event.getEntity());
if (npc != null)
{
((TeamGame) getGame()).RejoinHealth.put(npc.getPlayerInfo().getName(), npc.getNPC().getHealth());
}
});
}
}
public boolean hasLogoutNpc(Player player)
@ -172,42 +260,12 @@ public class CombatLogModule extends Module
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void on(PlayerQuitEvent event)
{
if (getGame().InProgress() && getGame().IsAlive(event.getPlayer()))
{
spawnLogoutNpc(event.getPlayer());
}
}
@EventHandler
public void on(PlayerJoinEvent event)
{
if (hasLogoutNpc(event.getPlayer()))
{
despawnLogoutNpc(event.getPlayer());
}
if (_killedBy.containsKey(event.getPlayer().getUniqueId()))
{
String name = _killedBy.remove(event.getPlayer().getUniqueId());
if (_notifyPlayer && name != null)
{
UtilPlayer.message(event.getPlayer(), F.main("Combat Log", "While you were gone, you were killed by " + ChatColor.GREEN + name + C.mBody + "."));
}
}
}
@Override
public void cleanup()
{
System.out.println("Killing combat log NPCs");
for (CombatLogNPC npc : _logoutNpcs.values())
{
npc.despawn();
}
_logoutNpcs.values().forEach(CombatLogNPC::despawn);
_logoutNpcs.clear();
_killedBy.clear();
@ -228,67 +286,6 @@ public class CombatLogModule extends Module
}
}
@EventHandler(ignoreCancelled = true)
public void onEntityDeath(EntityDeathEvent event)
{
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
if (logoutNpc == null)
return;
_onKill.accept(logoutNpc);
logoutNpc.onDeath();
event.getDrops().clear(); // Clear the entity's item drops. If drops are wanted they can be added
if (logoutNpc.getLastDamager() != null)
{
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), logoutNpc.getLastDamager().getName());
}
else
{
_killedBy.put(logoutNpc.getPlayerInfo().getUniqueId(), UtilParser.parseDamageCause(logoutNpc.getLastDamageCause()));
}
}
@EventHandler(ignoreCancelled = true)
public void onEntityDamaged(EntityDamageEvent event)
{
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
if (logoutNpc != null)
{
LivingEntity damager = UtilEvent.GetDamagerEntity(event, true);
Player damagerPlayer = null;
if (damager instanceof Player)
{
damagerPlayer = (Player) damager;
}
if (getGame() instanceof TeamGame && damagerPlayer != null)
{
GameTeam damagerTeam = getGame().GetTeam(damagerPlayer);
if (damagerTeam == logoutNpc.getPlayerInfo().getTeam())
{
event.setCancelled(true);
return;
}
}
logoutNpc.getNPC().getWorld().playSound(logoutNpc.getNPC().getLocation(), Sound.HURT_FLESH, 1, 1);
if (getGame() instanceof TeamGame)
{
getGame().getArcadeManager().runSync(() ->
{
((TeamGame) getGame()).RejoinHealth.put(logoutNpc.getPlayerInfo().getName(), logoutNpc.getNPC().getHealth());
});
}
logoutNpc.handleDamageEvent(event);
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
@ -305,24 +302,45 @@ public class CombatLogModule extends Module
{
CombatLogNPC npc = iterator.next();
if (Bukkit.getPlayerExact(npc.getPlayerInfo().getName()) != null)
if (npc.getNPC() == null)
{
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 1");
npc.despawn();
iterator.remove();
try
{
new IllegalArgumentException("Strange, the NPC with data " + npc.getPlayerInfo().getName() + " " + npc.getPlayerInfo().getUniqueId() + " was null").printStackTrace();
}
catch (Throwable t)
{
t.printStackTrace();
}
finally
{
iterator.remove();
}
}
else if (!npc.isAlive())
else
{
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2");
npc.despawn();
iterator.remove();
}
else if (npc.getAliveDuation() > this._spawnTime)
{
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 3");
_onExpire.accept(npc);
npc.despawn();
iterator.remove();
if (Bukkit.getPlayerExact(npc.getPlayerInfo().getName()) != null)
{
// Should never happen
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 1");
npc.despawn();
iterator.remove();
}
else if (!npc.isAlive())
{
// Should never happen
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 2");
npc.despawn();
iterator.remove();
}
else if (npc.getAliveDuation() > this._spawnTime)
{
System.out.println("Removing NPC " + npc.getPlayerInfo().getName() + " for 3");
CombatLogNPCExpiredEvent expiredEvent = new CombatLogNPCExpiredEvent(npc);
UtilServer.CallEvent(expiredEvent);
npc.despawn();
iterator.remove();
}
}
}
}

View File

@ -1,13 +1,19 @@
package nautilus.game.arcade.game.modules.combatlog;
import net.minecraft.server.v1_8_R3.EntityCreeper;
import net.minecraft.server.v1_8_R3.EntitySkeleton;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.hologram.Hologram;
import nautilus.game.arcade.ArcadeManager;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creeper;
@ -21,8 +27,6 @@ import org.bukkit.metadata.FixedMetadataValue;
public class CombatLogNPC
{
private CombatLogModule _module;
private PlayerInfo _playerInfo;
private Hologram _hologram;
@ -39,29 +43,21 @@ public class CombatLogNPC
private EntityDamageEvent.DamageCause _lastDamageCause;
private Entity _lastDamager;
public CombatLogNPC(CombatLogModule module, Player player, ArcadeManager arcadeManager)
CombatLogNPC(CombatLogModule module, Player player)
{
this._module = module;
ArcadeManager arcadeManager = module.getGame().getArcadeManager();
_playerInfo = new PlayerInfo(player, arcadeManager);
_endingTime = System.currentTimeMillis() + this._module.getSpawnTime();
_disguiseManager = arcadeManager.GetDisguise();
_spawnDate = System.currentTimeMillis();
_endingTime = System.currentTimeMillis() + module.getSpawnTime();
_hologram = new Hologram(arcadeManager.getHologramManager(), player.getEyeLocation().add(0, 1, 0), "Quitting in " + UtilTime.MakeStr(Math.max(_endingTime - System.currentTimeMillis(), 0)));
_spawnDate = 0;
_spawnHealth = player.getHealth();
_maxHealth = player.getMaxHealth();
_hologram.start();
}
/**
* Called when the {@code _npc} associated with this CombatLogNPC is killed
* and thus drops all the owner's items.
*/
public void onDeath()
{
despawn();
_npc = spawnNpc(player);
}
public void update()
@ -91,14 +87,6 @@ public class CombatLogNPC
return System.currentTimeMillis() - _spawnDate;
}
public void spawn()
{
if (_npc != null) despawn();
_npc = spawnNpc(getPlayer());
_spawnDate = System.currentTimeMillis();
}
public void despawn()
{
if (_disguise != null)
@ -130,15 +118,27 @@ public class CombatLogNPC
return _playerInfo;
}
public Player getPlayer()
public LivingEntity getNPC()
{
return _playerInfo.getPlayer();
return this._npc;
}
public EntityDamageEvent.DamageCause getLastDamageCause()
{
return _lastDamageCause;
}
public Entity getLastDamager()
{
return _lastDamager;
}
private LivingEntity spawnNpc(Player player)
{
Location spawnLoc = player.getLocation();
LivingEntity skel = player.getWorld().spawn(spawnLoc, Creeper.class);
EntityCreeper entityCreeper = new EntityCreeper(((CraftWorld) spawnLoc.getWorld()).getHandle());
LivingEntity skel = (LivingEntity) entityCreeper.getBukkitEntity();
skel.teleport(spawnLoc);
skel.setRemoveWhenFarAway(false);
skel.setMetadata("CombatLogNPC", new FixedMetadataValue(_disguiseManager.getPlugin(), player.getUniqueId().toString()));
skel.teleport(spawnLoc);
@ -165,17 +165,7 @@ public class CombatLogNPC
return skel;
}
public Entity getLastDamager()
{
return _lastDamager;
}
public LivingEntity getNPC()
{
return this._npc;
}
public void handleDamageEvent(EntityDamageEvent event)
void recordDamage(EntityDamageEvent event)
{
this._lastDamageCause = event.getCause();
if (event instanceof EntityDamageByEntityEvent)
@ -188,9 +178,4 @@ public class CombatLogNPC
this._lastDamager = null;
}
}
public EntityDamageEvent.DamageCause getLastDamageCause()
{
return _lastDamageCause;
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.game.modules.combatlog;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CombatLogNPCExpiredEvent extends Event
{
private static final HandlerList HANDLERS = new HandlerList();
private final CombatLogNPC _npc;
public CombatLogNPCExpiredEvent(CombatLogNPC npc)
{
_npc = npc;
}
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
public static HandlerList getHandlerList()
{
return HANDLERS;
}
public CombatLogNPC getNpc()
{
return _npc;
}
}

View File

@ -0,0 +1,32 @@
package nautilus.game.arcade.game.modules.combatlog;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CombatLogNPCKilledEvent extends Event
{
private static final HandlerList HANDLERS = new HandlerList();
private final CombatLogNPC _npc;
public CombatLogNPCKilledEvent(CombatLogNPC npc)
{
_npc = npc;
}
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
public static HandlerList getHandlerList()
{
return HANDLERS;
}
public CombatLogNPC getNpc()
{
return _npc;
}
}

View File

@ -0,0 +1,48 @@
package nautilus.game.arcade.game.modules.combatlog;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CombatLogNPCPreSpawnEvent extends Event implements Cancellable
{
private static final HandlerList HANDLERS = new HandlerList();
private final Player _player;
private boolean _cancelled;
public CombatLogNPCPreSpawnEvent(Player player)
{
_player = player;
}
@Override
public HandlerList getHandlers()
{
return HANDLERS;
}
public static HandlerList getHandlerList()
{
return HANDLERS;
}
public Player getPlayer()
{
return _player;
}
@Override
public boolean isCancelled()
{
return _cancelled;
}
@Override
public void setCancelled(boolean b)
{
_cancelled = b;
}
}

View File

@ -28,7 +28,7 @@ public class PlayerInfo
private GameTeam _team;
private Kit _kit;
public PlayerInfo(Player player, ArcadeManager arcadeManager)
PlayerInfo(Player player, ArcadeManager arcadeManager)
{
_playerName = player.getName();
_playerUuid = player.getUniqueId();
@ -51,11 +51,6 @@ public class PlayerInfo
return _playerUuid;
}
public Player getPlayer()
{
return Bukkit.getPlayerExact(_playerName);
}
public ChatColor getTeamColor()
{
return _teamColor;