Gem Hunter Mount Skins
This commit is contained in:
parent
fd090a5644
commit
e412c2cc05
@ -20,8 +20,8 @@ import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticCategoryPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadgetData;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadgetData;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
|
||||
public class HeroSkinCategoryPage extends GadgetPage
|
||||
|
@ -11,7 +11,7 @@ import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadgetData;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadgetData;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
|
||||
public class HeroSkinGadgetPage extends GadgetPage
|
||||
|
@ -101,9 +101,11 @@ import mineplex.core.gadget.gadgets.flag.FlagType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.emblems.EmblemGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.emblems.EmblemType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphGadget;
|
||||
@ -776,6 +778,26 @@ public class GadgetManager extends MiniPlugin
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
new GameCosmeticType(this, GameDisplay.GemHunters)
|
||||
{
|
||||
@Override
|
||||
public void addCategories()
|
||||
{
|
||||
new GameCosmeticCategory(this, "Mount Skins", new ItemStack(Material.SADDLE), false)
|
||||
{
|
||||
@Override
|
||||
public void addGadgets()
|
||||
{
|
||||
for (GemHuntersMountType type : GemHuntersMountType.values())
|
||||
{
|
||||
addGameGadget(new GemHuntersMountGadget(getManager(), this, type));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
for (GadgetType gadgetType : GadgetType.values())
|
||||
{
|
||||
if (!_gadgets.containsKey(gadgetType))
|
||||
|
@ -0,0 +1,28 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.gemhunters;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||
import mineplex.core.gadget.types.GameModifierGadget;
|
||||
|
||||
public class GemHuntersMountGadget extends GameModifierGadget
|
||||
{
|
||||
|
||||
private final GemHuntersMountType _type;
|
||||
|
||||
public GemHuntersMountGadget(GadgetManager manager, GameCosmeticCategory category, GemHuntersMountType type)
|
||||
{
|
||||
super(manager, category, type.getName() + " Mount", new String[] {
|
||||
C.cGray + "Changed your active Mount",
|
||||
C.cGray + "in " + F.greenElem("Gem Hunters") + "to " + type.getName() + ".",
|
||||
}, -7, type.getMaterial(), type.getMaterialData());
|
||||
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public GemHuntersMountType getType()
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.gemhunters;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
|
||||
public enum GemHuntersMountType
|
||||
{
|
||||
|
||||
DONKEY("Donkey", Material.CHEST)
|
||||
{
|
||||
@Override
|
||||
public Horse spawn(Location location, DisguiseManager manager)
|
||||
{
|
||||
return UtilVariant.spawnHorse(location, Variant.DONKEY);
|
||||
}
|
||||
};
|
||||
|
||||
private final String _name;
|
||||
private final Material _material;
|
||||
private final byte _materialData;
|
||||
|
||||
GemHuntersMountType(String name, Material material)
|
||||
{
|
||||
this(name, material, 0);
|
||||
}
|
||||
|
||||
GemHuntersMountType(String name, Material material, int materialData)
|
||||
{
|
||||
_name = name;
|
||||
_material = material;
|
||||
_materialData = (byte) materialData;
|
||||
}
|
||||
|
||||
public abstract Horse spawn(Location location, DisguiseManager manager);
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
public byte getMaterialData()
|
||||
{
|
||||
return _materialData;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.moba;
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.moba.skins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -15,7 +15,6 @@ import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.gadget.types.GameModifierGadget;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.google.GoogleSheetsManager;
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.moba;
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.moba.skins;
|
||||
|
||||
import mineplex.core.common.skin.SkinData;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
|
||||
public class HeroSkinGadgetData
|
@ -27,7 +27,7 @@ public class GameModifierGadget extends Gadget
|
||||
|
||||
if (message)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.elem(getName()) + "."));
|
||||
UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.name(getName()) + " (" + F.name(_category.getCategoryName()) + ")."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring;
|
||||
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm;
|
||||
import mineplex.core.gadget.gadgets.flag.FlagType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.shopmorph.ShopMorphType;
|
||||
import mineplex.core.gadget.gadgets.hat.HatType;
|
||||
import mineplex.core.gadget.gadgets.item.ItemBatGun;
|
||||
|
@ -18,7 +18,7 @@ import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.HeroSkinGadget;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.moba.skins.HeroSkinGadget;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
@ -80,6 +80,7 @@ import mineplex.gemhunters.loot.InventoryModule;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
import mineplex.gemhunters.map.ItemMapModule;
|
||||
import mineplex.gemhunters.moderation.ModerationModule;
|
||||
import mineplex.gemhunters.mount.MountModule;
|
||||
import mineplex.gemhunters.persistence.PersistenceModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.quest.QuestModule;
|
||||
@ -247,8 +248,7 @@ public class GemHunters extends JavaPlugin
|
||||
// Menus
|
||||
new MenuManager(this);
|
||||
|
||||
// Gadgets, used for mounts, lots of managers for something really small
|
||||
// :(
|
||||
// Gadgets
|
||||
CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, false);
|
||||
MountManager mountManager = new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager);
|
||||
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore);
|
||||
@ -261,8 +261,7 @@ public class GemHunters extends JavaPlugin
|
||||
cosmeticManager.setActive(false);
|
||||
cosmeticManager.setHideParticles(true);
|
||||
cosmeticManager.disableTeamArmor();
|
||||
gadgetManager.setGadgetEnabled(false);
|
||||
|
||||
|
||||
// Tutorials
|
||||
TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager));
|
||||
tutorialManager.addTutorial(new GemHuntersTutorial());
|
||||
@ -282,6 +281,7 @@ public class GemHunters extends JavaPlugin
|
||||
require(ItemMapModule.class);
|
||||
require(JoinModule.class);
|
||||
require(ModerationModule.class);
|
||||
require(MountModule.class);
|
||||
require(PersistenceModule.class);
|
||||
require(PlayerStatusModule.class);
|
||||
require(QuestModule.class);
|
||||
|
@ -1,20 +1,11 @@
|
||||
package mineplex.gemhunters.death;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusType;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -33,11 +24,22 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.gemhunters.death.event.PlayerCustomRespawnEvent;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusType;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
|
||||
/**
|
||||
* This module handles anything to do with a players death
|
||||
@ -46,9 +48,8 @@ import java.util.UUID;
|
||||
public class DeathModule extends MiniPlugin
|
||||
{
|
||||
|
||||
// Some items like the cash out item (and for some reason players drop
|
||||
// bones?) don't need to be dropped to avoid duplication.
|
||||
private static final Set<Material> DISALLOWED_DROPS = Sets.newHashSet(Material.EMERALD, Material.MAP, Material.BONE, Material.STAINED_GLASS_PANE);
|
||||
// Don't need to be dropped to avoid duplication.
|
||||
private static final Set<Material> DISALLOWED_DROPS = Sets.newHashSet(Material.EMERALD, Material.MAP, Material.STAINED_GLASS_PANE);
|
||||
private static final int DEATH_ANIMATION_TIME = 7000;
|
||||
private static final int DEATH_ANIMATION_COUNTDOWN = 2000;
|
||||
|
||||
@ -240,7 +241,7 @@ public class DeathModule extends MiniPlugin
|
||||
_toRemove.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
private boolean isRespawning(Entity player)
|
||||
public boolean isRespawning(Entity player)
|
||||
{
|
||||
return _toRemove.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
package mineplex.gemhunters.mount;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import mineplex.core.disguise.disguises.DisguiseLiving;
|
||||
|
||||
public class GHMount
|
||||
{
|
||||
|
||||
private final LivingEntity _entity;
|
||||
private final DisguiseLiving _disguise;
|
||||
|
||||
public GHMount(LivingEntity entity, DisguiseLiving disguise)
|
||||
{
|
||||
_entity = entity;
|
||||
_disguise = disguise;
|
||||
}
|
||||
|
||||
public LivingEntity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
}
|
@ -1,11 +1,51 @@
|
||||
package mineplex.gemhunters.mount;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class MountData
|
||||
{
|
||||
|
||||
private LivingEntity _entity;
|
||||
private final Player _player;
|
||||
private Horse _entity;
|
||||
private long _cooldown;
|
||||
private ItemStack _item;
|
||||
|
||||
MountData(Player player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void onSpawn(Horse entity, long cooldown, ItemStack item)
|
||||
{
|
||||
_entity = entity;
|
||||
_cooldown = cooldown;
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public void onRemove()
|
||||
{
|
||||
_entity = null;
|
||||
}
|
||||
|
||||
public Horse getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
|
||||
public long getCooldown()
|
||||
{
|
||||
return _cooldown;
|
||||
}
|
||||
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return _item;
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,44 @@
|
||||
package mineplex.gemhunters.mount;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GemHuntersMountGadget;
|
||||
import mineplex.core.game.GameDisplay;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.utils.UtilVariant;
|
||||
import mineplex.gemhunters.loot.LootItem;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
|
||||
@ -18,6 +46,12 @@ import mineplex.gemhunters.loot.LootModule;
|
||||
public class MountModule extends MiniClientPlugin<MountData>
|
||||
{
|
||||
|
||||
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 DisguiseManager _disguise;
|
||||
private final LootModule _loot;
|
||||
private final GadgetManager _gadget;
|
||||
|
||||
@ -25,24 +59,42 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
{
|
||||
super("Mount");
|
||||
|
||||
_disguise = require(DisguiseManager.class);
|
||||
_loot = require(LootModule.class);
|
||||
_gadget = require(GadgetManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new CommandBase<MountModule>(this, Rank.DEVELOPER, "showmethemounts")
|
||||
{
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Managers.require(GameCosmeticManager.class).getGadgetFrom("Donkey Mount").enable(caller);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MountData addPlayer(UUID uuid)
|
||||
{
|
||||
return new MountData();
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Set(player, new MountData(player));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
LootItem lootItem = _loot.fromItemStack(player.getItemInHand());
|
||||
|
||||
@ -52,12 +104,6 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
}
|
||||
|
||||
String metadata = lootItem.getMetadata();
|
||||
|
||||
if (!metadata.startsWith("MOUNT"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String[] split = metadata.split(" ");
|
||||
|
||||
if (split.length < 2)
|
||||
@ -65,8 +111,214 @@ public class MountModule extends MiniClientPlugin<MountData>
|
||||
return;
|
||||
}
|
||||
|
||||
int cooldown = Integer.parseInt(split[1]) * 1000;
|
||||
String cooldownString = split[1];
|
||||
long cooldown;
|
||||
|
||||
try
|
||||
{
|
||||
cooldown = TimeUnit.MINUTES.toMillis(Integer.parseInt(cooldownString));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.usable(player, getName(), true) || !Recharge.Instance.use(player, "Mount Interact", 250, false, false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MountData data = Get(player);
|
||||
|
||||
if (data.getEntity() != null)
|
||||
{
|
||||
player.sendMessage(F.main(_moduleName, "You already have an active mount."));
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().add(0, 1, 0);
|
||||
GemHuntersMountGadget gadget = (GemHuntersMountGadget) _gadget.getGameCosmeticManager().getActiveCosmetic(
|
||||
player,
|
||||
GameDisplay.GemHunters,
|
||||
"Mount Skins"
|
||||
);
|
||||
|
||||
Horse horse;
|
||||
|
||||
if (gadget == null)
|
||||
{
|
||||
horse = UtilVariant.spawnHorse(location, Variant.HORSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
horse = gadget.getType().spawn(location, _disguise);
|
||||
}
|
||||
|
||||
String name = player.getName();
|
||||
horse.setCustomName(name + "'" + (name.charAt(name.length() - 1) == 's' ? "" : "s") + " Mount");
|
||||
horse.setCustomNameVisible(true);
|
||||
horse.setJumpStrength(1);
|
||||
horse.getInventory().setSaddle(SADDLE);
|
||||
horse.getInventory().setArmor(new ItemStack(lootItem.getItemStack().getType()));
|
||||
horse.setDomestication(1);
|
||||
horse.setMaxDomestication(1);
|
||||
horse.setOwner(player);
|
||||
horse.setTamed(true);
|
||||
horse.setMaxHealth(HEALTH);
|
||||
horse.setHealth(HEALTH);
|
||||
UtilEnt.vegetate(player);
|
||||
|
||||
data.onSpawn(horse, cooldown, lootItem.getItemStack());
|
||||
player.sendMessage(F.main(_moduleName, "You spawned your " + F.name(getName()) + "."));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void horseDeath(EntityDeathEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Horse))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Horse horse = (Horse) event.getEntity();
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
if (data.getEntity() == null || !horse.equals(data.getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
event.getDrops().clear();
|
||||
event.setDroppedExp(0);
|
||||
Recharge.Instance.use(data.getPlayer(), getName(), data.getCooldown(), true, true);
|
||||
Recharge.Instance.Get(data.getPlayer()).get(getName()).Item = data.getItem();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Player player = event.getEntity();
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
if (!player.equals(data.getPlayer()) || data.getEntity() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
data.getEntity().remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
if (!player.equals(data.getPlayer()) || data.getEntity() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
data.getEntity().remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FASTER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
Player player = data.getPlayer();
|
||||
Horse horse = data.getEntity();
|
||||
|
||||
if (horse == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (horse.isDead() || !horse.isValid())
|
||||
{
|
||||
data.onRemove();
|
||||
}
|
||||
|
||||
double offset = UtilMath.offsetSquared(player, horse);
|
||||
|
||||
if (offset > MAX_DIST)
|
||||
{
|
||||
horse.teleport(player);
|
||||
}
|
||||
else if (offset > MIN_DIST)
|
||||
{
|
||||
UtilEnt.CreatureMove(horse, player.getLocation(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void horseInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (!(event.getRightClicked() instanceof Horse))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Horse horse = (Horse) event.getRightClicked();
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
if (player.equals(data.getPlayer()) || !horse.equals(data.getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "This is not your mount."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void horseDamage(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Entity damager = event.getDamager();
|
||||
Entity damaged = event.getEntity();
|
||||
|
||||
if (!(damager instanceof Player && damaged instanceof Horse))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (MountData data : GetValues())
|
||||
{
|
||||
if (!damager.equals(data.getPlayer()) || !damaged.equals(data.getEntity()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void horseInventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (event.getClickedInventory() != null && event.getClickedInventory() instanceof HorseInventory)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.gemhunters.death.DeathModule;
|
||||
import mineplex.serverdata.Region;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -37,6 +38,7 @@ public class PersistenceModule extends MiniPlugin
|
||||
|
||||
private final CoreClientManager _client;
|
||||
private final CashOutModule _cashOut;
|
||||
private final DeathModule _death;
|
||||
private final EconomyModule _economy;
|
||||
private final QuestModule _quest;
|
||||
private final InventoryModule _inventory;
|
||||
@ -51,6 +53,7 @@ public class PersistenceModule extends MiniPlugin
|
||||
|
||||
_client = require(CoreClientManager.class);
|
||||
_cashOut = require(CashOutModule.class);
|
||||
_death = require(DeathModule.class);
|
||||
_quest = require(QuestModule.class);
|
||||
_economy = require(EconomyModule.class);
|
||||
_inventory = require(InventoryModule.class);
|
||||
@ -75,7 +78,11 @@ public class PersistenceModule extends MiniPlugin
|
||||
Player player = event.getPlayer();
|
||||
CoreClient client = _client.Get(player);
|
||||
|
||||
if (_cashOut.isAboutToCashOut(player))
|
||||
if (_death.isRespawning(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (_cashOut.isAboutToCashOut(player))
|
||||
{
|
||||
runAsync(() ->
|
||||
{
|
||||
@ -119,7 +126,7 @@ public class PersistenceModule extends MiniPlugin
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void playerDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Player player = event.getEntity();
|
||||
|
Loading…
Reference in New Issue
Block a user