Final push
This commit is contained in:
parent
2b64de8ad1
commit
eb6003a169
@ -60,6 +60,7 @@ import mineplex.gemhunters.beta.BetaModule;
|
||||
import mineplex.gemhunters.bounties.BountyModule;
|
||||
import mineplex.gemhunters.chat.ChatModule;
|
||||
import mineplex.gemhunters.death.DeathModule;
|
||||
import mineplex.gemhunters.death.npc.NPCManager;
|
||||
import mineplex.gemhunters.debug.DebugModule;
|
||||
import mineplex.gemhunters.economy.CashOutModule;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
@ -268,6 +269,9 @@ public class GemHunters extends JavaPlugin
|
||||
new TimeCycle(this);
|
||||
new UndergroundMobs(this);
|
||||
|
||||
// Combat npc
|
||||
new NPCManager(hologramManager);
|
||||
|
||||
// UpdateEvent!!!
|
||||
new Updater(this);
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class BetaModule extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final String[] ANNOUCEMENTS = {
|
||||
"Please remember this game is an early access BETA and all bugs should be reported to a staff member.",
|
||||
"Please remember this game is an early access BETA and all bugs should be reported at mineplex.com/forums/m/11929946/viewforum/8006500 .",
|
||||
"Thank you for playing Gem Hunters!",
|
||||
"Many more features are being added over the coming days!",
|
||||
"Players in your party show up on your map!",
|
||||
|
@ -13,12 +13,12 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ -77,23 +77,18 @@ public class DeathModule extends MiniPlugin
|
||||
// Stop the player dieing
|
||||
player.setHealth(20);
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(20);
|
||||
player.setExhaustion(0);
|
||||
|
||||
startAnimation(player);
|
||||
_toRemove.put(player.getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
Iterator<ItemStack> iterator = event.getDrops().iterator();
|
||||
|
||||
// Iterate through all items and clear any disallowed items
|
||||
while (iterator.hasNext())
|
||||
@EventHandler
|
||||
public void itemSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
if (DISALLOWED_DROPS.contains(event.getEntity().getItemStack().getType()))
|
||||
{
|
||||
ItemStack itemStack = iterator.next();
|
||||
|
||||
if (DISALLOWED_DROPS.contains(itemStack.getType()))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,238 @@
|
||||
package mineplex.gemhunters.death.npc;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
|
||||
public class CombatLogNPC
|
||||
{
|
||||
public final static EntityType NPC_TYPE = EntityType.VILLAGER;
|
||||
|
||||
private PlayerInfo _playerInfo;
|
||||
|
||||
private Hologram _hologram;
|
||||
|
||||
private DisguiseManager _disguiseManager;
|
||||
private long _spawnDate;
|
||||
private final long _endingTime;
|
||||
private double _spawnHealth;
|
||||
|
||||
private boolean _creative;
|
||||
|
||||
private LivingEntity _npc;
|
||||
private ArmorStand _stand;
|
||||
|
||||
private CraftLivingEntity _lastDamager;
|
||||
|
||||
public int getEntityId()
|
||||
{
|
||||
return _npc.getEntityId();
|
||||
}
|
||||
|
||||
public CombatLogNPC(Player player, DisguiseManager disguiseManager, HologramManager hologramManager, boolean wasCreative)
|
||||
{
|
||||
_playerInfo = new PlayerInfo(player);
|
||||
_creative = wasCreative;
|
||||
|
||||
_disguiseManager = disguiseManager;
|
||||
_hologram = new Hologram(hologramManager, player.getEyeLocation().add(0, 1, 0), C.cYellow + UtilTime.MakeStr(NPCManager.COMBAT_LOG_DURATION) + C.cWhite + " Seconds left before despawn");
|
||||
_spawnDate = 0;
|
||||
_endingTime = System.currentTimeMillis() + NPCManager.COMBAT_LOG_DURATION;
|
||||
_spawnHealth = player.getHealth();
|
||||
_hologram.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the {@code _npc} associated with this CombatLogNPC is killed
|
||||
* and thus drops all the owner's items.
|
||||
*/
|
||||
public void onDeath(CraftLivingEntity killer)
|
||||
{
|
||||
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
|
||||
if (killer != null)
|
||||
{
|
||||
String killerName = "Unknown";
|
||||
|
||||
if (killer instanceof CraftPlayer)
|
||||
{
|
||||
killerName = ((CraftPlayer) killer).getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
killerName = UtilEnt.getName(killer);
|
||||
}
|
||||
|
||||
// try
|
||||
// {
|
||||
// DataOutputStream stream = new DataOutputStream(new FileOutputStream(_userDataPath + String.format("DEATH_%s.dat", _playerInfo.getPlayerUuid())));
|
||||
//
|
||||
// stream.writeLong(System.currentTimeMillis());
|
||||
// stream.writeInt(killerName.length());
|
||||
// stream.writeBytes(killerName);
|
||||
//
|
||||
// stream.close();
|
||||
// }
|
||||
// catch (IOException e)
|
||||
// {
|
||||
// System.out.println(String.format("FATAL ERROR while trying to create player death lock for %s, meaning %s will not be informed that they died next time they log in.", _playerInfo.getPlayerName(), _playerInfo.getPlayerName()));
|
||||
// }
|
||||
|
||||
UtilServer.broadcast(F.main("Death", F.elem(_playerInfo.getPlayerName()) + " was killed by " + F.elem(killerName) + " while combat logged."));
|
||||
}
|
||||
|
||||
_playerInfo.dropItems(location);
|
||||
_disguiseManager.undisguise(_npc);
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
_hologram.setText("Quitting in " + UtilTime.MakeStr(Math.max(_endingTime - System.currentTimeMillis(), 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true, if the {@code _npc} associated with this CombatLogNPC is
|
||||
* alive, false otherwise.
|
||||
*/
|
||||
public boolean isAlive()
|
||||
{
|
||||
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()
|
||||
{
|
||||
if (_npc != null) despawn();
|
||||
|
||||
_npc = spawnNpc(getPlayer());
|
||||
_spawnDate = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void despawn()
|
||||
{
|
||||
System.out.println("Despawning");
|
||||
if (_npc != null)
|
||||
{
|
||||
if (_stand != null)
|
||||
{
|
||||
_stand.setPassenger(null);
|
||||
_stand.remove();
|
||||
_stand = null;
|
||||
}
|
||||
|
||||
_npc.remove();
|
||||
_npc = null;
|
||||
_hologram.stop();
|
||||
_hologram = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
if (_hologram != null)
|
||||
{
|
||||
_hologram.stop();
|
||||
_hologram = null;
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerInfo getPlayerInfo()
|
||||
{
|
||||
return _playerInfo;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _playerInfo.getPlayer();
|
||||
}
|
||||
|
||||
public boolean matchesPlayer(Player player)
|
||||
{
|
||||
return _playerInfo.getPlayerName().equalsIgnoreCase(player.getName());
|
||||
}
|
||||
|
||||
private LivingEntity spawnNpc(Player player)
|
||||
{
|
||||
Location spawnLoc = player.getLocation();
|
||||
Skeleton skel = player.getWorld().spawn(spawnLoc, Skeleton.class);
|
||||
skel.setMetadata("CombatLogNPC", new FixedMetadataValue(UtilServer.getPlugin(), player.getUniqueId().toString()));
|
||||
skel.teleport(spawnLoc);
|
||||
skel.setHealth(_spawnHealth);
|
||||
UtilEnt.vegetate(skel);
|
||||
UtilEnt.silence(skel, true);
|
||||
|
||||
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, attempted -> inRange.contains(attempted));
|
||||
|
||||
if (!UtilEnt.isGrounded(player))
|
||||
{
|
||||
ArmorStand stand = player.getWorld().spawn(spawnLoc.clone().subtract(0,1,0), ArmorStand.class);
|
||||
|
||||
stand.setVisible(false);
|
||||
stand.setPassenger(skel);
|
||||
stand.setGravity(false);
|
||||
|
||||
_stand = stand;
|
||||
}
|
||||
|
||||
return skel;
|
||||
}
|
||||
|
||||
public boolean wasCreative()
|
||||
{
|
||||
return _creative;
|
||||
}
|
||||
|
||||
public CraftLivingEntity getLastDamager()
|
||||
{
|
||||
return _lastDamager;
|
||||
}
|
||||
|
||||
public void setLastDamager(CraftLivingEntity damager)
|
||||
{
|
||||
_lastDamager = damager;
|
||||
}
|
||||
}
|
@ -0,0 +1,253 @@
|
||||
package mineplex.gemhunters.death.npc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
public class NPCManager extends MiniPlugin
|
||||
{
|
||||
public static final long COMBAT_LOG_DURATION = 30000;
|
||||
|
||||
private static NPCManager _instance;
|
||||
|
||||
public static NPCManager getInstance()
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
|
||||
private Set<CombatLogNPC> _logoutNpcs;
|
||||
private Set<Integer> _toKillIds;
|
||||
|
||||
private HologramManager _hologramManager;
|
||||
|
||||
public NPCManager(HologramManager hologramManager)
|
||||
{
|
||||
super("NPC Manager");
|
||||
|
||||
_instance = this;
|
||||
_logoutNpcs = new HashSet<>();
|
||||
_toKillIds = new HashSet<>();
|
||||
_hologramManager = hologramManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
NPCManager.getInstance().spawnLogoutNpc(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
log("Killing logout npcs");
|
||||
|
||||
// Despawn/kill all combat log NPCs on server shutdown
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
npc.despawn();
|
||||
}
|
||||
_logoutNpcs.clear();
|
||||
}
|
||||
|
||||
public void spawnLogoutNpc(Player player)
|
||||
{
|
||||
if (!hasLogoutNpc(player))
|
||||
{
|
||||
CombatLogNPC npc = new CombatLogNPC(player, require(DisguiseManager.class), _hologramManager, player.getGameMode().equals(GameMode.CREATIVE));
|
||||
npc.spawn();
|
||||
_logoutNpcs.add(npc);
|
||||
log(String.format("Spawned combat log NPC for %s!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void killNpcs(PlayerJoinEvent event)
|
||||
{
|
||||
for (LivingEntity entity : Bukkit.getWorlds().get(0).getLivingEntities())
|
||||
{
|
||||
if (entity.hasMetadata("CombatLogNPC") && ((FixedMetadataValue) entity.getMetadata("CombatLogNPC").get(0)).asString().equals(event.getPlayer().getUniqueId().toString()))
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnLogoutNpc(Player player)
|
||||
{
|
||||
CombatLogNPC npc = getLogoutNpc(player);
|
||||
|
||||
if (npc != null)
|
||||
{
|
||||
_toKillIds.add(npc.getEntityId());
|
||||
npc.despawn();
|
||||
_logoutNpcs.remove(npc);
|
||||
log(String.format("Despawned combat log NPC for %s!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasLogoutNpc(Player player)
|
||||
{
|
||||
return getLogoutNpc(player) != null;
|
||||
}
|
||||
|
||||
public CombatLogNPC getLogoutNpc(Player player)
|
||||
{
|
||||
for (CombatLogNPC logoutNpc : _logoutNpcs)
|
||||
{
|
||||
if (logoutNpc.matchesPlayer(player))
|
||||
{
|
||||
return logoutNpc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event)
|
||||
{
|
||||
for (Entity entity : event.getChunk().getEntities())
|
||||
{
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
if (entity.getEntityId() == npc.getEntityId())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.getEntity());
|
||||
|
||||
if (logoutNpc != null)
|
||||
{
|
||||
logoutNpc.onDeath(logoutNpc.getLastDamager());
|
||||
event.getDrops().clear(); // Clear the entity's item drops. Manually
|
||||
// drops combat log items earlier
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityDamaged(CustomDamageEvent event)
|
||||
{
|
||||
CombatLogNPC logoutNpc = getLogoutNpc(event.GetDamageeEntity());
|
||||
|
||||
if (logoutNpc != null && event.GetDamagerEntity(true) != null)
|
||||
{
|
||||
if (logoutNpc.wasCreative())
|
||||
{
|
||||
event.SetCancelled("Cannot hurt creative player");
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.GetDamagerPlayer(true) != null)
|
||||
{
|
||||
event.GetDamagerPlayer(true).playSound(event.GetDamagerPlayer(true).getLocation(), Sound.HURT_FLESH, 1, 1);
|
||||
}
|
||||
|
||||
logoutNpc.setLastDamager(((CraftLivingEntity) event.GetDamagerEntity(true)));
|
||||
event.SetKnockback(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityIgnite(EntityCombustEvent event)
|
||||
{
|
||||
if (isLogoutNpc(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() == UpdateType.FASTER)
|
||||
{
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
Iterator<CombatLogNPC> iterator = _logoutNpcs.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
CombatLogNPC npc = iterator.next();
|
||||
|
||||
if (Bukkit.getPlayer(npc.getPlayerInfo().getPlayerName()) != null)
|
||||
{
|
||||
System.out.println("{NPCMANAGER} ORIGINAL PLAYER ALIVE AND DESPAWNING");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
else if (!npc.isAlive())
|
||||
{
|
||||
System.out.println("{NPCMANAGER} NOT ALIVE AND REMOVING");
|
||||
npc.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
else if (npc.getAliveDuation() > COMBAT_LOG_DURATION)
|
||||
{
|
||||
System.out.println("{NPCMANAGER} DESPAWNING");
|
||||
npc.despawn();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLogoutNpc(Entity entity)
|
||||
{
|
||||
return getLogoutNpc(entity) != null;
|
||||
}
|
||||
|
||||
private CombatLogNPC getLogoutNpc(Entity entity)
|
||||
{
|
||||
return getLogoutNpc(entity.getEntityId());
|
||||
}
|
||||
|
||||
private CombatLogNPC getLogoutNpc(int entityId)
|
||||
{
|
||||
for (CombatLogNPC npc : _logoutNpcs)
|
||||
{
|
||||
if (npc.getEntityId() == entityId)
|
||||
{
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package mineplex.gemhunters.death.npc;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
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;
|
||||
private UUID _playerUuid;
|
||||
private ItemStack[] _armor;
|
||||
private Set<ItemStack> _items;
|
||||
private Location _location;
|
||||
|
||||
public PlayerInfo(Player player)
|
||||
{
|
||||
_playerName = player.getName();
|
||||
_playerUuid = player.getUniqueId();
|
||||
_armor = player.getInventory().getArmorContents();
|
||||
_items = fetchItems(player.getInventory());
|
||||
_location = player.getLocation();
|
||||
}
|
||||
|
||||
public void dropItems(Location location)
|
||||
{
|
||||
World world = location.getWorld();
|
||||
for (ItemStack item : _items)
|
||||
{
|
||||
world.dropItemNaturally(location, item);
|
||||
}
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
Player player = getPlayer();
|
||||
|
||||
player.getInventory().setArmorContents(_armor);
|
||||
player.getInventory().addItem(_items.toArray(new ItemStack[0]));
|
||||
player.teleport(_location);
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public Set<ItemStack> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return _playerUuid;
|
||||
}
|
||||
|
||||
public String getPlayerUuid()
|
||||
{
|
||||
return _playerUuid.toString();
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return Bukkit.getPlayerExact(_playerName);
|
||||
}
|
||||
|
||||
private Set<ItemStack> fetchItems(PlayerInventory inventory)
|
||||
{
|
||||
Set<ItemStack> items = new HashSet<ItemStack>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -32,7 +32,6 @@ import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -311,6 +310,8 @@ public class LootModule extends MiniPlugin
|
||||
|
||||
while (!suitable && attempts < MAX_SEARCH_ATTEMPTS)
|
||||
{
|
||||
chestToPlace = UtilAlg.getRandomLocation(randomLocation, placeRadius, 0, placeRadius);
|
||||
block = chestToPlace.getBlock();
|
||||
suitable = isSuitable(block);
|
||||
attempts++;
|
||||
}
|
||||
@ -357,12 +358,6 @@ public class LootModule extends MiniPlugin
|
||||
ItemStack itemStack = lootItem.getItemStack();
|
||||
int index = getFreeIndex(inventory.getSize(), used);
|
||||
|
||||
// if (lootItem.getMetadata() != null)
|
||||
// {
|
||||
// UtilFirework.playFirework(block.getLocation().add(0.5, 1, 0.5),
|
||||
// UtilFirework.getRandomFireworkEffect(false, 2, 1));
|
||||
// }
|
||||
|
||||
inventory.setItem(index, itemStack);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
@ -92,7 +93,8 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
mountType = mount.getMountType();
|
||||
}
|
||||
|
||||
spawnMount(player, mountType);
|
||||
player.sendMessage(F.main(_moduleName, "Mounts are currently disabled."));
|
||||
//spawnMount(player, mountType);
|
||||
}
|
||||
|
||||
public void spawnMount(Player player, MountType mountType)
|
||||
|
@ -87,7 +87,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
updateQuests(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
//@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
|
@ -134,7 +134,9 @@ public class TraderNPC extends SimpleNPC
|
||||
{
|
||||
for (TradeableItem item : _selling)
|
||||
{
|
||||
if (item.getLootItem().getItemStack().getType() == itemStack.getType())
|
||||
ItemStack itemStack2 = item.getLootItem().getItemStack();
|
||||
|
||||
if (itemStack.getType() == itemStack2.getType())
|
||||
{
|
||||
return item.getCost();
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.portal.Intent;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.gemhunters.death.npc.CombatLogNPC;
|
||||
import mineplex.gemhunters.death.npc.NPCManager;
|
||||
import mineplex.gemhunters.death.npc.PlayerInfo;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
|
||||
import mineplex.gemhunters.util.ColouredTextAnimation;
|
||||
@ -61,12 +64,23 @@ public class SpawnModule extends MiniPlugin
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
NPCManager npcManager = NPCManager.getInstance();
|
||||
|
||||
if (npcManager.hasLogoutNpc(player))
|
||||
{
|
||||
CombatLogNPC npc = npcManager.getLogoutNpc(player);
|
||||
PlayerInfo info = npc.getPlayerInfo();
|
||||
|
||||
info.restore();
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(_spawn);
|
||||
player.setFoodLevel(20);
|
||||
player.setExhaustion(0);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.updateInventory();
|
||||
|
||||
if (_npcsSpawned)
|
||||
{
|
||||
|
@ -72,8 +72,6 @@ public class SupplyDrop
|
||||
_lastHelicopter = new HashSet<>(100);
|
||||
_bladeBlocks = new HashSet<>(20);
|
||||
_diagonal = false;
|
||||
|
||||
spawn.getChunk().load();
|
||||
}
|
||||
|
||||
public boolean advancePath()
|
||||
@ -92,6 +90,8 @@ public class SupplyDrop
|
||||
|
||||
public boolean moveHelicopter()
|
||||
{
|
||||
_current.getChunk().load();
|
||||
|
||||
for (Block block : _lastHelicopter)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
|
@ -13,6 +13,8 @@ import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
@ -25,7 +27,7 @@ import mineplex.gemhunters.debug.DebugModule;
|
||||
public class UndergroundMobs implements Listener
|
||||
{
|
||||
|
||||
private static final int MAX_MOBS = 300;
|
||||
private static final int MAX_MOBS = 500;
|
||||
private static final String SEWER_KEY = "SEWER_MOB";
|
||||
private static final String SUBWAY_KEY = "SUBWAY_MOBS";
|
||||
|
||||
@ -89,4 +91,13 @@ public class UndergroundMobs implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cancelSuffication(EntityDamageEvent event)
|
||||
{
|
||||
if (event.getCause() == DamageCause.SUFFOCATION && _entities.contains(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user