Merge pull request #44 in MIN/mineplex from clans_custom_gear to clans-beta
* commit '783f526b76266cf4b947ff6b6530c73b2e1c2366': Fix bug with DisguiseManager not properly handling the undisguising of non-player entities. Fix bug where FleshHook skill could be activated on players in a safe zone. Fix multiple bugs with unsafe logging system and NPC drops. Fix bug where unsafe timers and combat tagging in safe zones was not properly functioning. Fix bug with CustomGear not properly spawning with command. Add Clan Blacklist that restricts naming of Clans.
This commit is contained in:
commit
4567496978
@ -397,12 +397,12 @@ public class UtilPlayer
|
||||
return matchList;
|
||||
}
|
||||
|
||||
public static LinkedList<Player> getNearby(Location loc, double maxDist)
|
||||
public static List<Player> getNearby(Location loc, double maxDist)
|
||||
{
|
||||
return getNearby(loc, maxDist, false);
|
||||
}
|
||||
|
||||
public static LinkedList<Player> getNearby(Location loc, double maxDist, boolean onlySurvival)
|
||||
public static List<Player> getNearby(Location loc, double maxDist, boolean onlySurvival)
|
||||
{
|
||||
LinkedList<Player> nearbyMap = new LinkedList<Player>();
|
||||
|
||||
@ -417,8 +417,7 @@ public class UtilPlayer
|
||||
if (onlySurvival && cur.getGameMode() != GameMode.SURVIVAL)
|
||||
continue;
|
||||
|
||||
double dist = loc.toVector().subtract(cur.getLocation().toVector()).length();
|
||||
|
||||
double dist = loc.distance(cur.getLocation());
|
||||
if (dist > maxDist)
|
||||
continue;
|
||||
|
||||
|
@ -1085,8 +1085,12 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
_movePacketMap.remove(entity.getEntityId());
|
||||
_moveTempMap.remove(entity.getEntityId());
|
||||
_blockedNames.remove(((Player) entity).getName());
|
||||
|
||||
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
_blockedNames.remove(((Player) entity).getName());
|
||||
}
|
||||
|
||||
refreshTrackers(entity, players.toArray(new Player[0]));
|
||||
|
||||
if (_bedPackets && disguise instanceof DisguisePlayer && ((DisguisePlayer) disguise).getSleepingDirection() != null)
|
||||
|
@ -174,8 +174,7 @@ public class NpcManager extends MiniPlugin
|
||||
|
||||
public Npc getNpcByEntity(Entity entity)
|
||||
{
|
||||
if (entity == null)
|
||||
return null;
|
||||
if (entity == null) return null;
|
||||
|
||||
return getNpcByEntityUUID(entity.getUniqueId());
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.game.clans.clans;
|
||||
|
||||
/**
|
||||
* ClansBlacklist represents the blacklist of all disallowed names for clan creation.
|
||||
* @author MrTwiggy
|
||||
*
|
||||
*/
|
||||
public class ClansBlacklist
|
||||
{
|
||||
|
||||
// Set of all blacklisted clan names that are NOT valid.
|
||||
private final static String[] BLACKLISTED_NAMES = new String[]
|
||||
{
|
||||
"Youtube", "Owner", "Admin", "Mod", "Trainee", "Twitch",
|
||||
"Wilderness", "Shops", "Builder", "Spawn", "Clan", "Clans",
|
||||
"Fields", "Sr.Mod", "Sr. Mod", "Dev", "Jr.Dev", "Jr. Dev", "create",
|
||||
"join", "leave", "map", "cc", "ac", "invite", "kick", "neutral",
|
||||
"enemy", "trust", "unclaim", "claim", "delete"
|
||||
};
|
||||
|
||||
/**
|
||||
* @param clanName - the name of the clan to validate
|
||||
* @return true, if {@code clanName} is a valid and non-blacklisted clan name, false otherwise.
|
||||
*/
|
||||
public static boolean isValidClanName(String clanName)
|
||||
{
|
||||
for (String blacklistedName : BLACKLISTED_NAMES)
|
||||
{
|
||||
if (blacklistedName.equalsIgnoreCase(clanName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -60,29 +60,6 @@ public class ClansGame extends MiniPlugin
|
||||
|
||||
Clans = clans;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for (Player cur : UtilServer.getPlayers())
|
||||
{
|
||||
if (Clans.getClanUtility().isSafe(cur.getLocation()))
|
||||
{
|
||||
long lastDamager = Clans.getCombatManager().Get(cur).GetLastCombat();
|
||||
|
||||
if (!UtilTime.elapsed(lastDamager, 15000))
|
||||
{
|
||||
UtilPlayer.message(cur, F.main("Safe Zone", "You are not safe for " +
|
||||
F.time(UtilTime.convertString(15000 - (System.currentTimeMillis() - lastDamager), 1, TimeUnit.FIT))));
|
||||
|
||||
Clans.getCondition().Factory().Custom("Unsafe", cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preventHorseSpawn(CreatureSpawnEvent event)
|
||||
@ -313,9 +290,6 @@ public class ClansGame extends MiniPlugin
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
if (damagee == null) return;
|
||||
|
||||
if (Clans.getClanUtility().isSafe(damagee))
|
||||
event.SetCancelled("Safe Zone");
|
||||
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
if (damager == null) return;
|
||||
|
||||
|
@ -122,6 +122,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
private WorldEventManager _worldEvent;
|
||||
private Chat _chat;
|
||||
private ItemMapManager _itemMapManager;
|
||||
private DisguiseManager _disguiseManager;
|
||||
private NpcManager _npcManager;
|
||||
private Explosion _explosion;
|
||||
private GoldManager _goldManager;
|
||||
|
||||
@ -158,10 +160,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
_goldManager = new GoldManager(this, _clientManager, donationManager);
|
||||
LootManager lootManager = new LootManager(gearManager, _goldManager);
|
||||
PacketHandler packetHandler = new PacketHandler(plugin);
|
||||
DisguiseManager disguiseManager = new DisguiseManager(plugin, packetHandler);
|
||||
_disguiseManager = new DisguiseManager(plugin, packetHandler);
|
||||
Creature creature = new Creature(plugin);
|
||||
_npcManager = new NpcManager(plugin, creature);
|
||||
_condition = new SkillConditionManager(plugin);
|
||||
DamageManager damageManager = new DamageManager(plugin, _combatManager, new NpcManager(plugin, creature), disguiseManager, _condition);
|
||||
DamageManager damageManager = new DamageManager(plugin, _combatManager, _npcManager, _disguiseManager, _condition);
|
||||
_worldEvent = new WorldEventManager(plugin, this, damageManager, lootManager, blockRestore);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager);
|
||||
@ -184,9 +187,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
new Field(plugin, creature, _condition, energy, serverName);
|
||||
|
||||
// Required managers to be initialized
|
||||
new Spawn(plugin);
|
||||
new Spawn(plugin, this);
|
||||
new NPCManager(this);
|
||||
new LoggingManager(plugin);
|
||||
new LoggingManager(plugin, this);
|
||||
|
||||
new Weapon(plugin, energy);
|
||||
new Gameplay(plugin, this, blockRestore, damageManager);
|
||||
@ -198,7 +201,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
itemIgnore.add("Proximity Zapper");
|
||||
|
||||
ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, _projectileManager, webServerAddress, itemIgnore);
|
||||
SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress);
|
||||
SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, _disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress);
|
||||
skillManager.RemoveSkill("Dwarf Toss", "Block Toss");
|
||||
skillManager.removeSkill("Whirlwind Axe");
|
||||
skillManager.removeSkill("Shield Smash");
|
||||
@ -240,6 +243,16 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
addCommand(new MapCommand(this));
|
||||
}
|
||||
|
||||
public DisguiseManager getDisguiseManager()
|
||||
{
|
||||
return _disguiseManager;
|
||||
}
|
||||
|
||||
public NpcManager getNPCManager()
|
||||
{
|
||||
return _npcManager;
|
||||
}
|
||||
|
||||
public ClansRegions getClanRegions()
|
||||
{
|
||||
return _clanRegions;
|
||||
|
@ -522,18 +522,9 @@ public class ClansUtility
|
||||
|
||||
public boolean canHurt(Player damagee, Player damager)
|
||||
{
|
||||
if (damagee == null)
|
||||
if (damagee == null || damager == null)
|
||||
return false;
|
||||
|
||||
if (isSafe(damagee))
|
||||
return false;
|
||||
|
||||
if (damager == null)
|
||||
return true;
|
||||
|
||||
if (isSafe(damager))
|
||||
return false;
|
||||
|
||||
|
||||
ClanRelation rel = relPP(damagee.getName(), damager.getName());
|
||||
|
||||
if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF)
|
||||
|
@ -20,6 +20,7 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
@ -271,6 +272,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
UtilPlayer.message(caller, F.main("Clans", "Clan name inappropriate. Please try a different name"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ClansBlacklist.isValidClanName(args[1]))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Clan name is blacklisted! Please try a different name."));
|
||||
return;
|
||||
}
|
||||
|
||||
for (String cur : Plugin.denyClan)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
import mineplex.game.clans.items.commands.GearCommand;
|
||||
@ -64,49 +65,31 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class LoggingManager extends MiniPlugin
|
||||
{
|
||||
public static final String SAFE_LOG_MESSAGE = "You have safely logged out!";
|
||||
public static final double SAFE_LOG_RANGE = 1.5d;
|
||||
public static final double SAFE_LOG_RANGE = 1.5d; // Distance a player can move while safe-logging
|
||||
public static final int LOGOUT_DURATION = 10000; // Duration of safe-log (in milliseconds)
|
||||
public static final long REJOIN_TIME = 60000;
|
||||
|
||||
//Track Offline Players
|
||||
private HashMap<String, LogoutData> _logouts;
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public LoggingManager(JavaPlugin plugin)
|
||||
public LoggingManager(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("Logout Manager", plugin);
|
||||
|
||||
_logouts = new HashMap<String, LogoutData>();
|
||||
}
|
||||
|
||||
private Set<Player> getNearbyHostilePlayers(Location location, double radius)
|
||||
{
|
||||
Set<Player> nearbyPlayers = new HashSet<Player>();
|
||||
|
||||
for (Player player : location.getWorld().getPlayers())
|
||||
{
|
||||
double radiusSquared = radius * radius;
|
||||
|
||||
if (player.getLocation().distanceSquared(location) <= radiusSquared) // TODO: Check to see if they're in a clan?
|
||||
{
|
||||
nearbyPlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return nearbyPlayers;
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
public void onPlayerQuit(Player player)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
LogoutData logoutData = _logouts.remove(player.getName());
|
||||
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout() && !player.isDead();
|
||||
boolean isSafeLog = logoutData != null && logoutData.hasSafeLogout();
|
||||
|
||||
if (!isSafeLog && getNearbyHostilePlayers(player.getLocation(), 32d).size() == 1) // No other players within 32 blocks
|
||||
{
|
||||
isSafeLog = true;
|
||||
}
|
||||
// Players logging in safe zones are safe
|
||||
if (_clansManager.getClanUtility().isSafe(location)) isSafeLog = true;
|
||||
|
||||
// TODO: Check to see if player was attacked or attacked another player within last 15 seconds and set isSafeLog=false...
|
||||
if (!isSafeLog)
|
||||
{
|
||||
onCombatLog(player);
|
||||
@ -121,7 +104,7 @@ public class LoggingManager extends MiniPlugin
|
||||
NPCManager.getInstance().despawnLogoutNpc(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
@ -164,7 +147,8 @@ public class LoggingManager extends MiniPlugin
|
||||
{
|
||||
LogoutData data = new LogoutData(player, duration);
|
||||
_logouts.put(player.getName(), data);
|
||||
notify(player, "Successfully initiated safe-log!");
|
||||
long logoutDuration = UtilTime.convert(LOGOUT_DURATION, TimeUnit.MILLISECONDS, TimeUnit.SECONDS);
|
||||
notify(player, String.format("Successfully initiated safe-log! Do not move for %d seconds...", logoutDuration));
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -1,34 +1,56 @@
|
||||
package mineplex.game.clans.gameplay.safelog.npc;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.EntityInsentient;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
||||
|
||||
public class CombatLogNPC
|
||||
{
|
||||
|
||||
public final static EntityType NPC_TYPE = EntityType.VILLAGER;
|
||||
|
||||
private String _playerName;
|
||||
private PlayerInfo _playerInfo;
|
||||
|
||||
private DisguiseManager _disguiseManager;
|
||||
private long _spawnDate;
|
||||
private double _spawnHealth;
|
||||
|
||||
private LivingEntity _npc;
|
||||
public int getEntityId() { return _npc.getEntityId(); }
|
||||
|
||||
public CombatLogNPC(Player player)
|
||||
public CombatLogNPC(Player player, DisguiseManager disguiseManager)
|
||||
{
|
||||
_playerName = player.getName();
|
||||
_playerInfo = new PlayerInfo(player);
|
||||
_disguiseManager = disguiseManager;
|
||||
_spawnDate = 0;
|
||||
_spawnHealth = player.getHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -36,18 +58,39 @@ public class CombatLogNPC
|
||||
* and thus drops all the owner's items.
|
||||
*/
|
||||
public void onDeath()
|
||||
{
|
||||
Location location = _npc.getLocation();
|
||||
World world = location.getWorld();
|
||||
|
||||
File file = new File(world.getWorldFolder(), String.format("playerdata/%s.dat", _playerInfo.getPlayerUuid()));
|
||||
file.delete(); // Delete the player's .dat file so they will join with empty inventory/respawn on next login
|
||||
|
||||
_playerInfo.dropItems(location);
|
||||
_disguiseManager.undisguise(_npc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true, if the {@code _npc} associated with this CombatLogNPC is alive, false otherwise.
|
||||
*/
|
||||
public boolean isAlive()
|
||||
{
|
||||
Player player = getPlayer();
|
||||
UtilInv.drop(player, true);
|
||||
player.setHealth(0.0d);
|
||||
return _npc != null && !_npc.isDead();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of time (in milliseconds) that this npc has been alive an spawned in.
|
||||
*/
|
||||
public long getAliveDuation()
|
||||
{
|
||||
return System.currentTimeMillis() - _spawnDate;
|
||||
}
|
||||
|
||||
public void spawn()
|
||||
{
|
||||
System.out.println("Spawning");
|
||||
if (_npc != null) despawn();
|
||||
|
||||
_npc = spawnNpc(getPlayer());
|
||||
_spawnDate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void despawn()
|
||||
@ -62,27 +105,36 @@ public class CombatLogNPC
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
return _playerInfo.getPlayer();
|
||||
}
|
||||
|
||||
public boolean matchesPlayer(Player player)
|
||||
{
|
||||
return _playerName.equalsIgnoreCase(player.getName());
|
||||
return _playerInfo.getPlayerName().equalsIgnoreCase(player.getName());
|
||||
}
|
||||
|
||||
private LivingEntity spawnNpc(Player player)
|
||||
{
|
||||
Location location = player.getLocation();
|
||||
World world = location.getWorld();
|
||||
LivingEntity entity = (LivingEntity) world.spawnEntity(location, NPC_TYPE);
|
||||
|
||||
// Initialize proper values of entity NPC on spawn
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setCustomName(ChatColor.RESET + player.getName());
|
||||
entity.setCanPickupItems(false);
|
||||
entity.setRemoveWhenFarAway(false);
|
||||
//((EntityInsentient) ((CraftLivingEntity) entity).getHandle()).persistent = true;
|
||||
Location spawnLoc = player.getLocation();
|
||||
Skeleton skel = player.getWorld().spawn(spawnLoc, Skeleton.class);
|
||||
skel.teleport(spawnLoc);
|
||||
skel.setHealth(_spawnHealth);
|
||||
UtilEnt.Vegetate(skel);
|
||||
UtilEnt.silence(skel, true);
|
||||
|
||||
return entity;
|
||||
skel.getEquipment().setHelmet(player.getInventory().getHelmet());
|
||||
skel.getEquipment().setChestplate(player.getInventory().getChestplate());
|
||||
skel.getEquipment().setLeggings(player.getInventory().getLeggings());
|
||||
skel.getEquipment().setBoots(player.getInventory().getBoots());
|
||||
skel.getEquipment().setItemInHand(player.getItemInHand());
|
||||
|
||||
//Get in range
|
||||
List<Player> inRange = UtilPlayer.getNearby(spawnLoc, 75d);
|
||||
|
||||
//Disguise
|
||||
DisguisePlayer disguise = new DisguisePlayer(skel, ((CraftPlayer)player).getHandle().getProfile());
|
||||
_disguiseManager.disguise(disguise, inRange.toArray(new Player[inRange.size()]));
|
||||
|
||||
return skel;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.gameplay.safelog.npc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
@ -8,6 +9,8 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.generation.WeightSet;
|
||||
import mineplex.game.clans.shop.energy.EnergyShop;
|
||||
@ -18,6 +21,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
@ -25,6 +29,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class NPCManager extends MiniPlugin
|
||||
{
|
||||
public final long COMBAT_LOG_DURATION = 15000; // Time (in milliseconds) before a combat log NPC disappears.
|
||||
|
||||
private static NPCManager _instance;
|
||||
public static NPCManager getInstance() { return _instance; }
|
||||
|
||||
@ -57,7 +63,7 @@ public class NPCManager extends MiniPlugin
|
||||
{
|
||||
if (!hasLogoutNpc(player))
|
||||
{
|
||||
CombatLogNPC npc = new CombatLogNPC(player);
|
||||
CombatLogNPC npc = new CombatLogNPC(player, _clansManager.getDisguiseManager());
|
||||
npc.spawn();
|
||||
_logoutNpcs.add(npc);
|
||||
log(String.format("Spawned combat log NPC for %s!", player.getName()));
|
||||
@ -102,6 +108,41 @@ public class NPCManager extends MiniPlugin
|
||||
if (logoutNpc != null)
|
||||
{
|
||||
logoutNpc.onDeath();
|
||||
event.getDrops().clear(); // Clear the entity's item drops. Manually drops combat log items earlier
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityIgnite(EntityCombustEvent event)
|
||||
{
|
||||
if (isLogoutNpc(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW) return;
|
||||
|
||||
Iterator<CombatLogNPC> iterator = _logoutNpcs.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
CombatLogNPC npc = iterator.next();
|
||||
|
||||
if (!npc.isAlive())
|
||||
{
|
||||
System.out.println("NOT ALIVE AND REMOVING");
|
||||
iterator.remove();
|
||||
}
|
||||
else if (npc.getAliveDuation() > COMBAT_LOG_DURATION)
|
||||
{
|
||||
System.out.println("DESPAWNING");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
package mineplex.game.clans.gameplay.safelog.npc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class PlayerInfo
|
||||
{
|
||||
|
||||
private String _playerName;
|
||||
public String getPlayerName() { return _playerName; }
|
||||
|
||||
private String _playerUuid;
|
||||
public String getPlayerUuid() { return _playerUuid; }
|
||||
|
||||
private Set<ItemStack> _items;
|
||||
public Set<ItemStack> getItems() { return _items; }
|
||||
|
||||
public PlayerInfo(Player player)
|
||||
{
|
||||
_playerName = player.getName();
|
||||
_playerUuid = player.getUniqueId().toString();
|
||||
_items = fetchItems(player.getInventory());
|
||||
}
|
||||
|
||||
public void dropItems(Location location)
|
||||
{
|
||||
World world = location.getWorld();
|
||||
for (ItemStack item : _items)
|
||||
{
|
||||
world.dropItemNaturally(location, item);
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
}
|
||||
|
||||
private Set<ItemStack> fetchItems(PlayerInventory inventory)
|
||||
{
|
||||
Set<ItemStack> items = new HashSet<ItemStack>();
|
||||
|
||||
addItems(items, inventory.getArmorContents());
|
||||
addItems(items, inventory.getContents());
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private void addItems(Set<ItemStack> items, ItemStack[] itemsToAdd)
|
||||
{
|
||||
for (ItemStack item : itemsToAdd)
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -44,6 +44,7 @@ public class CustomItem
|
||||
_displayName = displayName;
|
||||
_description = description;
|
||||
_material = material;
|
||||
_attributes = new AttributeContainer();
|
||||
_uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,11 @@ public class AttributeContainer
|
||||
_suffix = suffix;
|
||||
}
|
||||
|
||||
public AttributeContainer()
|
||||
{
|
||||
this(null, null, null);
|
||||
}
|
||||
|
||||
public Set<ItemAttribute> getAttributes()
|
||||
{
|
||||
Set<ItemAttribute> attributes = new HashSet<ItemAttribute>();
|
||||
|
@ -5,6 +5,7 @@ import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
@ -26,28 +27,40 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.items.generation.WeightSet;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class Spawn extends MiniPlugin
|
||||
{
|
||||
public static final int SPAWN_RADIUS = 32;
|
||||
public static final int SHOP_RADIUS = 48;
|
||||
public static final String COMBAT_TAG_NAME = "Unsafe";
|
||||
|
||||
private static Spawn _instance;
|
||||
public static Spawn getInstance() { return _instance; }
|
||||
|
||||
private WeightSet<Location> _spawns;
|
||||
private WeightSet<Location> _shops;
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public Spawn(JavaPlugin plugin)
|
||||
public Spawn(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("Clan Spawn Zones", plugin);
|
||||
|
||||
_instance = this;
|
||||
_spawns = new WeightSet<Location>(getNorthSpawn(), getSouthSpawn());
|
||||
_shops = new WeightSet<Location>(getEastShop(), getWestShop());
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,6 +92,43 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
return;
|
||||
|
||||
for (Player cur : UtilServer.getPlayers())
|
||||
{
|
||||
if (_clansManager.getClanUtility().isSafe(cur.getLocation()))
|
||||
{
|
||||
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat();
|
||||
|
||||
if (!UtilTime.elapsed(lastDamager, 15000))
|
||||
{
|
||||
UtilPlayer.message(cur, F.main("Safe Zone", "You are not safe for " +
|
||||
F.time(UtilTime.convertString(15000 - (System.currentTimeMillis() - lastDamager), 1, TimeUnit.FIT))));
|
||||
|
||||
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSkillTriggered(SkillTriggerEvent event)
|
||||
{
|
||||
if (event.GetTargets() == null) return;
|
||||
|
||||
for (Entity entity : event.GetTargets())
|
||||
{
|
||||
if (isInSpawn(entity))
|
||||
{
|
||||
event.SetCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
@ -170,17 +220,18 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerAttacked(EntityDamageByEntityEvent event)
|
||||
public void onPlayerAttacked(CustomDamageEvent event)
|
||||
{
|
||||
Entity defender = event.getEntity();
|
||||
Player defender = event.GetDamageePlayer();
|
||||
|
||||
if (defender instanceof Player)
|
||||
if (defender != null)
|
||||
{
|
||||
Player player = (Player) defender;
|
||||
|
||||
if (isInSpawn(player) && !isCombatTagged(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.SetCancelled("Safe Zone");
|
||||
attemptNotify(event.GetDamagerPlayer(true), "You cannot attack players who are in spawn!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,23 +255,7 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
public boolean isInSpawn(Location location)
|
||||
{
|
||||
for(Location spawn : _spawns.elements())
|
||||
{
|
||||
if (isInRadius(spawn, location, SPAWN_RADIUS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for(Location shop : _shops.elements())
|
||||
{
|
||||
if (isInRadius(shop, location, SHOP_RADIUS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return _clansManager.getClanUtility().isSafe(location); // Check to see if location is in a SafeZone chunk
|
||||
}
|
||||
|
||||
private static boolean isInRadius(Location origin, Location location, int radius)
|
||||
@ -263,12 +298,7 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
private boolean isCombatTagged(Player player)
|
||||
{
|
||||
return false; // TODO: Check for implemented combat tagging?
|
||||
}
|
||||
|
||||
private void notify(Player player, String message)
|
||||
{
|
||||
|
||||
return _clansManager.getCondition().HasCondition(player, ConditionType.CUSTOM, COMBAT_TAG_NAME);
|
||||
}
|
||||
|
||||
private void teleport(final Player player, final Location location, int delay)
|
||||
@ -280,4 +310,18 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to send a {@code message} to {@code entity} if they are a {@link Player}.
|
||||
* @param entity
|
||||
* @param message
|
||||
*/
|
||||
private static void attemptNotify(Entity entity, String message)
|
||||
{
|
||||
if (entity instanceof Player)
|
||||
{
|
||||
Player player = (Player) entity;
|
||||
UtilPlayer.message(player, F.main("Clans", message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package mineplex.minecraft.game.classcombat.Skill.Brute;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,6 +26,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillActiveCharge;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
|
||||
public class FleshHook extends SkillActiveCharge implements IThrown
|
||||
{
|
||||
@ -138,6 +140,11 @@ public class FleshHook extends SkillActiveCharge implements IThrown
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
SkillTriggerEvent triggerEvent = new SkillTriggerEvent(player , GetName(), GetClassType(), target);
|
||||
UtilServer.getServer().getPluginManager().callEvent(triggerEvent);
|
||||
|
||||
if (triggerEvent.IsCancelled()) return;
|
||||
|
||||
//Pull
|
||||
UtilAction.velocity(target,
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -96,7 +97,7 @@ public class GolemBlockShot extends GolemAbility
|
||||
Location loc1 = getLocation();
|
||||
Location loc2 = loc1.clone().add(loc1.getDirection().setY(0).normalize());
|
||||
|
||||
LinkedList<Player> players = UtilPlayer.getNearby(getLocation(), 40, true);
|
||||
List<Player> players = UtilPlayer.getNearby(getLocation(), 40, true);
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@ package mineplex.minecraft.game.core.boss.ironwizard.abilities;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
@ -293,7 +294,7 @@ public class GolemCaveIn extends GolemAbility
|
||||
return;
|
||||
}
|
||||
|
||||
LinkedList<Player> players = UtilPlayer.getNearby(getLocation(), 50, true);
|
||||
List<Player> players = UtilPlayer.getNearby(getLocation(), 50, true);
|
||||
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.minecraft.game.core.boss.slimeking.ability;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
@ -118,7 +119,7 @@ public class SlamAbility extends SlimeAbility
|
||||
private void damageArea(Location location)
|
||||
{
|
||||
// TODO Deal more damage based on how close you are to the slime?
|
||||
LinkedList<Player> nearPlayers = UtilPlayer.getNearby(location, 4);
|
||||
List<Player> nearPlayers = UtilPlayer.getNearby(location, 4);
|
||||
for (Player player : nearPlayers)
|
||||
{
|
||||
player.damage(4);
|
||||
|
@ -19,7 +19,9 @@ public class NpcProtectListener implements Listener
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void CustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetDamageeEntity() != null && _npcManager.getNpcByEntity(event.GetDamageeEntity()) != null)
|
||||
if (_npcManager.isNpc(event.GetDamageeEntity()))
|
||||
{
|
||||
event.SetCancelled("NPC");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user