Bug fixes

This commit is contained in:
Sam 2017-09-08 16:51:13 +01:00
parent 81f5f002f0
commit 554aeb6af5
14 changed files with 178 additions and 47 deletions

View File

@ -238,9 +238,9 @@ public class CosmeticManager extends MiniPlugin
return _punish;
}
public void displayUI(Player player)
public CosmeticShop getShop()
{
_shop.attemptShopOpen(player);
return _shop;
}
public void disableTeamArmor()

View File

@ -1,7 +1,5 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
@ -14,7 +12,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilServer;
@ -58,21 +55,10 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
@Override
protected void buildPage()
{
// Treasure Shards
int treasureShards = getDonationManager().Get(getPlayer()).getBalance(GlobalCurrency.TREASURE_SHARD);
List<String> shardLore = new ArrayList<>();
shardLore.add(" ");
shardLore.add(C.cGray + "These seem like they might come in");
shardLore.add(C.cGray + "handy. Maybe I should collect more!");
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
int deathSlot = 19;
int jumpSlot = 28;
int particleSlot = 1;
int winEffectSlot = 13;
int shardSlot = 22;
int arrowSlot = 10;
int tauntSlot = 31;
int gameModifierSlot = 21;
@ -86,9 +72,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
int flagSlot = 34;
int morphSlot = 25;
int costumeSlot = 16;
int powerPlaySlot = 40;
addItem(shardSlot, shards);
int powerPlaySlot = 22;
EnumMap<GadgetType, Integer> ownedCount = new EnumMap<>(GadgetType.class);
EnumMap<GadgetType, Integer> maxCount = new EnumMap<>(GadgetType.class);

View File

@ -24,7 +24,7 @@ public class GameCosmeticGadgetPage extends GadgetPage
public GameCosmeticGadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, GameCosmeticCategoryPage previousMenu, GameCosmeticCategory category)
{
super(plugin, shop, clientManager, donationManager, name, player, null);
super(plugin, shop, clientManager, donationManager, name, player);
_previousMenu = previousMenu;
_category = category;
@ -37,7 +37,14 @@ public class GameCosmeticGadgetPage extends GadgetPage
{
super.buildPage();
addButton(4, new ShopItem(Material.BED, C.cGreen + "Go Back", new String[]{}, 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), _previousMenu));
if (_previousMenu != null)
{
addButton(4, new ShopItem(Material.BED, C.cGreen + "Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), _previousMenu));
}
else
{
removeButton(4);
}
}
@Override

View File

@ -44,7 +44,6 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.commands.AmmoCommand;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.commands.TestUnlockCommand;
import mineplex.core.gadget.commands.UnlockCosmeticsCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetChangeEvent.GadgetState;
@ -438,7 +437,6 @@ public class GadgetManager extends MiniPlugin
addCommand(new UnlockCosmeticsCommand(this));
addCommand(new LockCosmeticsCommand(this));
addCommand(new AmmoCommand(this));
addCommand(new TestUnlockCommand(this));
}
private void createSets()

View File

@ -3,8 +3,10 @@ package mineplex.core.gadget.gadgets.gamemodifiers;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.cosmetic.ui.page.GadgetPage;
import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticCategoryPage;
import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticGadgetPage;
@ -43,6 +45,11 @@ public abstract class GameCosmeticCategory
_manager.addGadget(gadget);
}
public GadgetPage getGadgetPage(CosmeticManager manager, Player player)
{
return new GameCosmeticGadgetPage(manager, manager.getShop(), _manager.getClientManager(), _manager.getDonationManager(), _categoryName, player, null, this);
}
public GadgetPage getGadgetPage(GameCosmeticCategoryPage parent)
{
return new GameCosmeticGadgetPage(parent.getPlugin(), parent.getShop(), parent.getClientManager(), parent.getDonationManager(), _categoryName, parent.getClient().GetPlayer(), parent, this);

View File

@ -19,6 +19,7 @@ import mineplex.core.gadget.types.GameModifierGadget;
import mineplex.core.game.GameDisplay;
@ReflectivelyCreateMiniPlugin
// TODO Remove all the string literals for cosmetic categories
public class GameCosmeticManager extends MiniPlugin
{
@ -133,7 +134,7 @@ public class GameCosmeticManager extends MiniPlugin
return gadgetsCloned;
}
private GameCosmeticCategory getCategoryFrom(GameDisplay gameType, String categoryName)
public GameCosmeticCategory getCategoryFrom(GameDisplay gameType, String categoryName)
{
if (gameType == null || categoryName == null)
{

View File

@ -82,7 +82,7 @@ public enum GemHuntersMountType
return;
}
UtilParticle.PlayParticleToAll(ParticleType.FOOTSTEP, horse.getLocation(), null, 0, 1, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.FOOTSTEP, horse.getLocation().add(0, 0.2, 0), null, 0, 1, ViewDist.NORMAL);
}
},
RAINBOW_SHEEP("Rainbow Sheep Mount Skin", Material.WOOL, 14)
@ -116,7 +116,7 @@ public enum GemHuntersMountType
}
DisguiseSheep sheep = (DisguiseSheep) base;
int mod = horse.getTicksLived() % 4;
int mod = horse.getTicksLived() % 40;
if (mod == 0) sheep.setColor(DyeColor.RED);
else if (mod == 1) sheep.setColor(DyeColor.YELLOW);

