Made changes GI suggested

This commit is contained in:
Sam 2018-06-29 00:38:13 +01:00 committed by Alexander Meech
parent 29a1619011
commit 01ae8aafa6
7 changed files with 41 additions and 78 deletions

View File

@ -38,7 +38,6 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.ClearCombatEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -351,12 +350,13 @@ public class CombatManager extends MiniPlugin
{
event.setDeathMessage(null);
if (!_active.containsKey(event.getEntity().getUniqueId()))
CombatLog log = _active.remove(event.getEntity().getUniqueId());
if (log == null)
{
return;
}
CombatLog log = _active.remove(event.getEntity().getUniqueId());
log.SetDeathTime(System.currentTimeMillis());
// Save Death
@ -411,7 +411,7 @@ public class CombatManager extends MiniPlugin
// Killed
String killedColor = log.GetKilledColor();
String deadPlayer = killedColor + event.getEntity().getName();
List<String> messages = new ArrayList<>();
String message = "";
// Killer
if (log.GetKiller() != null)
@ -427,31 +427,31 @@ public class CombatManager extends MiniPlugin
String weapon = (String) log.GetKiller().GetDamage().getFirst().getMetadata().get("customWeapon");
weapon = weapon == null ? log.GetKiller().GetLastDamageSource() : weapon;
messages.add(F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + killPlayer + C.mBody + " with " + F.item(weapon) + "."));
message = F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + killPlayer + C.mBody + " with " + F.item(weapon) + ".");
}
// No Killer
else
{
if (log.GetAttackers().isEmpty())
{
messages.add(F.main(getName(), deadPlayer + C.mBody + " has died."));
message = F.main(getName(), deadPlayer + C.mBody + " has died.");
}
else
{
if (log.GetLastDamager() != null && log.GetLastDamager().GetReason() != null && log.GetLastDamager().GetReason().length() > 1)
{
messages.add(F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetLastDamager().GetReason())) + C.mBody + ".");
message = F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetLastDamager().GetReason())) + C.mBody + ".";
}
else
{
messages.add(F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
message = F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".";
}
}
}
String finalMessage = message + combatEvent.getSuffix();
// Tell all players simple info
String[] messagesArray = messages.toArray(new String[0]);
combatEvent.getPlayersToInform().forEach(player -> player.sendMessage(messagesArray));
combatEvent.getPlayersToInform().forEach(player -> player.sendMessage(finalMessage));
// Tell the player who died it all
event.getEntity().sendMessage(messageType == DeathMessageType.Absolute ? log.DisplayAbsolute().toArray(new String[0]) : log.Display().toArray(new String[0]));
@ -480,21 +480,21 @@ public class CombatManager extends MiniPlugin
if (killer != null)
{
killer.sendMessage(F.main(getName(), "You " + combatEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "."));
killer.sendMessage(F.main(getName(), "You " + combatEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "." + combatEvent.getSuffix()));
}
event.getEntity().sendMessage(F.main(getName(), killPlayer + C.mBody + " " + combatEvent.getKilledWord() + " you with " + F.item(weapon) + "."));
event.getEntity().sendMessage(F.main(getName(), killPlayer + C.mBody + " " + combatEvent.getKilledWord() + " you with " + F.item(weapon) + "." + combatEvent.getSuffix()));
}
else
{
if (log.GetAttackers().isEmpty())
{
UtilPlayer.message(event.getEntity(), F.main(getName(), "You have died."));
UtilPlayer.message(event.getEntity(), F.main(getName(), "You have died." + combatEvent.getSuffix()));
}
else
{
UtilPlayer.message(event.getEntity(), F.main(getName(), "You were " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
UtilPlayer.message(event.getEntity(), F.main(getName(), "You were " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + "." + combatEvent.getSuffix());
}
}
}
@ -510,31 +510,16 @@ public class CombatManager extends MiniPlugin
log.ExpireOld();
}
public void Add(Player player)
public CombatLog Add(Player player)
{
_active.put(player.getUniqueId(), new CombatLog(player, 15000));
}
@EventHandler(priority = EventPriority.HIGHEST)
public void Clear(ClearCombatEvent event)
{
_active.remove(event.GetPlayer().getUniqueId());
CombatLog log = new CombatLog(player, ExpireTime);
_active.put(player.getUniqueId(), log);
return log;
}
public CombatLog Get(Player player)
{
if (!_active.containsKey(player.getUniqueId()))
{
Add(player);
}
return _active.get(player.getUniqueId());
}
public long GetExpireTime()
{
return ExpireTime;
return _active.getOrDefault(player.getUniqueId(), Add(player));
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -569,9 +554,4 @@ public class CombatManager extends MiniPlugin
{
_attackReason = var;
}
public AttackReason getUseWeapoName()
{
return _attackReason;
}
}

View File

@ -1,32 +0,0 @@
package mineplex.minecraft.game.core.combat.event;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ClearCombatEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private Player _player;
public ClearCombatEvent(Player player)
{
_player = player;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public Player GetPlayer()
{
return _player;
}
}

View File

@ -10,7 +10,6 @@ import mineplex.minecraft.game.core.combat.DeathMessageType;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
public class CombatDeathEvent extends Event
@ -23,7 +22,7 @@ public class CombatDeathEvent extends Event
private final List<Player> _playersToInform;
private DeathMessageType _messageType = DeathMessageType.Detailed;
private String _killedWord;
private String _killedWord, _suffix;
public CombatDeathEvent(PlayerDeathEvent event, ClientCombat clientCombat, CombatLog log, String killedWord)
{
@ -31,6 +30,7 @@ public class CombatDeathEvent extends Event
_clientCombat = clientCombat;
_log = log;
_killedWord = killedWord;
_suffix = "";
_playersToInform = new ArrayList<>(event.getEntity().getWorld().getPlayers());
}
@ -83,4 +83,14 @@ public class CombatDeathEvent extends Event
{
_killedWord = killedWord;
}
public void setSuffix(String suffix)
{
_suffix = suffix;
}
public String getSuffix()
{
return _suffix;
}
}

