Mess around the CombatManager and World Borders
This commit is contained in:
parent
5aeb44c30d
commit
3054ac2cfb
@ -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)
|
||||
},
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
@ -47,45 +52,41 @@ public class CombatManager extends MiniPlugin
|
||||
DefaultWeaponName
|
||||
}
|
||||
|
||||
private NautHashMap<UUID, CombatLog> _active = new NautHashMap<>();
|
||||
private Map<UUID, ClientCombat> _combatClients = new HashMap<>();
|
||||
private final Map<UUID, CombatLog> _active = new HashMap<>();
|
||||
private final Map<UUID, ClientCombat> _combatClients = new HashMap<>();
|
||||
|
||||
private HashSet<UUID> _removeList = new HashSet<>();
|
||||
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);
|
||||
|
||||
@ -93,10 +94,12 @@ public class CombatManager extends MiniPlugin
|
||||
if (damagerEnt != null)
|
||||
{
|
||||
if (damagerEnt instanceof Player)
|
||||
Get((Player)damagerEnt).SetLastCombat(System.currentTimeMillis());
|
||||
{
|
||||
Get((Player) damagerEnt).SetLastCombat(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
String cause = "";
|
||||
switch(event.getCause())
|
||||
String cause;
|
||||
switch (event.getCause())
|
||||
{
|
||||
case ENTITY_ATTACK:
|
||||
cause = "Attack";
|
||||
@ -128,125 +131,41 @@ public class CombatManager extends MiniPlugin
|
||||
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.getLeft(), event.getDamage(), null, source.getRight(), null);
|
||||
}
|
||||
|
||||
Get(damagee).Attacked(source,
|
||||
event.getDamage(), null, reason, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void AddAttack(CustomDamageEvent event)
|
||||
{
|
||||
// Not Player > No Log
|
||||
if (event.GetDamageePlayer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Damager is ENTITY
|
||||
if (event.GetDamagerEntity(true) != null)
|
||||
@ -259,7 +178,6 @@ public class CombatManager extends MiniPlugin
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
|
||||
|
||||
reason = "Attack";
|
||||
|
||||
if (_attackReason == AttackReason.DefaultWeaponName)
|
||||
@ -269,8 +187,11 @@ public class CombatManager extends MiniPlugin
|
||||
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);
|
||||
}
|
||||
@ -295,123 +216,134 @@ 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);
|
||||
|
||||
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 = "-";
|
||||
|
||||
if (cause == DamageCause.BLOCK_EXPLOSION)
|
||||
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 = "-";
|
||||
break;
|
||||
}
|
||||
|
||||
if (event.GetReason() != null)
|
||||
reason = event.GetReason();
|
||||
|
||||
Get(event.GetDamageePlayer()).Attacked(source,
|
||||
(int) event.GetDamage(), null, reason, event.GetDamageMod(), event.getMetadata());
|
||||
}
|
||||
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,50 +366,52 @@ 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)
|
||||
{
|
||||
//Display Simple
|
||||
for (Player cur : event.getEntity().getWorld().getPlayers())
|
||||
DeathMessageType messageType = combatEvent.GetBroadcastType();
|
||||
|
||||
//Death Message
|
||||
if (messageType == DeathMessageType.Detailed || messageType == DeathMessageType.Absolute)
|
||||
{
|
||||
// Killed
|
||||
String killedColor = log.GetKilledColor();
|
||||
|
||||
String deadPlayer = killedColor + event.getEntity().getName();
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
// Killer
|
||||
if (log.GetKiller() != null)
|
||||
@ -485,61 +421,42 @@ public class CombatManager extends MiniPlugin
|
||||
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) + "."));
|
||||
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())
|
||||
UtilPlayer.message(cur, F.main("Death", deadPlayer
|
||||
+ C.cGray + " has died."));
|
||||
{
|
||||
messages.add(F.main(getName(), deadPlayer + C.mBody + " has died."));
|
||||
}
|
||||
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 + ".");
|
||||
messages.add(F.main(getName(), deadPlayer + C.mBody + " " + combatEvent.getKilledWord() + " by " + F.name(log.GetLastDamager().GetReason())) + C.mBody + ".");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Tell all players simple info
|
||||
String[] messagesArray = messages.toArray(new String[0]);
|
||||
combatEvent.getPlayersToInform().forEach(player -> player.sendMessage(messagesArray));
|
||||
|
||||
//Self Detail
|
||||
if (deathEvent.GetBroadcastType() == DeathMessageType.Absolute)
|
||||
UtilPlayer.message(event.getEntity(), log.DisplayAbsolute());
|
||||
else
|
||||
UtilPlayer.message(event.getEntity(), log.Display());
|
||||
// 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 (deathEvent.GetBroadcastType() == DeathMessageType.Simple)
|
||||
else if (combatEvent.GetBroadcastType() == DeathMessageType.Simple)
|
||||
{
|
||||
//Simple
|
||||
if (log.GetKiller() != null)
|
||||
@ -548,21 +465,25 @@ public class CombatManager extends MiniPlugin
|
||||
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,8 +494,7 @@ 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 + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,11 +302,18 @@ public class CakePlayerModule extends CakeModule
|
||||
damager.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
}
|
||||
|
||||
if (damagee != null && damagee.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE))
|
||||
if (damagee != null)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ public class CakeWarsDuos extends CakeWars
|
||||
{
|
||||
super(manager, GameType.CakeWarsDuos);
|
||||
|
||||
DontAllowOverfill = true;
|
||||
HideTeamSheep = true;
|
||||
ShowTeammateMessage = true;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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,8 +94,8 @@ 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)
|
||||
{
|
||||
@ -197,13 +198,13 @@ public class GameFlagManager implements Listener
|
||||
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;
|
||||
@ -221,7 +222,7 @@ public class GameFlagManager implements Listener
|
||||
//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;
|
||||
@ -270,7 +271,6 @@ public class GameFlagManager implements Listener
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void ItemPickupEvent(PlayerPickupItemEvent event)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
@ -802,14 +802,14 @@ public class GameFlagManager implements Listener
|
||||
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;
|
||||
((CraftPlayer) player).getHandle().k = false;
|
||||
|
||||
for (int i=0 ; i<9 ; i++)
|
||||
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))
|
||||
{
|
||||
@ -843,7 +843,7 @@ public class GameFlagManager implements Listener
|
||||
UtilAction.zeroVelocity(player);
|
||||
|
||||
_respawnRunnables.remove(player);
|
||||
}, (int)(time * 20d));
|
||||
}, (int) (time * 20d));
|
||||
_respawnRunnables.put(player, run);
|
||||
}
|
||||
}
|
||||
@ -963,64 +963,74 @@ 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))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
player.teleport(game.GetSpectatorLocation());
|
||||
continue;
|
||||
}
|
||||
|
||||
//Riding a Projectile, edgecase
|
||||
if (player.getVehicle() != null && player.getVehicle() instanceof Projectile)
|
||||
{
|
||||
player.getVehicle().remove();
|
||||
player.leaveVehicle();
|
||||
((CraftPlayer)player).getHandle().spectating = false;
|
||||
((CraftPlayer) player).getHandle().spectating = false;
|
||||
}
|
||||
|
||||
if (!game.WorldBoundaryKill)
|
||||
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 (game.GetType() != GameType.Gravity)
|
||||
if (location.getY() > game.WorldData.MaxY)
|
||||
{
|
||||
if (player.getLocation().getY() > game.WorldData.MaxY)
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory2d(location, 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);
|
||||
{
|
||||
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");
|
||||
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(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
||||
player.getWorld().playSound(location, Sound.NOTE_BASS, 2f, 1f);
|
||||
}
|
||||
else
|
||||
else if ((game.WorldBoundary && game.WorldBoundaryKill) || location.getX() < worldData.MinX)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
if (!game.isInsideMap(player) && (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating))
|
||||
else
|
||||
{
|
||||
player.teleport(game.GetSpectatorLocation());
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.VOID, 9001, false, false, false, "Border", "Border Damage");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user