View File

@ -59,6 +59,22 @@ public class HeroSkinGadget extends GameModifierGadget
return skinData;
}
private static String[] getDescription(HeroSkinGadgetData skinData)
{
boolean hasDescription = !skinData.getDescription().isEmpty();
String[] description = new String[hasDescription ? 3 : 2];
description[0] = C.cGray + "Rarity: " + skinData.getRarity().getColor() + skinData.getRarity().getName();
description[1] = "";
if (hasDescription)
{
description[2] = C.cGray + ChatColor.translateAlternateColorCodes('&', skinData.getDescription());
}
return description;
}
private final HeroSkinGadgetData _gadgetData;
public HeroSkinGadget(GadgetManager manager, GameCosmeticCategory category, HeroSkinGadgetData skinData)
@ -68,7 +84,7 @@ public class HeroSkinGadget extends GameModifierGadget
public HeroSkinGadget(GadgetManager manager, GameCosmeticCategory category, HeroSkinGadgetData skinData, int cost)
{
super(manager, category, skinData.getName() + " (" + skinData.getHero() + ")", new String[]{C.cGray + "Rarity: " + skinData.getRarity().getColor() + skinData.getRarity().getName(), "", C.cGray + ChatColor.translateAlternateColorCodes('&', skinData.getDescription())}, cost, Material.GLASS, (byte) 0);
super(manager, category, skinData.getName() + " (" + skinData.getHero() + ")", getDescription(skinData), cost, Material.GLASS, (byte) 0);
setDisplayItem(skinData.getSkinData().getSkull());
skinData.setGadget(this);

View File

@ -23,14 +23,21 @@ public class GameModifierGadget extends Gadget
@Override
public void enableCustom(Player player, boolean message)
{
_active.add(player);
if (message)
if (_active.add(player) && message)
{
UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.name(getName()) + " (" + F.name(_category.getCategoryName()) + ")."));
}
}
@Override
public void disableCustom(Player player, boolean message)
{
if (_active.remove(player) && message)
{
UtilPlayer.message(player, F.main(Manager.getName(), "You disabled " + F.name(getName()) + " (" + F.name(_category.getCategoryName()) + ")."));
}
}
public GameCosmeticCategory getCategory()
{
return _category;

View File

@ -122,26 +122,26 @@ public class PrepareSelection implements Listener, IPacketHandler
AtomicInteger i = new AtomicInteger();
GameTeam team = _host.GetTeam(player);
Map<String, Location> spawns = _host.getLocationStartsWith("KIT " + team.GetName().toUpperCase());
Location goBack = spawns.remove("KIT " + team.GetName().toUpperCase() + " GO_BACK");
Location average = UtilAlg.getAverageLocation(team.GetSpawns());
MobaPlayer mobaPlayer = _host.getMobaData(player);
List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole());
Location goBack = spawns.remove("KIT " + team.GetName().toUpperCase() + " GO_BACK");
ClientArmorStand goBackStand = ClientArmorStand.spawn(goBack.clone().add(0, 1, 0), player);
goBackStand.setCustomNameVisible(true);
goBackStand.setCustomName(C.cGreenB + "Go Back");
goBackStand.setArms(true);
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM));
goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build());
goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build());
goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build());
_goBackStands.put(player, goBackStand);
UtilServer.runSyncLater(() ->
{
ClientArmorStand goBackStand = ClientArmorStand.spawn(goBack.clone().add(0, 1, 0), player);
goBackStand.setCustomNameVisible(true);
goBackStand.setCustomName(C.cGreenB + "Go Back");
goBackStand.setArms(true);
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM));
goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build());
goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build());
goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build());
_goBackStands.put(player, goBackStand);
for (Location location : spawns.values())
{
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average)));

View File

