Mess around the CombatManager and World Borders

This commit is contained in:
Sam 2018-06-19 21:38:05 +01:00 committed by Alexander Meech
parent 5aeb44c30d
commit 3054ac2cfb
26 changed files with 934 additions and 684 deletions

View File

@ -502,6 +502,7 @@ public enum GameKit
new String[]
{
"Fully charged arrows break blocks!",
receiveItem("Arrow", 1) + " for each kill.",
C.blankLine,
receiveArrow(1, 6, 3)
},

View File

@ -152,10 +152,10 @@ import mineplex.minecraft.game.classcombat.Class.ClientClass;
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.Skill.Assassin.Blink;
import mineplex.minecraft.game.classcombat.Skill.Assassin.Flash;
import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent;
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
import mineplex.minecraft.game.classcombat.item.ItemFactory;
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
@ -295,7 +295,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_incognitoManager = incognitoManager;
_serverName = serverName;
_clientManager = clientManager;
_combatManager = new CombatManager(plugin);
_combatManager = require(CombatManager.class);
_hologramManager = hologramManager;
_chat = chat;

View File

@ -169,7 +169,7 @@ public class ClansHub extends JavaPlugin
new EternalGiveawayManager(this, clientManager, serverStatusManager);
CombatManager combatManager = new CombatManager(this);
CombatManager combatManager = require(CombatManager.class);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition);

View File

@ -170,7 +170,7 @@ public class Hub extends JavaPlugin implements IRelation
new SnapshotPlugin(this, snapshotManager, clientManager);
new ReportPlugin(this, reportManager);
CombatManager combatManager = new CombatManager(this);
CombatManager combatManager = require(CombatManager.class);
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, conditionManager);
conditionManager.setDamageManager(damage);

View File

