Fix a lot of bugs

This commit is contained in:
Sam 2017-08-20 23:04:28 +01:00
parent 1c86cff6d7
commit fd090a5644
10 changed files with 281 additions and 144 deletions

View File

@ -12,6 +12,7 @@ import net.minecraft.server.v1_8_R3.NBTTagInt;
import net.minecraft.server.v1_8_R3.TileEntity;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
@ -29,7 +30,7 @@ import mineplex.core.common.block.DataLocationMap;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
public class Schematic implements Cloneable
public class Schematic
{
private final short _width;
private final short _height;
@ -67,6 +68,11 @@ public class Schematic implements Cloneable
this(width, height, length, blocks, blockData, null);
}
public Schematic(Schematic schematic)
{
this(schematic.getWidth(), schematic.getHeight(), schematic.getLength(), schematic.getBlocks(), schematic.getBlockData(), schematic.getWorldEditOffset(), schematic.getTileEntities(), schematic.getEntities());
}
public SchematicData paste(Location originLocation)
{
return paste(originLocation, false);
@ -269,21 +275,24 @@ public class Schematic implements Cloneable
/**
* Rotates the schematic 180 degrees.
*/
public void rotate180()
public Schematic rotate180()
{
// Swap blocks around
int area = _length * _width;
Bukkit.broadcastMessage("length=" + _length + " width=" + _width + " height=" + _height);
for (int height = 0; height < _height; height++)
{
int middleIndex = (int) (area * height / 2D);
int startIndex = height * area;
int endIndex = (int) (startIndex + area / 2D);
Bukkit.broadcastMessage("startIndex=" + startIndex + " endIndex=" + endIndex);
for (int lower = 0; lower <= middleIndex; lower++)
for (int lower = startIndex; lower <= endIndex; lower++)
{
int upper = area - lower;
int upper = endIndex - lower;
short temp = _blocks[lower];
byte tempData = _blockData[temp];
byte tempData = _blockData[lower];
_blocks[lower] = _blocks[upper];
_blocks[upper] = temp;
@ -299,6 +308,8 @@ public class Schematic implements Cloneable
blockVector.setX(-blockVector.getX());
blockVector.setZ(-blockVector.getZ());
});
return this;
}
public boolean hasWorldEditOffset()
@ -394,17 +405,4 @@ public class Schematic implements Cloneable
{
return String.format("Schematic [width: %d, length: %d, height: %d, blockLength: %d, blockDataLength: %d]", _width, _length, _height, _blocks.length, _blockData.length);
}
@Override
public Schematic clone()
{
try
{
return (Schematic) super.clone();
}
catch (CloneNotSupportedException e)
{
return null;
}
}
}

View File