View File

@ -102,7 +102,8 @@ public class CakeWars extends TeamGame
"Purchasing the Resource Generator upgrade in the Nether Star shop increases the number of resources your generator creates.",
"Balance attacking and defending.",
"All players standing on the Resource Generator get the items generated.",
"Don't want to see hologram and chat tips? Turn them off in /prefs."
"Don't want to see hologram and chat tips? Turn them off in /prefs.",
"Watch out for Polly The Sheep, if you see her, kill her quick. Otherwise you might just lose your cake."
};
private static final int RESPAWN_TIME = 6;
/**

View File

@ -116,7 +116,7 @@ public class CakeBatModule extends CakeModule
if (UtilEnt.onBlock(player) && ticks % 8 == 0)
{
player.sendMessage(F.main("Game", "Return to an island! If you don't bats will begin to attack you!"));
UtilTextBottom.display(C.cRedB + "Return to the surface!", player);
UtilTextBottom.display(C.cRedB + "Return to an island!", player);
player.playSound(location, Sound.NOTE_STICKS, 1, 0.5F);
}
}

View File

@ -48,14 +48,14 @@ public class CakeSheep extends CakeSpecialItem implements Listener
.addLore(
"",
"Spawns Polly The Sheep...",
"After " + C.cRed + "5 seconds" + C.cGray + " she explodes destroying",
"After " + C.cRed + "4 seconds" + C.cGray + " she explodes destroying",
"nearby player placed blocks.",
"If she is killed she does not explode.",
"Warning! Polly has a", C.cRed + "20 second" + C.cGray + " cooldown between uses."
)
.setUnbreakable(true)
.build();
private static final long EXPLOSION_TIME = TimeUnit.SECONDS.toMillis(5);
private static final long EXPLOSION_TIME = TimeUnit.SECONDS.toMillis(4);
private static final int EXPLOSION_RADIUS = 7;
private static final int NO_PLACE_RADIUS_SQUARED = 225;
@ -188,7 +188,7 @@ public class CakeSheep extends CakeSpecialItem implements Listener
sheep.setCustomName((tick % 2 == 0 ? cakeTeam.getGameTeam().GetColor() + C.Bold : C.cWhiteB) + format.format(left / 1000D));
if (tick % 6 == 0)
if (tick % 8 == 0)
{
location.getWorld().playSound(sheepLocation, Sound.SHEEP_IDLE, 2, 0.8F);
}

View File

@ -525,6 +525,10 @@ public class CakeTeamModule extends CakeModule
event.getPlayersToInform().removeIf(other -> (killerTeam == null || !killerTeam.HasPlayer(other)) && !team.HasPlayer(other));
}
else
{
event.setSuffix(C.cAquaB + " ELIMINATION");
}
}
@EventHandler(priority = EventPriority.HIGH)