@ -1,11 +1,16 @@
package mineplex.minecraft.game.core.combat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.ItemStack;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
@ -18,13 +23,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer;
@ -36,8 +41,8 @@ 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;
import net.minecraft.server.v1_8_R3.ItemStack;
@ReflectivelyCreateMiniPlugin
public class CombatManager extends MiniPlugin
{
public enum AttackReason
@ -46,208 +51,122 @@ public class CombatManager extends MiniPlugin
CustomWeaponName,
DefaultWeaponName
}
private NautHashMap<UUID, CombatLog> _active = new NautHashMap<>();
private Map<UUID, ClientCombat> _combatClients = new HashMap<>();
private HashSet<UUID> _removeList = new HashSet<>();
private final Map<UUID, CombatLog> _active = new HashMap<>();
private final Map<UUID, ClientCombat> _combatClients = new HashMap<>();
private final Set<UUID> _removeList = new HashSet<>();
protected long ExpireTime = 15000;
protected AttackReason _attackReason = AttackReason.CustomWeaponName;
public CombatManager(JavaPlugin plugin)
public CombatManager()
{
super("Combat", plugin);
super("Death");
}
@EventHandler
public void UnloadDonor(ClientUnloadEvent event)
public void unload(ClientUnloadEvent event)
{
_combatClients.remove(event.getUniqueId());
}
public ClientCombat Get(UUID uuid)
{
if (!_combatClients.containsKey(uuid))
_combatClients.put(uuid, new ClientCombat());
return _combatClients.get(uuid);
return _combatClients.computeIfAbsent(uuid, k -> new ClientCombat());
}
//This is a backup, for when CustomDamageEvent is disabled (manually)
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void AddAttack(EntityDamageEvent event)
{
if (event.isCancelled())
return;
if (event.getEntity() == null || !(event.getEntity() instanceof Player))
{
return;
Player damagee = (Player)event.getEntity();
}
Player damagee = (Player) event.getEntity();
LivingEntity damagerEnt = UtilEvent.GetDamagerEntity(event, true);
//Attacked by Entity
if (damagerEnt != null)
{
if (damagerEnt instanceof Player)
Get((Player)damagerEnt).SetLastCombat(System.currentTimeMillis());
String cause = "";
switch(event.getCause())
{
case ENTITY_ATTACK:
cause = "Attack";
break;
case ENTITY_EXPLOSION:
cause = "Explosion";
break;
case MAGIC:
cause = "Thrown Potion";
break;
case PROJECTILE:
cause = "Ranged Weapon";
break;
case THORNS:
cause = "Thorns Enchantment";
break;
default:
cause = event.getCause() + "";
break;
Get((Player) damagerEnt).SetLastCombat(System.currentTimeMillis());
}
String cause;
switch (event.getCause())
{
case ENTITY_ATTACK:
cause = "Attack";
break;
case ENTITY_EXPLOSION:
cause = "Explosion";
break;
case MAGIC:
cause = "Thrown Potion";
break;
case PROJECTILE:
cause = "Ranged Weapon";
break;
case THORNS:
cause = "Thorns Enchantment";
break;
default:
cause = event.getCause() + "";
break;
}
if (UtilEvent.isBowDamage(event))
{
cause = "Bow";
}
if (damagerEnt instanceof Player)
{
if (event.getCause() == DamageCause.ENTITY_ATTACK)
{
Player player = (Player) damagerEnt;
if (player.getItemInHand() == null)
{
cause = "Fists";
}
else if (player.getItemInHand().getType() == Material.AIR)
{
cause = "Fists";
}
else
{
cause = ItemStackFactory.Instance.GetName(player.getItemInHand(), false);
}
}
}
Get(damagee).Attacked(
UtilEnt.getName(damagerEnt),
event.getDamage(), damagerEnt,
cause, null);
Get(damagee).Attacked(UtilEnt.getName(damagerEnt), event.getDamage(), damagerEnt, cause, null);
}
// Damager is WORLD
else
{
DamageCause cause = event.getCause();
Pair<String, String> source = getSourceAndReason(cause);
String source = "?";
String reason = "-";
if (cause == DamageCause.BLOCK_EXPLOSION)
{
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.CONTACT)
{
source = "Cactus";
reason = "-";
} else if (cause == DamageCause.CUSTOM)
{
source = "Custom";
reason = "-";
} else if (cause == DamageCause.DROWNING)
{
source = "Water";
reason = "-";
} else if (cause == DamageCause.ENTITY_ATTACK)
{
source = "Entity";
reason = "Attack";
} else if (cause == DamageCause.ENTITY_EXPLOSION)
{
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.FALL)
{
source = "Fall";
reason = "-";
} else if (cause == DamageCause.FALLING_BLOCK)
{
source = "Falling Block";
reason = "-";
} else if (cause == DamageCause.FIRE)
{
source = "Fire";
reason = "-";
} else if (cause == DamageCause.FIRE_TICK)
{
source = "Fire";
reason = "-";
} else if (cause == DamageCause.LAVA)
{
source = "Lava";
reason = "-";
} else if (cause == DamageCause.LIGHTNING)
{
source = "Lightning";
reason = "-";
} else if (cause == DamageCause.MAGIC)
{
source = "Magic";
reason = "-";
} else if (cause == DamageCause.MELTING)
{
source = "Melting";
reason = "-";
} else if (cause == DamageCause.POISON)
{
source = "Poison";
reason = "-";
} else if (cause == DamageCause.PROJECTILE)
{
source = "Projectile";
reason = "-";
} else if (cause == DamageCause.STARVATION)
{
source = "Starvation";
reason = "-";
} else if (cause == DamageCause.SUFFOCATION)
{
source = "Suffocation";
reason = "-";
} else if (cause == DamageCause.SUICIDE)
{
source = "Suicide";
reason = "-";
} else if (cause == DamageCause.VOID)
{
source = "Void";
reason = "-";
} else if (cause == DamageCause.WITHER)
{
source = "Wither";
reason = "-";
}
Get(damagee).Attacked(source,
event.getDamage(), null, reason, null);
Get(damagee).Attacked(source.getLeft(), event.getDamage(), null, source.getRight(), null);
}
}
public void AddAttack(CustomDamageEvent event)
{
// Not Player > No Log
if (event.GetDamageePlayer() == null)
{
return;
}
// Damager is ENTITY
if (event.GetDamagerEntity(true) != null)
{
@ -259,19 +178,21 @@ public class CombatManager extends MiniPlugin
{
Player damager = event.GetDamagerPlayer(false);
reason = "Attack";
if (_attackReason == AttackReason.DefaultWeaponName)
{
reason = "Fists";
if (damager.getItemInHand() != null)
{
byte data = 0;
if (damager.getItemInHand().getData() != null)
{
data = damager.getItemInHand().getData().getData();
}
reason = ItemStackFactory.Instance.GetName(damager.getItemInHand().getType(), data, false);
}
}
@ -291,127 +212,138 @@ public class CombatManager extends MiniPlugin
}
}
}
}
}
else if (event.GetProjectile() != null)
{
if (event.GetProjectile() instanceof Arrow)
{
reason = "Archery";
}
else if (event.GetProjectile() instanceof Fireball)
{
reason = "Fireball";
}
}
}
if (event.GetDamagerEntity(true) instanceof Player)
{
Get((Player)event.GetDamagerEntity(true)).SetLastCombat(System.currentTimeMillis());
Get((Player)event.GetDamagerEntity(true)).SetLastCombatEngaged(System.currentTimeMillis());
Get(event.GetDamagerPlayer(true)).SetLastCombat(System.currentTimeMillis());
Get(event.GetDamagerPlayer(true)).SetLastCombatEngaged(System.currentTimeMillis());
Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis());
}
Get(event.GetDamageePlayer()).Attacked(
UtilEnt.getName(event.GetDamagerEntity(true)),
(int) event.GetDamage(), event.GetDamagerEntity(true),
reason, event.GetDamageMod(), event.getMetadata());
Get(event.GetDamageePlayer()).Attacked(UtilEnt.getName(event.GetDamagerEntity(true)), (int) event.GetDamage(), event.GetDamagerEntity(true), reason, event.GetDamageMod(), event.getMetadata());
}
// Damager is WORLD
else
{
DamageCause cause = event.GetCause();
Pair<String, String> source = getSourceAndReason(cause);
String source = "?";
String reason = "-";
if (cause == DamageCause.BLOCK_EXPLOSION)
if (event.GetReason() != null)
{
source.setRight(event.GetReason());
}
Get(event.GetDamageePlayer()).Attacked(source.getLeft(), (int) event.GetDamage(), null, source.getRight(), event.GetDamageMod(), event.getMetadata());
}
}
private Pair<String, String> getSourceAndReason(DamageCause cause)
{
String source = "?";
String reason = "-";
switch (cause)
{
case BLOCK_EXPLOSION:
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.CONTACT)
{
break;
case CONTACT:
source = "Cactus";
reason = "-";
} else if (cause == DamageCause.CUSTOM)
{
break;
case CUSTOM:
source = "Custom";
reason = "-";
} else if (cause == DamageCause.DROWNING)
{
break;
case DROWNING:
source = "Water";
reason = "-";
} else if (cause == DamageCause.ENTITY_ATTACK)
{
break;
case ENTITY_ATTACK:
source = "Entity";
reason = "Attack";
} else if (cause == DamageCause.ENTITY_EXPLOSION)
{
break;
case ENTITY_EXPLOSION:
source = "Explosion";
reason = "-";
} else if (cause == DamageCause.FALL)
{
break;
case FALL:
source = "Fall";
reason = "-";
} else if (cause == DamageCause.FALLING_BLOCK)
{
break;
case FALLING_BLOCK:
source = "Falling Block";
reason = "-";
} else if (cause == DamageCause.FIRE)
{
break;
case FIRE:
source = "Fire";
reason = "-";
} else if (cause == DamageCause.FIRE_TICK)
{
break;
case FIRE_TICK:
source = "Fire";
reason = "-";
} else if (cause == DamageCause.LAVA)
{
break;
case LAVA:
source = "Lava";
reason = "-";
} else if (cause == DamageCause.LIGHTNING)
{
break;
case LIGHTNING:
source = "Lightning";
reason = "-";
} else if (cause == DamageCause.MAGIC)
{
break;
case MAGIC:
source = "Magic";
reason = "-";
} else if (cause == DamageCause.MELTING)
{
break;
case MELTING:
source = "Melting";
reason = "-";
} else if (cause == DamageCause.POISON)
{
break;
case POISON:
source = "Poison";
reason = "-";
} else if (cause == DamageCause.PROJECTILE)
{
break;
case PROJECTILE:
source = "Projectile";
reason = "-";
} else if (cause == DamageCause.STARVATION)
{
break;
case STARVATION:
source = "Starvation";
reason = "-";
} else if (cause == DamageCause.SUFFOCATION)
{
break;
case SUFFOCATION:
source = "Suffocation";
reason = "-";
} else if (cause == DamageCause.SUICIDE)
{
break;
case SUICIDE:
source = "Suicide";
reason = "-";
} else if (cause == DamageCause.VOID)
{
break;
case VOID:
source = "Void";
reason = "-";
} else if (cause == DamageCause.WITHER)
{
break;
case WITHER:
source = "Wither";
reason = "-";
}
if (event.GetReason() != null)
reason = event.GetReason();
Get(event.GetDamageePlayer()).Attacked(source,
(int) event.GetDamage(), null, reason, event.GetDamageMod(), event.getMetadata());
break;
}
return Pair.create(source, reason);
}
@EventHandler(priority = EventPriority.LOW)
@ -420,7 +352,9 @@ public class CombatManager extends MiniPlugin
event.setDeathMessage(null);
if (!_active.containsKey(event.getEntity().getUniqueId()))
{
return;
}
CombatLog log = _active.remove(event.getEntity().getUniqueId());
log.SetDeathTime(System.currentTimeMillis());
@ -432,114 +366,97 @@ public class CombatManager extends MiniPlugin
int assists = 0;
for (int i = 0; i < log.GetAttackers().size(); i++)
{
if (!log.GetAttackers().get(i).IsPlayer())
continue;
CombatComponent attacker = log.GetAttackers().get(i);
if (UtilTime.elapsed(log.GetAttackers().get(i).GetLastDamage(),
ExpireTime))
if (!attacker.IsPlayer() || UtilTime.elapsed(attacker.GetLastDamage(), ExpireTime))
{
continue;
}
if (log.GetKiller() == null)
{
log.SetKiller(log.GetAttackers().get(i));
log.SetKiller(attacker);
ClientCombat killerClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity());
ClientCombat killerClient = Get(attacker.getUniqueIdOfEntity());
if (killerClient != null)
{
killerClient.GetKills().addFirst(log);
}
}
else
{
assists++;
ClientCombat assistClient = Get(log.GetAttackers().get(i).getUniqueIdOfEntity());
ClientCombat assistClient = Get(attacker.getUniqueIdOfEntity());
if (assistClient != null)
{
assistClient.GetAssists().addFirst(log);
}
}
}
log.SetAssists(assists);
// Event
CombatDeathEvent deathEvent = new CombatDeathEvent(event, Get(event.getEntity().getUniqueId()), log, "killed");
UtilServer.getServer().getPluginManager().callEvent(deathEvent);
CombatDeathEvent combatEvent = new CombatDeathEvent(event, Get(event.getEntity().getUniqueId()), log, "killed");
UtilServer.CallEvent(combatEvent);
//XXX Death MSG
if (deathEvent.GetBroadcastType() == DeathMessageType.Detailed || deathEvent.GetBroadcastType() == DeathMessageType.Absolute)
DeathMessageType messageType = combatEvent.GetBroadcastType();
//Death Message
if (messageType == DeathMessageType.Detailed || messageType == DeathMessageType.Absolute)
{
//Display Simple
for (Player cur : event.getEntity().getWorld().getPlayers())
// Killed
String killedColor = log.GetKilledColor();
String deadPlayer = killedColor + event.getEntity().getName();
List<String> messages = new ArrayList<>();
// Killer
if (log.GetKiller() != null)
{
// Killed
String killedColor = log.GetKilledColor();
String killerColor = log.GetKillerColor();
String deadPlayer = killedColor + event.getEntity().getName();
String killPlayer = killerColor + log.GetKiller().GetName();
// Killer
if (log.GetKiller() != null)
if (log.GetAssists() > 0)
{
String killerColor = log.GetKillerColor();
String killPlayer = killerColor + log.GetKiller().GetName();
if (log.GetAssists() > 0)
killPlayer += " + " + log.GetAssists();
String weapon = (String) log.GetKiller().GetDamage().getFirst().getMetadata().get("customWeapon");
weapon = weapon == null ? log.GetKiller().GetLastDamageSource() : weapon;
UtilPlayer.message(
cur,
F.main("Death",
deadPlayer + C.cGray + " " + deathEvent.getKilledWord() + " by "
+ killPlayer + C.cGray + " with "
+ F.item(weapon) + "."));
killPlayer += " + " + log.GetAssists();
}
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) + "."));
}
// No Killer
else
{
if (log.GetAttackers().isEmpty())
{
messages.add(F.main(getName(), deadPlayer + C.mBody + " has died."));
}
// No Killer
else
{
if (log.GetAttackers().isEmpty())
UtilPlayer.message(cur, F.main("Death", deadPlayer
+ C.cGray + " has died."));
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 + ".");
}
else
{
if (log.GetLastDamager() != null && log.GetLastDamager().GetReason() != null && log.GetLastDamager().GetReason().length() > 1)
{
UtilPlayer.message(
cur,
F.main("Death",
deadPlayer
+ C.cGray
+ " " + deathEvent.getKilledWord() + " by "
+ F.name(log.GetLastDamager()
.GetReason()))
+ C.cGray + ".");
}
else
{
UtilPlayer.message(
cur,
F.main("Death",
deadPlayer
+ C.cGray
+ " " + deathEvent.getKilledWord() + " by "
+ F.name(log.GetAttackers()
.getFirst().GetName()))
+ C.cGray + ".");
}
messages.add(F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
}
}
}
//Self Detail
if (deathEvent.GetBroadcastType() == DeathMessageType.Absolute)
UtilPlayer.message(event.getEntity(), log.DisplayAbsolute());
else
UtilPlayer.message(event.getEntity(), log.Display());
}
else if (deathEvent.GetBroadcastType() == DeathMessageType.Simple)
// Tell all players simple info
String[] messagesArray = messages.toArray(new String[0]);
combatEvent.getPlayersToInform().forEach(player -> player.sendMessage(messagesArray));
// 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]));
}
else if (combatEvent.GetBroadcastType() == DeathMessageType.Simple)
{
//Simple
if (log.GetKiller() != null)
@ -547,22 +464,26 @@ public class CombatManager extends MiniPlugin
//Killer
String killerColor = log.GetKillerColor();
String killPlayer = killerColor + log.GetKiller().GetName();
// Killed
String killedColor = log.GetKilledColor();
String deadPlayer = killedColor + event.getEntity().getName();
if (log.GetAssists() > 0)
{
killPlayer += " + " + log.GetAssists();
}
String weapon = log.GetKiller().GetLastDamageSource();
Player killer = UtilPlayer.searchExact(log.GetKiller().GetName());
UtilPlayer.message(killer, F.main("Death", "You " + deathEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "."));
UtilPlayer.message(event.getEntity(), F.main("Death", killPlayer + C.cGray + " " + deathEvent.getKilledWord() + " you with " + F.item(weapon) + "."));
if (killer != null)
{
killer.sendMessage(F.main("Death", "You " + combatEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "."));
}
event.getEntity().sendMessage(F.main("Death", killPlayer + C.mBody + " " + combatEvent.getKilledWord() + " you with " + F.item(weapon) + "."));
}
else
{
@ -573,11 +494,10 @@ public class CombatManager extends MiniPlugin
else
{
UtilPlayer.message(event.getEntity(), F.main("Death", "You were " + deathEvent.getKilledWord() + " by " +
F.name(log.GetAttackers().getFirst().GetName())) + C.cGray + ".");
UtilPlayer.message(event.getEntity(), F.main("Death", "You were " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
}
}
}
}
}
@EventHandler
@ -607,7 +527,7 @@ public class CombatManager extends MiniPlugin
{
Add(player);
}
return _active.get(player.getUniqueId());
}
@ -644,12 +564,12 @@ public class CombatManager extends MiniPlugin
}
}
}
public void setUseWeaponName(AttackReason var)
{
_attackReason = var;
}
public AttackReason getUseWeapoName()
{
return _attackReason;

View File

@ -1,6 +1,6 @@
package mineplex.minecraft.game.core.combat;
public enum DeathMessageType
public enum DeathMessageType
{
Absolute,
Detailed,

View File

@ -1,38 +1,47 @@
package mineplex.minecraft.game.core.combat.event;
import java.util.ArrayList;
import java.util.List;
import mineplex.minecraft.game.core.combat.ClientCombat;
import mineplex.minecraft.game.core.combat.CombatLog;
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
{
private static final HandlerList handlers = new HandlerList();
private EntityDeathEvent _event;
private ClientCombat _clientCombat;
private CombatLog _log;
private static final HandlerList HANDLER_LIST = new HandlerList();
private final PlayerDeathEvent _event;
private final ClientCombat _clientCombat;
private final CombatLog _log;
private final List<Player> _playersToInform;
private DeathMessageType _messageType = DeathMessageType.Detailed;
private String _killedWord;
public CombatDeathEvent(EntityDeathEvent event, ClientCombat clientCombat, CombatLog log, String killedWord)
public CombatDeathEvent(PlayerDeathEvent event, ClientCombat clientCombat, CombatLog log, String killedWord)
{
_event = event;
_clientCombat = clientCombat;
_log = log;
_killedWord = killedWord;
_playersToInform = new ArrayList<>(event.getEntity().getWorld().getPlayers());
}
public HandlerList getHandlers()
{
return handlers;
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return handlers;
return HANDLER_LIST;
}
public ClientCombat GetClientCombat()
@ -45,11 +54,16 @@ public class CombatDeathEvent extends Event
return _log;
}
public EntityDeathEvent GetEvent()
public PlayerDeathEvent GetEvent()
{
return _event;
}
public List<Player> getPlayersToInform()
{
return _playersToInform;
}
public void SetBroadcastType(DeathMessageType value)
{
_messageType = value;

View File

@ -3,7 +3,6 @@ package nautilus.game.arcade;
import java.io.File;
import java.util.HashMap;
import mineplex.core.imagemap.CustomItemFrames;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
@ -82,6 +81,7 @@ import mineplex.core.visibility.VisibilityManager;
import mineplex.core.website.WebsiteLinkManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameServerConfig;
@ -169,7 +169,7 @@ public class Arcade extends JavaPlugin
DisguiseManager disguiseManager = require(DisguiseManager.class);
NpcManager npcmanager = new NpcManager(this, creature);
_damageManager = new DamageManager(this, new CombatManager(this), npcmanager, disguiseManager, null);
_damageManager = new DamageManager(this, require(CombatManager.class), npcmanager, disguiseManager, null);
Punish punish = new Punish(this, _clientManager);

View File

@ -255,6 +255,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
public int WorldTimeSet = 12000;
public boolean WorldWeatherEnabled = false;
public int WorldWaterDamage = 0;
public boolean WorldBoundary = true;
public boolean WorldBoundaryKill = true;
public boolean WorldBlockBurn = false;
public boolean WorldBlockGrow = false;

View File

@ -38,6 +38,7 @@ import mineplex.core.leaderboard.RotatingLeaderboard;
import mineplex.core.leaderboard.StaticLeaderboard;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
@ -49,6 +50,7 @@ import nautilus.game.arcade.game.games.cakewars.general.CakeBatModule;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.general.CakeSpawnerModule;
import nautilus.game.arcade.game.games.cakewars.island.CakeIslandModule;
import nautilus.game.arcade.game.games.cakewars.item.CakeItemModule;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeArcher;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeBuilder;
import nautilus.game.arcade.game.games.cakewars.kits.KitCakeFrosting;
@ -150,6 +152,7 @@ public class CakeWars extends TeamGame
BlockBreak = true;
DeathTeleport = false;
DeathSpectateSecs = RESPAWN_TIME;
DeathDropItems = true;
StrictAntiHack = true;
HungerSet = 20;
InventoryClick = true;
@ -158,6 +161,8 @@ public class CakeWars extends TeamGame
ItemDrop = true;
ItemPickup = true;
GameTimeout = TimeUnit.HOURS.toMillis(1);
WorldBoundary = false;
DontAllowOverfill = true;
_help = TIPS;
registerStatTrackers(
@ -216,6 +221,9 @@ public class CakeWars extends TeamGame
new CakeBatModule(this)
.register();
new CakeItemModule(this)
.register();
_capturePointModule = new CapturePointModule();
_capturePointModule.register(this);
@ -616,6 +624,12 @@ public class CakeWars extends TeamGame
.count();
}
@Override
public DeathMessageType GetDeathMessageType()
{
return DeathMessageType.Detailed;
}
public Location getAverageLocation(GameTeam team)
{
return _averages.get(team);

View File

@ -46,6 +46,12 @@ public class CakeBatModule extends CakeModule
_bats = new HashSet<>();
}
@Override
public void cleanup()
{
_unsafeSeconds.clear();
}
@EventHandler
public void prepare(GameStateChangeEvent event)
{
@ -90,7 +96,7 @@ public class CakeBatModule extends CakeModule
Location location = player.getLocation();
if (location.getY() >= _minY)
if (location.getY() >= _minY && _game.isInsideMap(player))
{
continue;
}
@ -109,7 +115,7 @@ public class CakeBatModule extends CakeModule
{
if (UtilEnt.onBlock(player) && ticks % 8 == 0)
{
player.sendMessage(F.main("Game", "Return to the surface! If you don't bats will begin to attack you!"));
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);
player.playSound(location, Sound.NOTE_STICKS, 1, 0.5F);
}
@ -119,7 +125,7 @@ public class CakeBatModule extends CakeModule
if (Recharge.Instance.use(player, "Bat Inform", 8000, false, false))
{
UtilTextMiddle.display(C.cRedB + "STOP CAMPING", "Bats are attacking you!", 0, 20, 10, player);
player.sendMessage(F.main("Game", "Get back to the surface, bats are attacking you!"));
player.sendMessage(F.main("Game", "Get back to an island, bats are attacking you!"));
player.playSound(location, Sound.NOTE_PLING, 1, 0.5F);
}

View File

@ -1,28 +1,22 @@
package nautilus.game.arcade.game.games.cakewars.general;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.AnvilInventory;
@ -30,17 +24,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -51,9 +40,10 @@ import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.shop.CakeResource;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakePlayerModule extends CakeModule
{
@ -63,18 +53,6 @@ public class CakePlayerModule extends CakeModule
.addLore("", "Preserves your inventory on death", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
public static final ItemStack DEPLOY_PLATFORM = new ItemBuilder(Material.INK_SACK)
.setTitle(C.cYellowB + "Deploy Platform")
.addLore("", "Creates a platform of wool next to", "any block you click!", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
public static final ItemStack INSTA_WALL = new ItemBuilder(Material.STAINED_GLASS)
.setTitle(C.cYellowB + "Insta-Wall")
.addLore("", "Creates a wall of wool above", "any block you click!", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
private static final int PLATFORM_DELTA = 1;
private static final int PLATFORM_WARMUP_TICKS = 40;
private final Set<Block> _placedBlocks;
// Used to store the inventory of a player when using the rune of holding
@ -242,6 +220,30 @@ public class CakePlayerModule extends CakeModule
{
_storedInventory.remove(player);
}
CakeTeam cakeTeam = _game.getCakeTeamModule().getCakeTeam(_game.GetTeam(player));
// If respawning drop nothing
if (cakeTeam == null || cakeTeam.canRespawn())
{
event.getDrops().clear();
}
// If out of the game drop only resources
else
{
event.getDrops().removeIf(itemStack ->
{
for (CakeResource resource : CakeResource.values())
{
if (resource.getItemStack().isSimilar(itemStack))
{
return false;
}
}
return true;
});
}
}
@EventHandler
@ -300,9 +302,16 @@ public class CakePlayerModule extends CakeModule
damager.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
}
if (damagee != null && damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE))
if (damagee != null)
{
event.SetCancelled("Damage Resistance");
if (event.GetCause() == DamageCause.SUFFOCATION && !Recharge.Instance.use(damagee, "Suffocation", 1100, false, false))
{
event.SetCancelled("Suffocation Rate");
}
else if (damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE))
{
event.SetCancelled("Damage Resistance");
}
}
}
@ -312,142 +321,6 @@ public class CakePlayerModule extends CakeModule
_storedInventory.remove(event.getPlayer());
}
@EventHandler(priority = EventPriority.HIGH)
public void playerInteractPlatform(PlayerInteractEvent event)
{
if (event.isCancelled() || !_game.IsLive())
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
Block block = event.getClickedBlock();
if (UtilPlayer.isSpectator(player))
{
event.setCancelled(true);
return;
}
if (itemStack == null || block == null)
{
return;
}
BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
GameTeam team = _game.GetTeam(player);
byte teamData = team.GetColorData();
boolean blockChanged = false;
if (itemStack.getType() == DEPLOY_PLATFORM.getType())
{
block = block.getRelative(face).getRelative(face);
for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++)
{
for (int z = -PLATFORM_DELTA; z <= PLATFORM_DELTA; z++)
{
Block nearby = block.getRelative(x, 0, z);
Location nearbyLocation = nearby.getLocation();
if (isInvalidBlock(nearby))
{
continue;
}
_placedBlocks.add(nearby);
MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData);
blockChanged = true;
}
}
}
else if (itemStack.getType() == INSTA_WALL.getType() && event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
event.setCancelled(true);
if (!Recharge.Instance.use(player, "Place Wall", 500, false, false))
{
return;
}
List<Block> changed = new ArrayList<>();
boolean xAxis = face == BlockFace.NORTH || face == BlockFace.SOUTH;
block = block.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++)
{
for (int y = -PLATFORM_DELTA; y <= PLATFORM_DELTA; y++)
{
Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x);
if (isInvalidBlock(nearby))
{
continue;
}
_placedBlocks.add(nearby);
changed.add(nearby);
blockChanged = true;
}
}
DustSpellColor color = new DustSpellColor(team.GetColorBase());
_game.getArcadeManager().runSyncTimer(new BukkitRunnable()
{
int ticks = 0;
@Override
public void run()
{
if (++ticks == PLATFORM_WARMUP_TICKS)
{
cancel();
for (Block wall : changed)
{
MapUtil.QuickChangeBlockAt(wall.getLocation(), Material.WOOL, teamData);
if (Math.random() > 0.5)
{
wall.getWorld().playEffect(wall.getLocation(), Effect.STEP_SOUND, Material.WOOL, teamData);
}
}
}
else
{
int index = 0;
double maxY = ((double) ticks / PLATFORM_WARMUP_TICKS) * 3;
for (Block wall : changed)
{
if (index++ % 3 == 0)
{
for (double y = 0; y < maxY; y += 0.2)
{
new ColoredParticle(ParticleType.RED_DUST, color, wall.getLocation().add(xAxis ? Math.random() : 0.5, y, xAxis ? 0.5 : Math.random()))
.display();
}
}
}
}
}
}, 0, 1);
}
if (blockChanged)
{
player.setItemInHand(UtilInv.decrement(itemStack));
}
}
private boolean isInvalidBlock(Block block)
{
Location location = block.getLocation();
return !UtilBlock.airFoliage(block) || _game.getCapturePointModule().isOnPoint(location) || _game.getCakeShopModule().isNearShop(location) || _game.getCakeSpawnerModule().isNearSpawner(location) || _game.isNearSpawn(location);
}
@EventHandler
public void itemCraft(CraftItemEvent event)
{

View File

@ -0,0 +1,108 @@
package nautilus.game.arcade.game.games.cakewars.item;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeItemModule extends CakeModule
{
private final Set<CakeSpecialItem> _items;
public CakeItemModule(CakeWars game)
{
super(game);
_items = new HashSet<>();
}
@Override
protected void setup()
{
_items.add(new CakeDeployPlatform(_game));
_items.add(new CakeWall(_game));
}
@Override
public void cleanup()
{
_items.clear();
}
@EventHandler
public void playerInteract(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
{
return;
}
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
if (UtilPlayer.isSpectator(player))
{
event.setCancelled(true);
return;
}
if (itemStack == null || event.getClickedBlock() == null)
{
return;
}
GameTeam team = _game.GetTeam(player);
if (team == null)
{
return;
}
CakeTeam cakeTeam = _game.getCakeTeamModule().getCakeTeam(team);
if (cakeTeam == null)
{
return;
}
for (CakeSpecialItem item :_items)
{
if (item.getItemStack().getType() != itemStack.getType())
{
continue;
}
event.setCancelled(true);
boolean inform = item.getCooldown() >= 1000;
if (!Recharge.Instance.use(player, item.getClass().getSimpleName(), item.getCooldown(), inform, inform))
{
return;
}
if (item.onClick(event, cakeTeam))
{
player.setItemInHand(UtilInv.decrement(itemStack));
}
return;
}
}
}

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.games.cakewars.item;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilBlock;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public abstract class CakeSpecialItem
{
protected final CakeWars _game;
private final ItemStack _itemStack;
private final long _cooldown;
public CakeSpecialItem(CakeWars game, ItemStack itemStack)
{
this(game, itemStack, 0);
}
public CakeSpecialItem(CakeWars game, ItemStack itemStack, long cooldown)
{
_game = game;
_itemStack = itemStack;
_cooldown = cooldown;
}
protected abstract boolean onClick(PlayerInteractEvent event, CakeTeam cakeTeam);
protected boolean isInvalidBlock(Block block)
{
Location location = block.getLocation();
return !UtilBlock.airFoliage(block) || _game.getCapturePointModule().isOnPoint(location) || _game.getCakeShopModule().isNearShop(location) || _game.getCakeSpawnerModule().isNearSpawner(location) || _game.isNearSpawn(location);
}
public ItemStack getItemStack()
{
return _itemStack;
}
public long getCooldown()
{
return _cooldown;
}
}

View File

@ -0,0 +1,69 @@
package nautilus.game.arcade.game.games.cakewars.item.items;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeDeployPlatform extends CakeSpecialItem
{
public static final ItemStack ITEM_STACK = new ItemBuilder(Material.INK_SACK)
.setTitle(C.cYellowB + "Deploy Platform")
.addLore("", "Creates a platform of wool next to", "any block you click!", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
private static final int PLATFORM_DELTA = 1;
public CakeDeployPlatform(CakeWars cakeWars)
{
super(cakeWars, ITEM_STACK);
}
@Override
protected boolean onClick(PlayerInteractEvent event, CakeTeam cakeTeam)
{
Player player = event.getPlayer();
Block block = event.getClickedBlock();
BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
GameTeam team = cakeTeam.getGameTeam();
byte teamData = team.GetColorData();
boolean blockChanged = false;
block = block.getRelative(face, 2);
for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++)
{
for (int z = -PLATFORM_DELTA; z <= PLATFORM_DELTA; z++)
{
Block nearby = block.getRelative(x, 0, z);
Location nearbyLocation = nearby.getLocation();
if (isInvalidBlock(nearby))
{
continue;
}
_game.getCakePlayerModule().getPlacedBlocks().add(nearby);
MapUtil.QuickChangeBlockAt(nearbyLocation, Material.WOOL, teamData);
blockChanged = true;
}
}
return blockChanged;
}
}

View File

@ -0,0 +1,129 @@
package nautilus.game.arcade.game.games.cakewars.item.items;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.common.util.C;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.item.CakeSpecialItem;
import nautilus.game.arcade.game.games.cakewars.team.CakeTeam;
public class CakeWall extends CakeSpecialItem
{
public static final ItemStack ITEM_STACK = new ItemBuilder(Material.STAINED_GLASS)
.setTitle(C.cYellowB + "Wool Wall")
.addLore("", "Creates a wall of wool above", "any block you click!", "Uses: " + C.cRed + "1")
.setUnbreakable(true)
.build();
private static final int PLATFORM_DELTA = 1;
private static final int WALL_WARMUP_TICKS = 40;
public CakeWall(CakeWars cakeWars)
{
super(cakeWars, ITEM_STACK, 500);
}
@Override
protected boolean onClick(PlayerInteractEvent event, CakeTeam cakeTeam)
{
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
{
return false;
}
event.setCancelled(true);
Player player = event.getPlayer();
Block block = event.getClickedBlock();
BlockFace face = UtilBlock.getFace(player.getLocation().getYaw()).getOppositeFace();
GameTeam team = cakeTeam.getGameTeam();
byte teamData = team.GetColorData();
boolean blockChanged = false;
List<Block> changed = new ArrayList<>();
boolean xAxis = face == BlockFace.NORTH || face == BlockFace.SOUTH;
block = block.getRelative(BlockFace.UP, 2);
for (int x = -PLATFORM_DELTA; x <= PLATFORM_DELTA; x++)
{
for (int y = -PLATFORM_DELTA; y <= PLATFORM_DELTA; y++)
{
Block nearby = block.getRelative(xAxis ? x : 0, y, xAxis ? 0 : x);
if (isInvalidBlock(nearby))
{
continue;
}
_game.getCakePlayerModule().getPlacedBlocks().add(nearby);
changed.add(nearby);
blockChanged = true;
}
}
DustSpellColor color = new DustSpellColor(team.GetColorBase());
_game.getArcadeManager().runSyncTimer(new BukkitRunnable()
{
int ticks = 0;
@Override
public void run()
{
if (++ticks == WALL_WARMUP_TICKS)
{
cancel();
for (Block wall : changed)
{
MapUtil.QuickChangeBlockAt(wall.getLocation(), Material.WOOL, teamData);
if (Math.random() > 0.5)
{
wall.getWorld().playEffect(wall.getLocation(), Effect.STEP_SOUND, Material.WOOL, teamData);
}
}
}
else
{
int index = 0;
double maxY = ((double) ticks / WALL_WARMUP_TICKS) * 3;
for (Block wall : changed)
{
if (index++ % 3 == 0)
{
for (double y = 0; y < maxY; y += 0.2)
{
new ColoredParticle(ParticleType.RED_DUST, color, wall.getLocation().add(xAxis ? Math.random() : 0.5, y, xAxis ? 0.5 : Math.random()))
.display();
}
}
}
}
}
}, 0, 1);
return blockChanged;
}
}

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.UtilEnt;
@ -80,4 +81,24 @@ public class KitCakeArcher extends Kit
block.breakNaturally();
}, 0);
}
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
Player killer = event.getEntity().getKiller();
if (killer == null || !HasKit(killer))
{
return;
}
for (Perk perk : GetPerks())
{
if (perk instanceof PerkFletcher)
{
killer.getInventory().addItem(((PerkFletcher) perk).getItem(1));
return;
}
}
}
}