@ -1,25 +1,16 @@
package mineplex.core.disguise;
import com.mineplex.spigot.ChunkAddEntityEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTasks;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Predicate;
import net.minecraft.server.v1_8_R3.BlockBed;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Blocks;
@ -30,7 +21,6 @@ import net.minecraft.server.v1_8_R3.EnumDirection;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutBed;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityEquipment;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
@ -43,6 +33,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.PacketPlayOutUpdateAttributes;
import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_8_R3.WorldSettings;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.BlockFace;
@ -57,17 +48,32 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.function.Predicate;
import com.mineplex.spigot.ChunkAddEntityEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTasks;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSquid;
import mineplex.core.hologram.HologramManager;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketInfo;
import mineplex.core.packethandler.PacketVerifier;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
/*
* notes: rabbit jump has been removed (PacketPlayOutEntityStatus) because it didn't work for 1.9+ anyways
@ -77,16 +83,19 @@ import java.util.function.Predicate;
@ReflectivelyCreateMiniPlugin
public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
private static final String HIDE_PLAYER_NAME_TEAM = "hiddenNPCS";
// A map of entityids which are disguised to their respective disguises
private Map<Integer, LinkedList<DisguiseBase>> _spawnPacketMap = new HashMap<>();
private final Map<Integer, LinkedList<DisguiseBase>> _spawnPacketMap = new HashMap<>();
// The map which stores entity UUIDs once they have been unloaded
private Map<UUID, LinkedList<DisguiseBase>> _entityDisguiseMap = new HashMap<>();
private final Map<UUID, LinkedList<DisguiseBase>> _entityDisguiseMap = new HashMap<>();
// The map of which players should a disguise be shown to
private Map<DisguiseBase, Predicate<Player>> _disguisePlayerMap = new HashMap<>();
private final Map<DisguiseBase, Predicate<Player>> _disguisePlayerMap = new HashMap<>();
private HashSet<String> _blockedNames = new HashSet<>();
private final HashSet<String> _blockedNames = new HashSet<>();
private boolean _handlingPacket = false;
@ -282,6 +291,20 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
entityPlayer.playerConnection.networkManager.handle(add);
}
// Cleanup team entries
Scoreboard scoreboard = player.getScoreboard();
if (scoreboard != null)
{
Team team = scoreboard.getTeam(HIDE_PLAYER_NAME_TEAM);
if (team != null)
{
String name = ((DisguisePlayer) originalDisguise).getName();
team.getEntries().removeIf(name::equals);
}
}
}
}
}
@ -678,6 +701,69 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
}
}
/**
* Handles hiding player disguises name tags if needed.
*/
@EventHandler
public void hideNames(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
{
return;
}
_disguisePlayerMap.forEach((disguise, showTest) ->
{
// Not a player, not interested.
if (!(disguise instanceof DisguisePlayer))
{
return;
}
DisguisePlayer disguisePlayer = (DisguisePlayer) disguise;
// Should show the name tag
if (!disguisePlayer.hasHologram())
{
return;
}
// For all players
Bukkit.getOnlinePlayers().forEach(player ->
{
// If the disguise is not to be shown
if (!showTest.test(player))
{
return;
}
Scoreboard scoreboard = player.getScoreboard();
// Null scoreboard
if (scoreboard == null)
{
return;
}
// Team which all hidden players are placed in
Team team = scoreboard.getTeam(HIDE_PLAYER_NAME_TEAM);
// Team didn't exist
if (team == null)
{
team = scoreboard.registerNewTeam(HIDE_PLAYER_NAME_TEAM);
team.setNameTagVisibility(NameTagVisibility.NEVER);
}
if (!team.hasEntry(disguisePlayer.getName()))
{
// Add the name of the disguised player into the team
team.addEntry(disguisePlayer.getName());
}
});
});
}
public enum UndisguiseReason
{
EXPLICIT,

View File

@ -39,9 +39,13 @@ import org.bukkit.event.EventHandler;
import com.mojang.authlib.GameProfile;
import mineplex.core.Managers;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilMath;
import mineplex.core.disguise.playerdisguise.PlayerDisguiseManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.hologram.HologramManager;
import mineplex.core.thread.ThreadPool;
import mineplex.core.utils.UtilGameProfile;
@ -63,6 +67,7 @@ public class DisguisePlayer extends DisguiseHuman
private boolean _replaceOriginalName = true;
private int _showInTabListDelay = 30;
private int _replaceOriginalNameDelay;
private Hologram _hologram;
private DisguisePlayer(Entity entity)
{
@ -254,7 +259,7 @@ public class DisguisePlayer extends DisguiseHuman
packet.c = MathHelper.floor(getEntity().locX * 32.0D);
packet.d = MathHelper.floor(getEntity().locY * 32.0D);
packet.e = MathHelper.floor(getEntity().locZ * 32.0D);
packet.f = (byte) ((int) ((getEntity().isFakeHead() ? getEntity().fakePitch : getEntity().pitch) * 256.0F / 360.0F));
packet.f = (byte) ((int) ((getEntity().isFakeHead() ? getEntity().fakeYaw : getEntity().yaw) * 256.0F / 360.0F));
packet.g = (byte) ((int) ((getEntity().isFakeHead() ? getEntity().fakePitch : getEntity().pitch) * 256.0F / 360.0F));
packet.i = DataWatcher;
@ -305,6 +310,11 @@ public class DisguisePlayer extends DisguiseHuman
update(entityPlayer);
}
}
if (hasHologram())
{
_hologram.start();
}
}
@Override
@ -476,6 +486,22 @@ public class DisguisePlayer extends DisguiseHuman
this._replaceOriginalNameDelay = delay;
}
public Hologram getHologram()
{
if (_hologram == null)
{
_hologram = new Hologram(Managers.require(HologramManager.class), getEntity().getBukkitEntity().getLocation().add(0, 1.75, 0), true)
.setRemoveOnEntityDeath();
}
return _hologram;
}
public boolean hasHologram()
{
return _hologram != null;
}
private UUID getOriginalUUID()
{
if (this._originalProfile.getProperties().containsKey(PlayerDisguiseManager.ORIGINAL_UUID_KEY))

View File

@ -90,12 +90,12 @@ public class EmblemGadget extends GameModifierGadget
{
Schematic schematic = _schematic;
if (inverse)
{
schematic = _schematic.clone();
schematic.rotate180();
}
// if (inverse)
// {
// schematic = new Schematic(schematic)
// .rotate180();
// }
return schematic.paste(location, true, true);
return schematic.paste(location.clone().add(0, schematic.getHeight() + 2, 0), true, true);
}
}

