Mounts base
This commit is contained in:
parent
4fc991dd24
commit
1b2c384afe
@ -86,6 +86,8 @@ import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan;
|
||||
import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood;
|
||||
import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitGameModifier;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
||||
@ -558,6 +560,12 @@ public class GadgetManager extends MiniPlugin
|
||||
addGadget(new EternalTaunt(this));
|
||||
addGadget(new BlowAKissTaunt(this));
|
||||
|
||||
// Gem Hunters Mounts
|
||||
for (MountType mount : MountType.values())
|
||||
{
|
||||
addGadget(new GameModifierMount(this, mount));
|
||||
}
|
||||
|
||||
for (GadgetType gadgetType : GadgetType.values())
|
||||
{
|
||||
if (!_gadgets.containsKey(gadgetType))
|
||||
|
@ -19,7 +19,11 @@ public enum GameModifierType
|
||||
|
||||
MineStrike("MineStrike", new String[]{"Apply custom gun models and skin to use ingame"}, Material.TNT, 0),
|
||||
SurvivalGames("Survival Games", new String[]{"Placeholder"}, Material.DIAMOND_SWORD, 0, true),
|
||||
Bridges("Bridges", new String[]{"Placeholder"}, Material.IRON_PICKAXE, 0, true);
|
||||
Bridges("Bridges", new String[]{"Placeholder"}, Material.IRON_PICKAXE, 0, true),
|
||||
|
||||
GemHunters("Gem Hunters", new String[] { "" }, Material.EMERALD, 0)
|
||||
|
||||
;
|
||||
|
||||
private String _name;
|
||||
private List<String> _desc;
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.gemhunters;
|
||||
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
||||
import mineplex.core.gadget.types.GameModifierGadget;
|
||||
|
||||
public class GameModifierMount extends GameModifierGadget
|
||||
{
|
||||
|
||||
private final MountType _mountType;
|
||||
|
||||
public GameModifierMount(GadgetManager manager, MountType mountType)
|
||||
{
|
||||
super(manager, GameModifierType.GemHunters, mountType.getName() + " Mount", mountType.getDescription(), -2, mountType.getMaterial(), mountType.getData(), false);
|
||||
|
||||
_mountType = mountType;
|
||||
}
|
||||
|
||||
public final MountType getMountType()
|
||||
{
|
||||
return _mountType;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package mineplex.core.gadget.gadgets.gamemodifiers.gemhunters;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public enum MountType
|
||||
{
|
||||
|
||||
SKELETON(EntityType.HORSE, Material.BONE, (byte) 0, "Skeleton Horse", "Spooky")
|
||||
|
||||
;
|
||||
|
||||
private final EntityType _entityType;
|
||||
private final Material _material;
|
||||
private final byte _data;
|
||||
private final String _name;
|
||||
private final String[] _description;
|
||||
|
||||
private MountType(EntityType entityType, Material material, byte data, String name, String... description)
|
||||
{
|
||||
_entityType = entityType;
|
||||
_material = material;
|
||||
_data = data;
|
||||
_name = name;
|
||||
_description = description;
|
||||
}
|
||||
|
||||
public final EntityType getEntityType()
|
||||
{
|
||||
return _entityType;
|
||||
}
|
||||
|
||||
public final Material getMaterial()
|
||||
{
|
||||
return _material;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
{
|
||||
return _data;
|
||||
}
|
||||
|
||||
public final String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public final String[] getDescription()
|
||||
{
|
||||
return _description;
|
||||
}
|
||||
|
||||
}
|
@ -27,20 +27,25 @@ import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.give.Give;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.ignore.IgnoreManager;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
import mineplex.core.menu.MenuManager;
|
||||
import mineplex.core.message.MessageManager;
|
||||
import mineplex.core.monitor.LagMeter;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
@ -59,14 +64,15 @@ import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.loot.InventoryModule;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
import mineplex.gemhunters.map.ItemMapModule;
|
||||
import mineplex.gemhunters.mount.MountModule;
|
||||
import mineplex.gemhunters.quest.QuestModule;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
import mineplex.gemhunters.scoreboard.ScoreboardModule;
|
||||
import mineplex.gemhunters.shop.ShopModule;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
import mineplex.gemhunters.supplydrop.SupplyDropModule;
|
||||
import mineplex.gemhunters.world.SewerMobs;
|
||||
import mineplex.gemhunters.world.TimeCycle;
|
||||
import mineplex.gemhunters.world.UndergroundMobs;
|
||||
import mineplex.gemhunters.world.WorldListeners;
|
||||
import mineplex.gemhunters.worldevent.WorldEventModule;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
@ -200,7 +206,7 @@ public class GemHunters extends JavaPlugin
|
||||
explosion.SetTemporaryDebris(false);
|
||||
|
||||
// Inventories
|
||||
// new InventoryManager(this, clientManager);
|
||||
InventoryManager inventoryManager = new InventoryManager(this, clientManager);
|
||||
|
||||
// Reports
|
||||
// SnapshotManager snapshotManager = new SnapshotManager(this, new
|
||||
@ -215,11 +221,14 @@ public class GemHunters extends JavaPlugin
|
||||
new CustomTagFix(this, packetHandler);
|
||||
|
||||
// Holograms
|
||||
new HologramManager(this, packetHandler);
|
||||
HologramManager hologramManager = new HologramManager(this, packetHandler);
|
||||
|
||||
// Menus
|
||||
new MenuManager(this);
|
||||
|
||||
// Gadgets, used for mounts, lots of managers for something really small :(
|
||||
new GadgetManager(this, clientManager, donationManager, inventoryManager, new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager), new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore), preferenceManager, disguiseManager, blockRestore, new ProjectileManager(this), achievementManager, packetHandler, hologramManager, incognito);
|
||||
|
||||
// Now we finally get to enable the Gem Hunters modules
|
||||
// Though if any other module needs one of these it will be generated in
|
||||
// order, however they are all here just for good measure.
|
||||
@ -232,6 +241,7 @@ public class GemHunters extends JavaPlugin
|
||||
require(InventoryModule.class);
|
||||
require(LootModule.class);
|
||||
require(ItemMapModule.class);
|
||||
require(MountModule.class);
|
||||
require(QuestModule.class);
|
||||
require(SafezoneModule.class);
|
||||
require(ScoreboardModule.class);
|
||||
@ -244,7 +254,7 @@ public class GemHunters extends JavaPlugin
|
||||
// interact events etc...
|
||||
new WorldListeners(this);
|
||||
new TimeCycle(this);
|
||||
new SewerMobs(this);
|
||||
new UndergroundMobs(this);
|
||||
|
||||
// UpdateEvent!!!
|
||||
new Updater(this);
|
||||
|
@ -107,16 +107,14 @@ public class CashOutModule extends MiniPlugin
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Inventory inv = event.getClickedInventory();
|
||||
ItemStack itemStack = event.getCurrentItem();
|
||||
|
||||
if (inv == null || itemStack == null)
|
||||
if (itemStack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (inv.equals(player.getInventory()))
|
||||
if (!itemStack.isSimilar(CASH_OUT_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package mineplex.gemhunters.mount;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType;
|
||||
|
||||
public class MountData
|
||||
{
|
||||
|
||||
private MountType _mountType;
|
||||
private LivingEntity _entity;
|
||||
|
||||
public MountData()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void setMountType(MountType mountType)
|
||||
{
|
||||
_mountType = mountType;
|
||||
}
|
||||
|
||||
public MountType getMountType()
|
||||
{
|
||||
return _mountType;
|
||||
}
|
||||
|
||||
public void setEntity(LivingEntity entity)
|
||||
{
|
||||
_entity = entity;
|
||||
}
|
||||
|
||||
public LivingEntity getEntity()
|
||||
{
|
||||
return _entity;
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package mineplex.gemhunters.mount;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount;
|
||||
import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.gemhunters.loot.LootItem;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class MountModule extends MiniClientPlugin<MountData>
|
||||
{
|
||||
|
||||
private static final String ITEM_METADATA = "UNLOCKER";
|
||||
|
||||
private final LootModule _loot;
|
||||
private final GadgetManager _gadget;
|
||||
|
||||
private MountModule()
|
||||
{
|
||||
super("Mount");
|
||||
|
||||
_loot = require(LootModule.class);
|
||||
_gadget = require(GadgetManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MountData addPlayer(UUID uuid)
|
||||
{
|
||||
return new MountData();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
|
||||
if (itemStack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LootItem lootItem = _loot.fromItemStack(itemStack);
|
||||
|
||||
if (lootItem == null || lootItem.getMetadata() == null || !lootItem.getMetadata().startsWith(ITEM_METADATA))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int cooldown = Integer.parseInt(lootItem.getMetadata().split(" ")[1]);
|
||||
|
||||
if (!Recharge.Instance.use(player, _moduleName, cooldown, true, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawnMount(player);
|
||||
}
|
||||
|
||||
public void spawnMount(Player player)
|
||||
{
|
||||
spawnMount(player, ((GameModifierMount) _gadget.getActiveGameModifier(player, GameModifierType.GemHunters, g -> g != null)).getMountType());
|
||||
}
|
||||
|
||||
public void spawnMount(Player player, MountType mountType)
|
||||
{
|
||||
MountData data = Get(player);
|
||||
LivingEntity entity = data.getEntity();
|
||||
EntityType entityType = mountType.getEntityType();
|
||||
|
||||
despawnMount(player);
|
||||
|
||||
entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation().add(0, 1, 0), entityType == null ? EntityType.HORSE : entityType);
|
||||
|
||||
data.setEntity(entity);
|
||||
data.setMountType(mountType);
|
||||
}
|
||||
|
||||
public void despawnMount(Player player)
|
||||
{
|
||||
MountData data = Get(player);
|
||||
LivingEntity entity = data.getEntity();
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive(Player player)
|
||||
{
|
||||
return Get(player).getEntity() != null;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package mineplex.gemhunters.mount.event;
|
||||
|
||||
public class MountSpawnEvent
|
||||
{
|
||||
|
||||
}
|
@ -24,7 +24,6 @@ public class QuestPlayerData
|
||||
public void clear()
|
||||
{
|
||||
_possibleQuests.clear();
|
||||
_activeQuests.clear();
|
||||
_completedQuests.clear();
|
||||
|
||||
_lastClear = System.currentTimeMillis();
|
||||
|
Loading…
Reference in New Issue
Block a user