View File

@ -19,7 +19,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.kit.Perk;
public class PerkPassiveWoolGain extends Perk
@ -31,7 +31,7 @@ public class PerkPassiveWoolGain extends Perk
private static final int MAX_PLATFORMS = 5;
private static final String WOOL_NAME = "Knitted Wool";
private static final String PLATFORM_NAME = "Knitted Platform";
private static final ItemStack PLATFORM_ITEM = new ItemBuilder(CakePlayerModule.DEPLOY_PLATFORM)
private static final ItemStack PLATFORM_ITEM = new ItemBuilder(CakeDeployPlatform.ITEM_STACK)
.setTitle(C.cYellowB + PLATFORM_NAME)
.build();
@ -64,7 +64,7 @@ public class PerkPassiveWoolGain extends Perk
player.getInventory().addItem(itemStack);
}
if (!UtilInv.contains(player, PLATFORM_ITEM.getType(), team.getDyeColor().getDyeData(), MAX_PLATFORMS) && Recharge.Instance.use(player, PLATFORM_NAME, PLATFORM_RECHARGE, false, false))
if (!UtilInv.contains(player, PLATFORM_NAME, PLATFORM_ITEM.getType(), team.getDyeColor().getDyeData(), MAX_PLATFORMS) && Recharge.Instance.use(player, PLATFORM_NAME, PLATFORM_RECHARGE, false, false))
{
ItemStack itemStack = new ItemBuilder(PLATFORM_ITEM)
.setData(team.getDyeColor().getDyeData())

View File

@ -70,7 +70,7 @@ public class PerkSlowSnowball extends Perk
return;
}
Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 3, 1, false, true, false, false);
Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 3, 0, false, true, false, false);
event.AddMod(damager.getName(), GetName(), 1, true);
event.AddKnockback(GetName(), 0.5);
}