View File

@ -18,9 +18,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
@ -68,13 +66,6 @@ public class SkillBoxingRing extends HeroSkill
}
Player player = event.getPlayer();
if (!UtilEnt.isGrounded(player))
{
player.sendMessage(F.main("Game", "You cannot use " + F.skill(GetName()) + " while airborne."));
return;
}
Location location = player.getLocation().subtract(0, 1, 0);
byte colour = (byte) (Manager.GetGame().GetTeam(player).GetColor() == ChatColor.RED ? 14 : 11);
// // Double Plants work by the bottom block having a data value, in this case 4, the top part of the plant has

View File

@ -1,15 +1,13 @@
package nautilus.game.arcade.game.games.moba.modes;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.gadget.gadgets.gamemodifiers.moba.emblems.EmblemGadget;
import mineplex.core.game.GameDisplay;
@ -38,12 +36,9 @@ public class MobaMap implements Listener
for (GameTeam team : _host.GetTeamList())
{
List<Location> schematicSpawns = new ArrayList<>();
List<Location> schematicSpawns = _host.WorldData.GetCustomLocs("EMBLEM " + team.GetName().toUpperCase());
int index = 0;
String key = "EMBLEM " + team.GetName().toUpperCase();
schematicSpawns.addAll(_host.WorldData.GetCustomLocs(key));
schematicSpawns.addAll(_host.WorldData.GetCustomLocs(key + " R"));
boolean inverse = team.GetColor() == ChatColor.RED;
for (Player player : team.GetPlayers(true))
{
@ -62,10 +57,8 @@ public class MobaMap implements Listener
break;
}
Location location = schematicSpawns.get(index++).add(0, 1, 0);
Vector direction = UtilAlg.getTrajectory(location, _host.GetSpectatorLocation());
gadget.buildAt(location, direction.getX() < 0);
Location location = schematicSpawns.get(index++);
gadget.buildAt(location, inverse);
}
}
}

View File