@ -290,7 +290,7 @@ public class TowerManager implements Listener
{
Location crystalLocation = tower.getCrystal().getLocation();
if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(crystalLocation, location) > PROJECTILE_RANGE_SQUARED || shouldCancelDamage(tower, shooter))
if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(crystalLocation, location) > PROJECTILE_RANGE_SQUARED || !canDamage(tower, team) || shouldCancelDamage(tower, shooter))
{
continue;
}
@ -349,7 +349,6 @@ public class TowerManager implements Listener
{
// Is other team
// Is first tower
// Is same lane
// Is dead
if (!team.equals(other.getOwner()) && other.isFirstTower() && other.isDead())
{

View File

@ -26,15 +26,20 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniClientPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountGadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.game.GameDisplay;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -42,16 +47,26 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilVariant;
import mineplex.gemhunters.loot.LootItem;
import mineplex.gemhunters.loot.LootModule;
import mineplex.gemhunters.mount.command.MountSkinsCommand;
import mineplex.gemhunters.mount.command.SpawnMountCommand;
@ReflectivelyCreateMiniPlugin
public class MountModule extends MiniClientPlugin<MountData>
{
public enum Perm implements Permission
{
MOUNT_SKINS_COMMAND,
SPAWN_MOUNT_COMMAND
}
private static final ItemStack SADDLE = new ItemStack(Material.SADDLE);
private static final int HEALTH = 40;
private static final int MAX_DIST = 25 * 25;
private static final int MIN_DIST = 4 * 4;
private final CosmeticManager _cosmetic;
private final DisguiseManager _disguise;
private final LootModule _loot;
private final GadgetManager _gadget;
@ -60,9 +75,25 @@ public class MountModule extends MiniClientPlugin<MountData>
{
super("Mount");
_cosmetic = require(CosmeticManager.class);
_disguise = require(DisguiseManager.class);
_loot = require(LootModule.class);
_gadget = require(GadgetManager.class);
generatePermissions();
}
private void generatePermissions()
{
PermissionGroup.PLAYER.setPermission(Perm.MOUNT_SKINS_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.SPAWN_MOUNT_COMMAND, true, true);
}
@Override
public void addCommands()
{
addCommand(new MountSkinsCommand(this));
addCommand(new SpawnMountCommand(this));
}
@Override
@ -123,6 +154,11 @@ public class MountModule extends MiniClientPlugin<MountData>
return;
}
spawnHorse(player, data, lootItem.getItemStack(), cooldown);
}
public void spawnHorse(Player player, MountData data, ItemStack itemStack, long cooldown)
{
Location location = player.getLocation().add(0, 1, 0);
GemHuntersMountGadget gadget = (GemHuntersMountGadget) _gadget.getGameCosmeticManager().getActiveCosmetic(
player,
@ -148,7 +184,7 @@ public class MountModule extends MiniClientPlugin<MountData>
horse.setCustomNameVisible(true);
horse.setJumpStrength(1);
horse.getInventory().setSaddle(SADDLE);
horse.getInventory().setArmor(new ItemStack(lootItem.getItemStack().getType()));
horse.getInventory().setArmor(new ItemStack(itemStack.getType()));
horse.setDomestication(1);
horse.setMaxDomestication(1);
horse.setOwner(player);
@ -165,7 +201,7 @@ public class MountModule extends MiniClientPlugin<MountData>
((DisguiseInsentient) disguise).setName(name);
}
data.onSpawn(horse, cooldown, lootItem.getItemStack());
data.onSpawn(horse, cooldown, itemStack);
player.sendMessage(F.main(_moduleName, "You spawned your " + F.name(getName()) + "."));
}
@ -345,4 +381,23 @@ public class MountModule extends MiniClientPlugin<MountData>
gadget.getType().onUpdate(event, data.getEntity());
}
}
@EventHandler
public void gadgetEquip(GadgetEnableEvent event)
{
if (event.getGadget().getGadgetType() != GadgetType.GAME_MODIFIER)
{
event.setCancelled(true);
}
}
public CosmeticManager getCosmeticManager()
{
return _cosmetic;
}
public GadgetManager getGadgetManager()
{
return _gadget;
}
}

View File

@ -0,0 +1,25 @@
package mineplex.gemhunters.mount.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
import mineplex.core.game.GameDisplay;
import mineplex.gemhunters.mount.MountModule;
import mineplex.gemhunters.mount.MountModule.Perm;
public class MountSkinsCommand extends CommandBase<MountModule>
{
public MountSkinsCommand(MountModule plugin)
{
super(plugin, Perm.MOUNT_SKINS_COMMAND, "mount", "mounts", "skins", "mountskins");
}
@Override
public void Execute(Player caller, String[] args)
{
GameCosmeticCategory category = Plugin.getGadgetManager().getGameCosmeticManager().getCategoryFrom(GameDisplay.GemHunters, "Mount Skins");
Plugin.getCosmeticManager().getShop().openPageForPlayer(caller, category.getGadgetPage(Plugin.getCosmeticManager(), caller));
}
}

View File

@ -0,0 +1,32 @@
package mineplex.gemhunters.mount.command;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import mineplex.core.command.CommandBase;
import mineplex.gemhunters.mount.MountData;
import mineplex.gemhunters.mount.MountModule;
import mineplex.gemhunters.mount.MountModule.Perm;
public class SpawnMountCommand extends CommandBase<MountModule>
{
public SpawnMountCommand(MountModule plugin)
{
super(plugin, Perm.SPAWN_MOUNT_COMMAND, "spawnmount");
}
@Override
public void Execute(Player caller, String[] args)
{
MountData data = Plugin.Get(caller);
if (data.getEntity() != null)
{
data.getEntity().remove();
}
Plugin.spawnHorse(caller, data, new ItemStack(Material.DIAMOND_BARDING), 0);
}
}