View File

@ -12,7 +12,6 @@ public class CakeWarsDuos extends CakeWars
{
super(manager, GameType.CakeWarsDuos);
DontAllowOverfill = true;
HideTeamSheep = true;
ShowTeammateMessage = true;

View File

@ -30,7 +30,6 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
@ -48,6 +47,8 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.cakewars.CakeModule;
import nautilus.game.arcade.game.games.cakewars.CakeWars;
import nautilus.game.arcade.game.games.cakewars.general.CakePlayerModule;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeDeployPlatform;
import nautilus.game.arcade.game.games.cakewars.item.items.CakeWall;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeBearTrap;
import nautilus.game.arcade.game.games.cakewars.shop.trap.CakeTNTTrap;
import nautilus.game.arcade.game.games.cakewars.ui.CakeResourcePage;
@ -62,7 +63,10 @@ public class CakeShopModule extends CakeModule
.setTitle(C.cPurpleB + "Ender Pearl")
.addLore("", "Warning! Ender Pearls have a", C.cRed + "7 second" + C.cGray + " cooldown between uses.")
.build();
static final int HEALING_STATION_RADIUS = 5;
static int getHealingStationRadius(int level)
{
return 5 + (3 * (level - 1));
}
private final NewNPCManager _manager;
private final Map<NPC, CakeResource> _npcs;
@ -119,7 +123,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.BLOCK, new ItemStack(Material.ENDER_STONE, 8), 12),
// Deploy Platform
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.DEPLOY_PLATFORM, 5),
new CakeShopItem(CakeShopItemType.OTHER, CakeDeployPlatform.ITEM_STACK, 5),
// Emerald
new CakeShopItem(CakeShopItemType.OTHER, new ItemStack(Material.EMERALD), 20)
@ -159,7 +163,7 @@ public class CakeShopModule extends CakeModule
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.RUNE_OF_HOLDING, 20),
// Insta-Wall
new CakeShopItem(CakeShopItemType.OTHER, CakePlayerModule.INSTA_WALL, 2),
new CakeShopItem(CakeShopItemType.OTHER, CakeWall.ITEM_STACK, 2),
// Traps
new CakeTNTTrap(8),
@ -315,24 +319,28 @@ public class CakeShopModule extends CakeModule
@EventHandler
public void updateHealingParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST || !_game.IsLive())
if (event.getType() != UpdateType.FASTER || !_game.IsLive())
{
return;
}
_game.getCakeTeamModule().getCakeTeams().forEach((team, cakeTeam) ->
{
if (cakeTeam.getUpgrades().getOrDefault(CakeTeamItem.REGENERATION, 0) == 0)
int level = cakeTeam.getUpgrades().getOrDefault(CakeTeamItem.REGENERATION, 0);
if (level == 0 || !cakeTeam.canRespawn())
{
return;
}
Location location = cakeTeam.getCake().clone();
DustSpellColor color = new DustSpellColor(team.GetColorBase());
int radius = getHealingStationRadius(level);
double deltaTheta = Math.PI / (25 - (5 * level));
for (double theta = 0; theta < 2 * Math.PI; theta += Math.PI / 20)
for (double theta = 0; theta < 2 * Math.PI; theta += deltaTheta)
{
double x = HEALING_STATION_RADIUS * Math.cos(theta), z = HEALING_STATION_RADIUS * Math.sin(theta);
double x = radius * Math.cos(theta), z = radius * Math.sin(theta);
location.add(x, 0, z);

View File

@ -19,8 +19,7 @@ public enum CakeTeamItem implements CakeItem
"Protection",
new ItemStack(Material.DIAMOND_CHESTPLATE),
4,
10,
18
10
)
{
@Override
@ -45,8 +44,7 @@ public enum CakeTeamItem implements CakeItem
@Override
public void apply(Player player, int level, Location cake)
{
player.removePotionEffect(PotionEffectType.FAST_DIGGING);
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, level - 1, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, level - 1, true, false), true);
}
},
SHARPNESS(
@ -63,7 +61,26 @@ public enum CakeTeamItem implements CakeItem
{
if (UtilItem.isSword(itemStack))
{
itemStack.addEnchantment(Enchantment.DAMAGE_ALL, level);
itemStack.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, level);
}
}
}
},
POWER(
"Sharpness",
new ItemStack(Material.DIAMOND_SWORD),
8,
12
)
{
@Override
public void apply(Player player, int level, Location cake)
{
for (ItemStack itemStack : player.getInventory().getContents())
{
if (itemStack != null && itemStack.getType() == Material.BOW)
{
itemStack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, level);
}
}
}
@ -77,13 +94,16 @@ public enum CakeTeamItem implements CakeItem
REGENERATION(
"Healing Station",
new ItemStack(Material.GOLDEN_APPLE),
8
8,
12
)
{
@Override
public void apply(Player player, int level, Location cake)
{
if (UtilMath.offset2dSquared(player.getLocation(), cake) < CakeShopModule.HEALING_STATION_RADIUS * CakeShopModule.HEALING_STATION_RADIUS)
int maxDist = CakeShopModule.getHealingStationRadius(level);
if (UtilMath.offset2dSquared(player.getLocation(), cake) < maxDist * maxDist)
{
player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false));

View File

@ -42,7 +42,6 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.DeathMessageType;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
@ -501,8 +500,7 @@ public class CakeTeamModule extends CakeModule
_game.Announce(F.main("Game", F.name(team.GetFormattedName()) + "'s Cake has been eaten! All their players have quit."));
}
// Runs on MONITOR because otherwise GetDeathMessageType() overrides this
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler
public void playerDeath(CombatDeathEvent event)
{
if (!_game.IsLive())
@ -510,7 +508,7 @@ public class CakeTeamModule extends CakeModule
return;
}
Player player = (Player) event.GetEvent().getEntity();
Player player = event.GetEvent().getEntity();
GameTeam team = _game.GetTeam(player);
if (team == null)
@ -520,7 +518,13 @@ public class CakeTeamModule extends CakeModule
CakeTeam cakeTeam = _teams.get(team);
event.SetBroadcastType(cakeTeam.canRespawn() ? DeathMessageType.Simple : DeathMessageType.Detailed);
if (cakeTeam.canRespawn())
{
Player killer = player.getKiller();
GameTeam killerTeam = _game.GetTeam(killer);
event.getPlayersToInform().removeIf(other -> (killerTeam == null || !killerTeam.HasPlayer(other)) && !team.HasPlayer(other));
}
}
@EventHandler(priority = EventPriority.HIGH)