@ -7,6 +7,7 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.Donor;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeFormat;
import nautilus.game.arcade.events.GameStateChangeEvent;
@ -20,6 +21,8 @@ import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.games.moba.progression.ui.MobaRoleShop;
import nautilus.game.arcade.game.games.moba.util.MobaUtil;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -87,6 +90,44 @@ public class MobaProgression implements Listener
caller.sendMessage(F.main("Debug", "Set your " + role.getChatColor() + role.getName() + C.cGray + " level to " + F.elem(getLevel(exp) + 1) + "."));
}
});
host.registerDebugCommand(new DebugCommand("unlockhero", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
Donor donor = _host.getArcadeManager().GetDonation().Get(caller);
String input = args[0];
boolean all = input.equalsIgnoreCase("ALL");
for (HeroKit kit : _host.getKits())
{
if (all || kit.GetName().equalsIgnoreCase(input))
{
caller.sendMessage(F.main("Debug", "Unlocked " + F.name(kit.GetName()) + "."));
donor.addOwnedUnknownSalesPackage(getPackageName(kit));
}
}
}
});
host.registerDebugCommand(new DebugCommand("lockhero", Rank.DEVELOPER)
{
@Override
public void Execute(Player caller, String[] args)
{
Donor donor = _host.getArcadeManager().GetDonation().Get(caller);
String input = args[0];
boolean all = input.equalsIgnoreCase("ALL");
for (HeroKit kit : _host.getKits())
{
if (all || kit.GetName().equalsIgnoreCase(input))
{
caller.sendMessage(F.main("Debug", "Locked " + F.name(kit.GetName()) + "."));
donor.removeOwnedUnknownSalesPackage(getPackageName(kit));
}
}
}
});
}
public void spawnRoleViewers(Map<String, List<Location>> lobbyLocations)

View File