View File

@ -1,22 +1,8 @@
package nautilus.game.arcade.kit.perks;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mineplex.core.Managers;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
@ -31,6 +17,19 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
public class PerkFletcher extends Perk
{
@ -175,7 +174,7 @@ public class PerkFletcher extends Perk
//Add
if (_slot == -1)
{
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(262, (byte)0, 1, F.item(_name)));
cur.getInventory().addItem(getItem(1));
}
else
{
@ -185,7 +184,7 @@ public class PerkFletcher extends Perk
{
amount += old.getAmount();
}
cur.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(262, (byte)0, amount, F.item(_name)));
cur.getInventory().setItem(_slot, getItem(amount));
}
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
@ -247,6 +246,11 @@ public class PerkFletcher extends Perk
return;
}
_fletchArrows.removeIf(arrow -> arrow.isDead() || !arrow.isValid());
_fletchArrows.removeIf(arrow -> !arrow.isValid());
}
public ItemStack getItem(int amount)
{
return ItemStackFactory.Instance.CreateStack(262, (byte) 0, amount, F.item(_name));
}
}

View File

@ -8,6 +8,7 @@ import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -73,8 +74,8 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerDeathOutEvent;
import nautilus.game.arcade.game.Game;
@ -93,18 +94,18 @@ public class GameFlagManager implements Listener
final ArcadeManager Manager;
private SecondaryDamageManager Secondary;
private Map<Player, Long> _respawnTimers = new HashMap<>();
private Map<Player, Integer> _respawnRunnables = new HashMap<>();
private final Map<Player, Long> _respawnTimers = new HashMap<>();
private final Map<Player, Integer> _respawnRunnables = new HashMap<>();
public GameFlagManager(ArcadeManager manager)
{
Manager = manager;
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.DEV.setPermission(Perm.BYPASS_TELEPORT_KICK, true, true);
@ -114,13 +115,13 @@ public class GameFlagManager implements Listener
PermissionGroup.ADMIN.setPermission(Perm.BYPASS_TELEPORT_KICK, true, true);
}
}
@EventHandler
public void triggerSecondary(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
if (Secondary == null)
{
if (!Manager.GetDamage().IsEnabled())
@ -144,9 +145,9 @@ public class GameFlagManager implements Listener
@EventHandler(priority = EventPriority.LOW)
public void DamageEvent(CustomDamageEvent event)
{
{
Game game = Manager.GetGame();
if (game == null)
if (game == null)
{
event.SetCancelled("Game Null");
return;
@ -164,7 +165,7 @@ public class GameFlagManager implements Listener
return;
}
//Damagee Spec
if (damagee != null && Manager.isSpectator(damagee))
{
@ -177,7 +178,7 @@ public class GameFlagManager implements Listener
return;
}
//Damager Spec
if (damager != null && Manager.isSpectator(damager))
{
@ -194,16 +195,16 @@ public class GameFlagManager implements Listener
if (game.GetState() != GameState.Live)
{
event.SetCancelled("Game not Live");
return;
return;
}
if (damagee != null && damagee instanceof Player && !game.IsAlive((Player)damagee))
if (damagee != null && damagee instanceof Player && !game.IsAlive((Player) damagee))
{
event.SetCancelled("Damagee Not Playing");
return;
}
if (damager != null && damager instanceof Player && !game.IsAlive((Player)damager))
if (damager != null && damager instanceof Player && !game.IsAlive((Player) damager))
{
event.SetCancelled("Damager Not Playing");
return;
@ -214,14 +215,14 @@ public class GameFlagManager implements Listener
event.SetCancelled("Fall Damage Disabled");
return;
}
//Entity vs Entity
if (damagee != null && damager != null)
if (damagee != null && damager != null)
{
//PvP
if (damagee instanceof Player && damager instanceof Player)
{
if (!Manager.canHurt((Player)damagee, (Player)damager))
if (!Manager.canHurt((Player) damagee, (Player) damager))
{
event.SetCancelled("PvP Disabled");
return;
@ -250,7 +251,7 @@ public class GameFlagManager implements Listener
@EventHandler(priority = EventPriority.HIGH)
public void DamageExplosion(CustomDamageEvent event)
{
{
if (event.IsCancelled())
return;
@ -258,10 +259,10 @@ public class GameFlagManager implements Listener
return;
Player damagee = event.GetDamageePlayer();
if (damagee == null) return;
if (damagee == null) return;
Player damager = event.GetDamagerPlayer(true);
if (damager == null) return;
if (damager == null) return;
if (Manager.canHurt(damagee, damager))
return;
@ -269,7 +270,6 @@ public class GameFlagManager implements Listener
event.SetCancelled("Allied Explosion");
}
@EventHandler(priority = EventPriority.LOWEST)
public void ItemPickupEvent(PlayerPickupItemEvent event)
@ -293,7 +293,7 @@ public class GameFlagManager implements Listener
}
}
else
{
{
if (!game.ItemPickupAllow.contains(event.getItem().getItemStack().getTypeId()))
{
event.setCancelled(true);
@ -311,7 +311,7 @@ public class GameFlagManager implements Listener
if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
{
event.setCancelled(true);
}
@ -327,21 +327,21 @@ public class GameFlagManager implements Listener
}
}
else
{
{
if (!game.ItemDropAllow.contains(event.getItemDrop().getItemStack().getTypeId()))
{
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void InventoryOpen(InventoryOpenEvent event)
{
Game game = Manager.GetGame();
if (game == null)
return;
if (!game.InProgress())
return;
@ -360,7 +360,7 @@ public class GameFlagManager implements Listener
event.getInventory().getType() == InventoryType.ENDER_CHEST ||
event.getInventory().getType() == InventoryType.WORKBENCH ||
event.getInventory().getType() == InventoryType.CHEST)
{
{
if (event.getInventory().getType() == InventoryType.CHEST)
{
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest)
@ -390,27 +390,27 @@ public class GameFlagManager implements Listener
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void InventoryClick(InventoryClickEvent event)
{
Game game = Manager.GetGame();
if (game == null)
return;
if (!game.InProgress())
return;
if (game.InventoryClick)
return;
Player player = UtilPlayer.searchExact(event.getWhoClicked().getName());
if (player != null && !game.IsAlive(player))
return;
if (!game.IsAlive(player))
return;
if (event.getInventory().getType() == InventoryType.CRAFTING)
{
event.setCancelled(true);
@ -427,7 +427,7 @@ public class GameFlagManager implements Listener
if (game == null)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
else
@ -435,11 +435,11 @@ public class GameFlagManager implements Listener
if (!game.IsAlive(player))
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
// Event Server Allowance
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE)
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE)
{
return;
}
@ -453,7 +453,7 @@ public class GameFlagManager implements Listener
}
}
else
{
{
if (!game.BlockPlaceAllow.contains(event.getBlock().getTypeId()))
{
event.setCancelled(true);
@ -472,7 +472,7 @@ public class GameFlagManager implements Listener
if (game == null)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
else if (game.GetState() == GameState.Live)
@ -482,7 +482,7 @@ public class GameFlagManager implements Listener
event.setCancelled(true);
}
// Event Server Allowance
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE)
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE)
{
return;
}
@ -513,7 +513,7 @@ public class GameFlagManager implements Listener
public void PrivateBlockPlace(BlockPlaceEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.PrivateBlocks)
return;
@ -545,14 +545,14 @@ public class GameFlagManager implements Listener
if (game.PrivateBlockCount.get(privateKey) == 4)
{
event.getPlayer().sendMessage(F.main(game.GetName(), "Protected block limit reached."));
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void PrivateBlockPlaceCancel(BlockPlaceEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.PrivateBlocks)
return;
@ -567,7 +567,7 @@ public class GameFlagManager implements Listener
Player player = event.getPlayer();
BlockFace[] faces = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
BlockFace[] faces = new BlockFace[]{BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces)
{
@ -592,9 +592,9 @@ public class GameFlagManager implements Listener
continue;
//Disallow
UtilPlayer.message(event.getPlayer(), F.main("Game",
"You cannot combine " +
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
UtilPlayer.message(event.getPlayer(), F.main("Game",
"You cannot combine " +
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
" with " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
event.setCancelled(true);
@ -606,7 +606,7 @@ public class GameFlagManager implements Listener
public void PrivateBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.PrivateBlocks)
return;
@ -635,9 +635,9 @@ public class GameFlagManager implements Listener
return;
//Disallow
UtilPlayer.message(event.getPlayer(), F.main("Game",
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
UtilPlayer.message(event.getPlayer(), F.main("Game",
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
event.setCancelled(true);
}
@ -647,7 +647,7 @@ public class GameFlagManager implements Listener
public void PrivateBlockUse(PlayerInteractEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.PrivateBlocks)
return;
@ -667,10 +667,10 @@ public class GameFlagManager implements Listener
return;
Player owner = game.PrivateBlockMap.get(event.getClickedBlock().getLocation());
if (!game.IsAlive(owner))
return;
Player player = event.getPlayer();
if (owner.equals(player))
@ -687,19 +687,19 @@ public class GameFlagManager implements Listener
return;
//Disallow
UtilPlayer.message(event.getPlayer(), F.main("Game",
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getClickedBlock(), false)) +
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
UtilPlayer.message(event.getPlayer(), F.main("Game",
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getClickedBlock(), false)) +
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void PrivateBlockCrumble(PerkDestructorBlockEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.PrivateBlocks)
return;
@ -730,20 +730,20 @@ public class GameFlagManager implements Listener
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void PlayerDeath(PlayerDeathEvent event)
{
final Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
final Player player = event.getEntity();
//Remove all conditions
Manager.GetCondition().EndCondition(player, null, null);
for (PotionEffect potion : player.getActivePotionEffects())
player.removePotionEffect(potion.getType());
//Visual
// Manager.GetCondition().Factory().Blind("Ghost", player, player, 2.5, 0, false, false, false);
@ -776,7 +776,7 @@ public class GameFlagManager implements Listener
if (game.AutomaticRespawn && game.IsAlive(player))
{
game.RespawnPlayer(player);
}
}
else
{
Manager.addSpectator(player, game.DeathTeleport);
@ -795,28 +795,28 @@ public class GameFlagManager implements Listener
if (game.GetTeam(player) != null)
if (game.GetTeam(player).GetRespawnTime() > time)
time = game.GetTeam(player).GetRespawnTime();
final double timeF = time;
UtilInv.Clear(player);
Manager.GetCondition().Factory().Cloak("Ghost", player, player, time, false, false);
player.setAllowFlight(true);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().setGhost(true);
((CraftPlayer)player).getHandle().k = false;
for (int i=0 ; i<9 ; i++)
((CraftPlayer) player).getHandle().k = false;
for (int i = 0; i < 9; i++)
player.getInventory().setItem(i, new ItemStack(Material.SKULL));
UtilAction.velocity(player, new Vector(0,0,0), 1, true, 0.4, 0, 1, true);
UtilAction.velocity(player, new Vector(0, 0, 0), 1, true, 0.4, 0, 1, true);
if (!game.IsAlive(player))
{
Manager.addSpectator(player, game.DeathTeleport);
return;
}
if (time > 3)
{
UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds...");
@ -843,33 +843,33 @@ public class GameFlagManager implements Listener
UtilAction.zeroVelocity(player);
_respawnRunnables.remove(player);
}, (int)(time * 20d));
}, (int) (time * 20d));
_respawnRunnables.put(player, run);
}
}
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
//Drop Items
if (game.QuitDropItems)
if (game.IsLive())
if (game.IsAlive(event.getPlayer()))
UtilInv.drop(event.getPlayer(), true);
//Remove Kit
game.RemoveTeamPreference(event.getPlayer());
game.GetPlayerKits().remove(event.getPlayer());
game.GetPlayerGems().remove(event.getPlayer());
if (!game.QuitOut)
return;
GameTeam team = game.GetTeam(event.getPlayer());
if (team != null)
{
if (game.InProgress())
@ -878,7 +878,7 @@ public class GameFlagManager implements Listener
team.RemovePlayer(event.getPlayer());
}
}
@EventHandler
public void PlayerMoveCancel(PlayerMoveEvent event)
{
@ -888,7 +888,7 @@ public class GameFlagManager implements Listener
if (!game.PrepareFreeze)
return;
if (!game.IsAlive(event.getPlayer()))
return;
@ -908,7 +908,7 @@ public class GameFlagManager implements Listener
return;
Game game = Manager.GetGame();
//Not Playing
for (Player player : UtilServer.getPlayers())
{
@ -963,73 +963,83 @@ public class GameFlagManager implements Listener
public void PlayerBoundaryCheck(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
Game game = Manager.GetGame();
if (game == null || game.GetState() != GameState.Live)
return;
for (Player player : UtilServer.getPlayers())
if (game == null || !game.IsLive())
{
if (!game.isInsideMap(player) && game.IsAlive(player))
return;
}
WorldData worldData = game.WorldData;
for (Player player : game.WorldData.World.getPlayers())
{
if (game.isInsideMap(player))
{
//Riding a Projectile, edgecase
if (player.getVehicle() != null && player.getVehicle() instanceof Projectile)
{
player.getVehicle().remove();
player.leaveVehicle();
((CraftPlayer)player).getHandle().spectating = false;
}
if (!game.WorldBoundaryKill)
{
UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!");
continue;
}
if (game.GetType() != GameType.Gravity)
{
if (player.getLocation().getY() > game.WorldData.MaxY)
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
else
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
}
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.VOID, 4, false, false, false,
"Border", "Border Damage");
if (!Manager.GetDamage().IsEnabled())
{
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 4));
}
if (UtilPlayer.isSpectator(player))
{
player.teleport(game.GetSpectatorLocation());
continue;
}
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
//Riding a Projectile, edgecase
if (player.getVehicle() != null && player.getVehicle() instanceof Projectile)
{
player.getVehicle().remove();
player.leaveVehicle();
((CraftPlayer) player).getHandle().spectating = false;
}
Location location = player.getLocation();
if (game.WorldBoundary && !game.WorldBoundaryKill)
{
UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!");
if (location.getY() > game.WorldData.MaxY)
{
UtilAction.velocity(player, UtilAlg.getTrajectory2d(location, game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
}
else
{
if (!Manager.GetDamage().IsEnabled())
{
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 9001));
}
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.VOID, 9001, false, false, false,
"Border", "Border Damage");
}
UtilAction.velocity(player, UtilAlg.getTrajectory2d(location, game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
}
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 4, false, false, false, "Border", "Border Damage");
if (!Manager.GetDamage().IsEnabled())
{
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 4));
}
player.getWorld().playSound(location, Sound.NOTE_BASS, 2f, 1f);
}
if (!game.isInsideMap(player) && (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating))
else if ((game.WorldBoundary && game.WorldBoundaryKill) || location.getX() < worldData.MinX)
{
player.teleport(game.GetSpectatorLocation());
if (!Manager.GetDamage().IsEnabled())
{
Bukkit.getPluginManager().callEvent(new EntityDamageEvent(player, DamageCause.VOID, 9001));
}
else
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, false, false, "Border", "Border Damage");
}
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void WorldCreature(CreatureSpawnEvent event)
{
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.CreatureAllow && !game.CreatureAllowOverride)
{
@ -1044,8 +1054,8 @@ public class GameFlagManager implements Listener
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void StaffDisqualify(MineplexTeleportEvent event)
{
@ -1054,13 +1064,13 @@ public class GameFlagManager implements Listener
if (Manager.GetClients().Get(event.getPlayer()).hasPermission(Perm.BYPASS_TELEPORT_KICK))
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!(game.IsLive() || game.GetState() == GameState.Prepare))
return;
if (!game.TeleportsDisqualify)
return;
@ -1080,7 +1090,7 @@ public class GameFlagManager implements Listener
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldTimeSet != -1)
{
@ -1126,7 +1136,7 @@ public class GameFlagManager implements Listener
}
});
}
@EventHandler
public void WorldWeather(UpdateEvent event)
{
@ -1134,7 +1144,7 @@ public class GameFlagManager implements Listener
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (!game.WorldWeatherEnabled)
{
@ -1192,16 +1202,16 @@ public class GameFlagManager implements Listener
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void WorldSoilTrample(PlayerInteractEvent event)
{
if (event.getAction() != Action.PHYSICAL)
return;
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldSoilTrample)
return;
@ -1210,83 +1220,83 @@ public class GameFlagManager implements Listener
event.setCancelled(true);
}
@EventHandler
public void WorldBlockBurn(BlockBurnEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldBlockBurn)
return;
event.setCancelled(true);
}
@EventHandler
public void WorldBlockBurn(BlockGrowEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldBlockGrow)
return;
event.setCancelled(true);
}
@EventHandler
public void WorldFireSpread(BlockIgniteEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldFireSpread)
return;
if (event.getCause() == IgniteCause.FLINT_AND_STEEL && game.AllowFlintAndSteel)
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void WorldLeavesDecay(LeavesDecayEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;
if (game == null) return;
if (game.WorldLeavesDecay)
return;
event.setCancelled(true);
}
@EventHandler
public void SpectatorMessage(UpdateEvent event)
{
if (Manager.IsTournamentServer())
return;
if (Manager.GetGame() == null)
return;
if (!Manager.GetGame().AnnounceStay)
return;
if (!Manager.GetGame().IsLive())
return;
return;
if (event.getType() != UpdateType.SEC)
return;
for (Player player : UtilServer.getPlayers())
{
if (Manager.IsAlive(player))
continue;
if (Recharge.Instance.use(player, "Dont Quit Message", 300000, false, false) && !Manager.getPreferences().get(player).isActive(Preference.AUTO_JOIN_NEXT_GAME))
{
UtilPlayer.message(player, " ");
@ -1330,19 +1340,19 @@ public class GameFlagManager implements Listener
{
if (Manager.GetGame() == null)
return;
if (Manager.GetGame().GetType().getResourcePackUrls(Manager.GetGame()) == null || Manager.GetGame().GetType().getResourcePackUrls(Manager.GetGame()).length == 0)
return;
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
}
@EventHandler
public void displayRespawnTimer(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
if (Manager.GetGame() == null)
{
_respawnTimers.clear();

View File

@ -183,7 +183,7 @@ public class GemHunters extends JavaPlugin
creature.SetDisableCustomDrops(true);
// The old classic Damage Manager
DamageManager damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager, new ConditionManager(this));
DamageManager damageManager = new DamageManager(this, require(CombatManager.class), new NpcManager(this, creature), disguiseManager, new ConditionManager(this));
damageManager.SetEnabled(false);
// GWEN