@ -1,6 +1,25 @@
package nautilus.game.arcade.game.games.moba.progression;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.util.Vector;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
@ -14,26 +33,11 @@ import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.hologram.Hologram;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class MobaUnlockAnimation implements Listener
{
@ -89,8 +93,8 @@ public class MobaUnlockAnimation implements Listener
GameProfile profile = new GameProfile(UUID.randomUUID(), _kit.GetName());
profile.getProperties().clear();
profile.getProperties().put("textures", _kit.getSkinData().getProperty());
DisguisePlayer disguise = new DisguisePlayer(_npcEntity, profile);
disguise.setSendSkinDataToSelf(false);
_host.getArcadeManager().GetDisguise().disguise(disguise);
}
@ -107,7 +111,7 @@ public class MobaUnlockAnimation implements Listener
case 0:
if (!UtilTime.elapsed(_start, 2000))
{
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, _npcEntity.getLocation().add(0, 1.5, 0), 1, 1, 1, 0.0001F, 50, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, _npcEntity.getLocation().add(0, 1.5, 0), 1, 1, 1, 0, 50, ViewDist.NORMAL);
}
else
{
@ -139,7 +143,7 @@ public class MobaUnlockAnimation implements Listener
case 2:
if (UtilTime.elapsed(_start, 12000))
{
_player.sendMessage(F.main("Game", "Unlocked" + _kit.getRole().getChatColor() + _kit.GetName() + ". You can now select them at the start of the game!"));
_player.sendMessage(F.main("Game", "Unlocked " + F.name(_kit.getRole().getChatColor() + _kit.GetName()) + ". You can now select them at the start of the game!"));
_player.teleport(_spawn);
_player.playSound(_player.getLocation(), Sound.LEVEL_UP, 1, 1.2F);
cleanup();

View File

@ -5,13 +5,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -23,11 +18,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphGadget;
import mineplex.core.game.GameDisplay;
import mineplex.core.packethandler.PacketHandler.ListenerPriority;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.CombatComponent;
@ -81,41 +74,38 @@ public class MobaShop implements Listener
}
@EventHandler(priority = EventPriority.HIGHEST)
public void spawnNpc(GameStateChangeEvent event)
public void spawnNPC(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
return;
}
// Only spawn the NPCs once all players have been loaded into the world.
_host.getArcadeManager().runSyncLater(this::spawnShopNPCs, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10);
}
private void spawnShopNPCs()
{
ArrayList<Location> locations = _host.WorldData.GetDataLocs(MobaConstants.SHOP);
_host.CreatureAllowOverride = true;
for (GameTeam team : _host.GetTeamList())
{
Location location = UtilAlg.findClosest(team.GetSpawn(), locations);
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _host.GetSpectatorLocation())));
location.setPitch(0);
for (Player player : team.GetPlayers(true))
{
ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class);
stand.setRemoveWhenFarAway(false);
stand.setCustomName(getNPCName());
stand.setCustomNameVisible(true);
UtilEnt.vegetate(stand);
UtilEnt.silence(stand, true);
UtilEnt.ghost(stand, true, false);
UtilEnt.CreatureForceLook(stand, 0, UtilAlg.GetYaw(UtilAlg.getTrajectory(stand.getLocation(), _host.GetSpectatorLocation())));
ShopMorphGadget gadget = (ShopMorphGadget) _host.getArcadeManager().getCosmeticManager().getGadgetManager().getGameCosmeticManager().getActiveCosmetic(
player,
GameDisplay.MOBA,
"Shop Morph"
);
MobaShopNPC npc = new MobaShopNPC(this, player, stand, gadget);
MobaShopNPC npc = new MobaShopNPC(this, player, location, gadget);
_host.getArcadeManager().getPacketHandler().addPacketHandler(npc, ListenerPriority.NORMAL, false, PacketPlayInUseEntity.class, PacketPlayOutSpawnEntityLiving.class);
_entities.put(player, npc);
}
}
@ -135,7 +125,7 @@ public class MobaShop implements Listener
public void openShop(Player player)
{
if (_host.GetState() != GameState.Live)
if (!_host.IsLive())
{
return;
}
@ -172,25 +162,6 @@ public class MobaShop implements Listener
}
}
private void npcInteract(Entity clicked, Entity clicker)
{
if (!(clicker instanceof Player) || UtilPlayer.isSpectator(clicker))
{
return;
}
Player player = (Player) clicker;
for (LivingEntity shop : _entities.keySet())
{
if (clicked.equals(shop))
{
openShop(player);
return;
}
}
}
public void purchaseItem(Player player, MobaItem item)
{
List<MobaItem> owned = _upgrades.get(player);

View File

@ -2,9 +2,13 @@ package nautilus.game.arcade.game.games.moba.shop;
import java.util.UUID;
import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton.SkeletonType;
@ -12,6 +16,8 @@ import org.bukkit.entity.Skeleton.SkeletonType;
import com.mojang.authlib.GameProfile;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
@ -19,6 +25,7 @@ import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphGadget;
import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphType;
import mineplex.core.hologram.Hologram.HologramTarget;
import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo;
@ -30,13 +37,23 @@ public class MobaShopNPC implements IPacketHandler
private final ArmorStand _stand;
private final ShopMorphGadget _gadget;
public MobaShopNPC(MobaShop shop, Player player, ArmorStand stand, ShopMorphGadget gadget)
public MobaShopNPC(MobaShop shop, Player player, Location location, ShopMorphGadget gadget)
{
_shop = shop;
_player = player;
_stand = stand;
_gadget = gadget;
shop.getHost().getArcadeManager().getPacketHandler().addPacketHandler(this, PacketPlayInUseEntity.class, PacketPlayOutSpawnEntityLiving.class);
_stand = location.getWorld().spawn(location, ArmorStand.class);
_stand.setRemoveWhenFarAway(false);
_stand.setCustomName(MobaShop.getNPCName());
_stand.setCustomNameVisible(true);
UtilEnt.vegetate(_stand);
UtilEnt.silence(_stand, true);
UtilEnt.ghost(_stand, true, false);
disguise();
}
@ -58,8 +75,18 @@ public class MobaShopNPC implements IPacketHandler
profile.getProperties().put("textures", _gadget.getType().getSkinData().getProperty());
DisguisePlayer player = new DisguisePlayer(_stand, profile);
player.setReplaceOriginalName(false, 0);
player.getHologram()
.setHologramTarget(HologramTarget.WHITELIST)
.addPlayer(_player)
.setText(
MobaShop.getNPCName()
);
disguise = player;
Location location = _stand.getLocation();
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _shop.getHost().GetSpectatorLocation())));
_shop.getHost().getArcadeManager().runSyncLater(() -> _stand.teleport(location), 20);
}
else
{