Remove all GameModifiers and replace them with GameCosmetics
This commit is contained in:
parent
16daa3f7d8
commit
89e820e442
@ -1,5 +1,10 @@
|
|||||||
package mineplex.core.cosmetic.ui.page.gamemodifiers;
|
package mineplex.core.cosmetic.ui.page.gamemodifiers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilUI;
|
import mineplex.core.common.util.UtilUI;
|
||||||
@ -12,10 +17,6 @@ import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType;
|
|||||||
import mineplex.core.gadget.types.GameModifierGadget;
|
import mineplex.core.gadget.types.GameModifierGadget;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GameCosmeticCategoryPage extends GadgetPage
|
public class GameCosmeticCategoryPage extends GadgetPage
|
||||||
{
|
{
|
||||||
@ -67,7 +68,7 @@ public class GameCosmeticCategoryPage extends GadgetPage
|
|||||||
C.cGreen + "Left-Click to view " + category.getCategoryName() + " cosmetics"
|
C.cGreen + "Left-Click to view " + category.getCategoryName() + " cosmetics"
|
||||||
);
|
);
|
||||||
|
|
||||||
addButton(slots[index++], builder.build(), (player, clickType) -> getShop().openPageForPlayer(player, new GameCosmeticGadgetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), category.getCategoryName(), player, this, category)));
|
addButton(slots[index++], builder.build(), (player, clickType) -> getShop().openPageForPlayer(player, category.getGadgetPage(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new GameCosmeticsPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)));
|
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new GameCosmeticsPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)));
|
||||||
|
@ -8,7 +8,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -99,12 +98,6 @@ import mineplex.core.gadget.gadgets.flag.FlagType;
|
|||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType;
|
||||||
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;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
||||||
import mineplex.core.gadget.gadgets.hat.HatItem;
|
import mineplex.core.gadget.gadgets.hat.HatItem;
|
||||||
@ -627,13 +620,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
addGadget(new MusicGadget(this, "Ward Disc", new String[]{""}, -2, 2265, 251000));
|
addGadget(new MusicGadget(this, "Ward Disc", new String[]{""}, -2, 2265, 251000));
|
||||||
addGadget(new MusicGadget(this, "Wait Disc", new String[]{""}, -2, 2267, 238000));
|
addGadget(new MusicGadget(this, "Wait Disc", new String[]{""}, -2, 2267, 238000));
|
||||||
|
|
||||||
// Survival Games
|
|
||||||
/* for (KitModifier kitModifier : KitModifier.values())
|
|
||||||
{
|
|
||||||
addGadget(new KitGameModifier(this, kitModifier));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
// Balloons
|
// Balloons
|
||||||
for (BalloonType balloonType : BalloonType.values())
|
for (BalloonType balloonType : BalloonType.values())
|
||||||
{
|
{
|
||||||
@ -663,12 +649,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
_singleParticleSelectors.put(singleParticleSelectors, gadget);
|
_singleParticleSelectors.put(singleParticleSelectors, gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gem Hunters Mounts
|
|
||||||
for (MountType mount : MountType.values())
|
|
||||||
{
|
|
||||||
addGadget(new GameModifierMount(this, mount));
|
|
||||||
}
|
|
||||||
|
|
||||||
new GameCosmeticType(this, GameDisplay.MineStrike)
|
new GameCosmeticType(this, GameDisplay.MineStrike)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -681,7 +661,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(1))
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(1))
|
||||||
{
|
{
|
||||||
addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2));
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -692,18 +672,18 @@ public class GadgetManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(2))
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(2))
|
||||||
{
|
{
|
||||||
addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2));
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new GameCosmeticCategory(this, "SMG", new ItemBuilder(Material.INK_SACK, (byte) 4).build(), true)
|
new GameCosmeticCategory(this, "SMG", new ItemStack(Material.INK_SACK), true)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void addGadgets()
|
public void addGadgets()
|
||||||
{
|
{
|
||||||
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(3))
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(3))
|
||||||
{
|
{
|
||||||
addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2));
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -714,18 +694,29 @@ public class GadgetManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(4))
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(4))
|
||||||
{
|
{
|
||||||
addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2));
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new GameCosmeticCategory(this, "Knife", new ItemStack(Material.DIAMOND_SWORD), true)
|
new GameCosmeticCategory(this, "Sniper Rifle", new ItemStack(Material.SULPHUR), true)
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void addGadgets()
|
public void addGadgets()
|
||||||
{
|
{
|
||||||
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(5))
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(5))
|
||||||
{
|
{
|
||||||
addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2));
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new GameCosmeticCategory(this, "Knife", new ItemStack(Material.DIAMOND_SWORD), false)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void addGadgets()
|
||||||
|
{
|
||||||
|
for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(6))
|
||||||
|
{
|
||||||
|
addGameGadget(new GameModifierMineStrikeSkin(getManager(), this, mineStrikeSkin, -2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -874,70 +865,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
return balloonGadgets;
|
return balloonGadgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GameModifierGadget> getGameModifiers(GameModifierType gameType)
|
|
||||||
{
|
|
||||||
List<GameModifierGadget> list = new ArrayList<>();
|
|
||||||
for (Gadget g : getGadgets(GadgetType.GAME_MODIFIER))
|
|
||||||
{
|
|
||||||
if (g instanceof GameModifierGadget)
|
|
||||||
{
|
|
||||||
GameModifierGadget mod = (GameModifierGadget) g;
|
|
||||||
if (mod.getGameType() == gameType) list.add(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameModifierMineStrikeSkin getGameModifier(MineStrikeSkin skin)
|
|
||||||
{
|
|
||||||
for(GameModifierGadget g : getGameModifiers(GameModifierType.MineStrike))
|
|
||||||
{
|
|
||||||
GameModifierMineStrikeSkin gskin = (GameModifierMineStrikeSkin) g;
|
|
||||||
if(g.getName().equals(skin.getSkinName())) return gskin;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GameModifierGadget> getGameModifiers(KitModifierType kitType)
|
|
||||||
{
|
|
||||||
List<GameModifierGadget> list = new ArrayList<>();
|
|
||||||
for (GameModifierGadget gadget : getGameModifiers(kitType.getGameModifierType()))
|
|
||||||
{
|
|
||||||
if (gadget instanceof KitGameModifier)
|
|
||||||
{
|
|
||||||
if (((KitGameModifier) gadget).getKitType() == kitType)
|
|
||||||
{
|
|
||||||
list.add(gadget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameModifierGadget getActiveGameModifier(Player player, GameModifierType gameType, Predicate<GameModifierGadget> selector)
|
|
||||||
{
|
|
||||||
for (GameModifierGadget g : getGameModifiers(gameType))
|
|
||||||
{
|
|
||||||
if (!g.isActive(player)) { continue; }
|
|
||||||
if (!selector.test(g)) { continue; }
|
|
||||||
return g;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gets all the Game modifiers that are related to kits
|
|
||||||
public KitGameModifier getActiveGameModifier(Player player, KitModifierType kitType, Predicate<GameModifierGadget> selector)
|
|
||||||
{
|
|
||||||
for (GameModifierGadget g : getGameModifiers(kitType))
|
|
||||||
{
|
|
||||||
if (!g.isActive(player)) { continue; }
|
|
||||||
if (!selector.test(g)) { continue; }
|
|
||||||
if (!(g instanceof KitGameModifier)) { continue; }
|
|
||||||
return (KitGameModifier) g;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HatGadget getHatGadget(HatType type)
|
public HatGadget getHatGadget(HatType type)
|
||||||
{
|
{
|
||||||
for (Gadget gadget : getGadgets(GadgetType.HAT))
|
for (Gadget gadget : getGadgets(GadgetType.HAT))
|
||||||
@ -1440,7 +1367,9 @@ public class GadgetManager extends MiniPlugin
|
|||||||
break;
|
break;
|
||||||
case GAME_MODIFIER:
|
case GAME_MODIFIER:
|
||||||
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
||||||
if (gameModifierGadget.canAllowMultiple())
|
GameCosmeticCategory category = gameModifierGadget.getCategory();
|
||||||
|
|
||||||
|
if (category.isAllowingMultiple())
|
||||||
{
|
{
|
||||||
key = gameModifierGadget.getName();
|
key = gameModifierGadget.getName();
|
||||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||||
@ -1450,7 +1379,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
key = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
|
key = "active" + category.getType().getName().replace(" ", "");
|
||||||
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
if (event.getGadgetState() == GadgetChangeEvent.GadgetState.ENABLED)
|
||||||
{
|
{
|
||||||
value = gameModifierGadget.getName();
|
value = gameModifierGadget.getName();
|
||||||
@ -1468,31 +1397,6 @@ public class GadgetManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isKitModifierActive(KitModifier kitModifier, Player player)
|
|
||||||
{
|
|
||||||
for (Gadget gadget : getGadgets(GadgetType.GAME_MODIFIER))
|
|
||||||
{
|
|
||||||
if (gadget instanceof KitGameModifier)
|
|
||||||
{
|
|
||||||
KitGameModifier kitGameModifier = (KitGameModifier) gadget;
|
|
||||||
if (kitGameModifier.getKitModifier().equals(kitModifier))
|
|
||||||
return kitGameModifier.isActive(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KitModifier getActiveKitModifier(KitModifierType kitModifierType, Player player)
|
|
||||||
{
|
|
||||||
for (KitModifier kitModifier : KitModifier.values())
|
|
||||||
{
|
|
||||||
if (kitModifier.getKitModifierType().equals(kitModifierType))
|
|
||||||
if (isKitModifierActive(kitModifier, player))
|
|
||||||
return kitModifier;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVanish(IncognitoStatusChangeEvent event)
|
public void onVanish(IncognitoStatusChangeEvent event)
|
||||||
{
|
{
|
||||||
@ -1563,6 +1467,7 @@ public class GadgetManager extends MiniPlugin
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles taunt commands
|
* Handles taunt commands
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
package mineplex.core.gadget.gadgets.gamemodifiers;
|
package mineplex.core.gadget.gadgets.gamemodifiers;
|
||||||
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
import mineplex.core.gadget.types.Gadget;
|
|
||||||
import mineplex.core.gadget.types.GameModifierGadget;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.cosmetic.ui.page.GadgetPage;
|
||||||
|
import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticCategoryPage;
|
||||||
|
import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticGadgetPage;
|
||||||
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.types.GameModifierGadget;
|
||||||
|
|
||||||
public abstract class GameCosmeticCategory
|
public abstract class GameCosmeticCategory
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -40,6 +43,16 @@ public abstract class GameCosmeticCategory
|
|||||||
_manager.addGadget(gadget);
|
_manager.addGadget(gadget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GadgetPage getGadgetPage(GameCosmeticCategoryPage parent)
|
||||||
|
{
|
||||||
|
return new GameCosmeticGadgetPage(parent.getPlugin(), parent.getShop(), parent.getClientManager(), parent.getDonationManager(), _categoryName, parent.getClient().GetPlayer(), parent, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameCosmeticType getType()
|
||||||
|
{
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCategoryName()
|
public String getCategoryName()
|
||||||
{
|
{
|
||||||
return _categoryName;
|
return _categoryName;
|
||||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -31,7 +32,12 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
_cosmetics.put(type, cosmetics);
|
_cosmetics.put(type, cosmetics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameModifierGadget getOwnedCosmetic(Player player, GameDisplay gameType, String categoryName)
|
public GameModifierGadget getActiveCosmetic(Player player, GameDisplay gameType, String categoryName)
|
||||||
|
{
|
||||||
|
return getActiveCosmetic(player, gameType, categoryName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameModifierGadget getActiveCosmetic(Player player, GameDisplay gameType, String categoryName, Predicate<GameModifierGadget> selector)
|
||||||
{
|
{
|
||||||
GameCosmeticCategory category = getCategoryFrom(gameType, categoryName);
|
GameCosmeticCategory category = getCategoryFrom(gameType, categoryName);
|
||||||
|
|
||||||
@ -39,10 +45,6 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (category.isAllowingMultiple())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("The category " + categoryName + " allows for multiple gadgets to be enabled at a time. Please use getOwnedCosmetics");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<GameModifierGadget> gadgets = category.getGadgets();
|
List<GameModifierGadget> gadgets = category.getGadgets();
|
||||||
|
|
||||||
@ -53,7 +55,12 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
|
|
||||||
for (GameModifierGadget gadget : gadgets)
|
for (GameModifierGadget gadget : gadgets)
|
||||||
{
|
{
|
||||||
if (gadget.ownsGadget(player))
|
if (selector != null && !selector.test(gadget))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gadget.isActive(player))
|
||||||
{
|
{
|
||||||
return gadget;
|
return gadget;
|
||||||
}
|
}
|
||||||
@ -62,7 +69,12 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GameModifierGadget> getOwnedCosmetics(Player player, GameDisplay gameType, String categoryName)
|
public List<GameModifierGadget> getActiveCosmetics(Player player, GameDisplay gameType, String categoryName)
|
||||||
|
{
|
||||||
|
return getActiveCosmetics(player, gameType, categoryName, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GameModifierGadget> getActiveCosmetics(Player player, GameDisplay gameType, String categoryName, Predicate<GameModifierGadget> selector)
|
||||||
{
|
{
|
||||||
GameCosmeticCategory category = getCategoryFrom(gameType, categoryName);
|
GameCosmeticCategory category = getCategoryFrom(gameType, categoryName);
|
||||||
|
|
||||||
@ -70,10 +82,6 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (!category.isAllowingMultiple())
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("The category " + categoryName + " does not allow multiple gadgets enabled at one time. Please use getOwnedCosmetic");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<GameModifierGadget> gadgets = category.getGadgets();
|
List<GameModifierGadget> gadgets = category.getGadgets();
|
||||||
|
|
||||||
@ -83,13 +91,23 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<GameModifierGadget> gadgetsCloned = new ArrayList<>(gadgets);
|
List<GameModifierGadget> gadgetsCloned = new ArrayList<>(gadgets);
|
||||||
gadgetsCloned.removeIf(gadget -> !gadget.ownsGadget(player));
|
gadgetsCloned.removeIf(gadget -> !gadget.isActive(player));
|
||||||
|
|
||||||
|
if (selector != null)
|
||||||
|
{
|
||||||
|
gadgets.removeIf(gadget -> !selector.test(gadget));
|
||||||
|
}
|
||||||
|
|
||||||
return gadgetsCloned;
|
return gadgetsCloned;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameCosmeticCategory getCategoryFrom(GameDisplay gameType, String categoryName)
|
private GameCosmeticCategory getCategoryFrom(GameDisplay gameType, String categoryName)
|
||||||
{
|
{
|
||||||
|
if (gameType == null || categoryName == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
for (Entry<GameCosmeticType, List<GameCosmeticCategory>> entry : _cosmetics.entrySet())
|
for (Entry<GameCosmeticType, List<GameCosmeticCategory>> entry : _cosmetics.entrySet())
|
||||||
{
|
{
|
||||||
GameCosmeticType type = entry.getKey();
|
GameCosmeticType type = entry.getKey();
|
||||||
@ -113,6 +131,48 @@ public class GameCosmeticManager extends MiniPlugin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameModifierGadget getGadgetFrom(String name)
|
||||||
|
{
|
||||||
|
for (List<GameCosmeticCategory> categories : _cosmetics.values())
|
||||||
|
{
|
||||||
|
for (GameCosmeticCategory category : categories)
|
||||||
|
{
|
||||||
|
for (GameModifierGadget gadget : category.getGadgets())
|
||||||
|
{
|
||||||
|
if (gadget.getName().equals(name))
|
||||||
|
{
|
||||||
|
return gadget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GameModifierGadget> getGadgetsFrom(GameDisplay gameType)
|
||||||
|
{
|
||||||
|
List<GameModifierGadget> gadgets = new ArrayList<>();
|
||||||
|
GameCosmeticType type = null;
|
||||||
|
|
||||||
|
for (GameCosmeticType cosmeticType : _cosmetics.keySet())
|
||||||
|
{
|
||||||
|
if (cosmeticType.getGame() == gameType)
|
||||||
|
{
|
||||||
|
type = cosmeticType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
return gadgets;
|
||||||
|
}
|
||||||
|
|
||||||
|
type.getCategories().forEach(category -> gadgets.addAll(category.getGadgets()));
|
||||||
|
return gadgets;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<GameCosmeticType, List<GameCosmeticCategory>> getTypes()
|
public Map<GameCosmeticType, List<GameCosmeticCategory>> getTypes()
|
||||||
{
|
{
|
||||||
return _cosmetics;
|
return _cosmetics;
|
||||||
|
@ -47,4 +47,9 @@ public abstract class GameCosmeticType
|
|||||||
{
|
{
|
||||||
return _game;
|
return _game;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GameCosmeticCategory> getCategories()
|
||||||
|
{
|
||||||
|
return _categories;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package mineplex.core.gadget.gadgets.gamemodifiers.kits;
|
|
||||||
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
import mineplex.core.gadget.types.GameModifierGadget;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class creates a Kit modifier, to be implemented in game kits, such as Survival Games or Bridges
|
|
||||||
*
|
|
||||||
* @author LCastr0
|
|
||||||
*/
|
|
||||||
public class KitGameModifier extends GameModifierGadget
|
|
||||||
{
|
|
||||||
|
|
||||||
private KitModifier _kitModifier;
|
|
||||||
private KitModifierType _kitType;
|
|
||||||
|
|
||||||
public KitGameModifier(GadgetManager manager, KitModifier kitModifier)
|
|
||||||
{
|
|
||||||
super(manager, kitModifier.getKitModifierType().getGameModifierType(), kitModifier.getName(), kitModifier.getLore(), kitModifier.getCost(),
|
|
||||||
kitModifier.getMaterial(), kitModifier.getData(), false);
|
|
||||||
_kitModifier = kitModifier;
|
|
||||||
_kitType = kitModifier.getKitModifierType();
|
|
||||||
}
|
|
||||||
|
|
||||||
public KitModifierType getKitType()
|
|
||||||
{
|
|
||||||
return _kitType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KitModifier getKitModifier()
|
|
||||||
{
|
|
||||||
return _kitModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void enableCustom(Player player, boolean message)
|
|
||||||
{
|
|
||||||
Manager.getGameModifiers(getGameType()).stream().filter(getKitFilter(_kitType)).forEach(g -> g.disable(player));
|
|
||||||
|
|
||||||
super.enableCustom(player, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filters kit based on type
|
|
||||||
* @param kitModifierType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static Predicate<GameModifierGadget> getKitFilter(KitModifierType kitModifierType)
|
|
||||||
{
|
|
||||||
return new Predicate<GameModifierGadget>() {
|
|
||||||
@Override
|
|
||||||
public boolean test(GameModifierGadget g) {
|
|
||||||
if (!(g instanceof KitGameModifier)) { return false; }
|
|
||||||
return ((KitGameModifier)g).getKitType().equals(kitModifierType);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
package mineplex.core.gadget.gadgets.gamemodifiers.kits;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
public enum KitModifier
|
|
||||||
{
|
|
||||||
|
|
||||||
// Bridges
|
|
||||||
Bridges_Apple_Potato(KitModifierType.Bridges_AppleKit, "Potato", new String[] {"Placeholder"}, Material.POTATO_ITEM, 0),
|
|
||||||
|
|
||||||
// Survival Games
|
|
||||||
Survival_Games_Beastmaster_Chicken(KitModifierType.SurvivalGames_BeastmasterKit, "Chicken", new String[] {"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.CHICKEN), 0),
|
|
||||||
Survival_Games_Beastmaster_Mini_Guardian(KitModifierType.SurvivalGames_BeastmasterKit, "Mini Guardian", new String[] {"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.GUARDIAN), 0),
|
|
||||||
Survival_Games_Beastmaster_Pig(KitModifierType.SurvivalGames_BeastmasterKit, "Pig", new String[] {"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.PIG), 0),
|
|
||||||
Survival_Games_Beastmaster_Squid(KitModifierType.SurvivalGames_BeastmasterKit, "Squid", new String[] {"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.SQUID), 0),
|
|
||||||
Survival_Games_Horseman_Mule(KitModifierType.SurvivalGames_HorsemanKit, "Mule", new String[] {"Placeholder"}, Material.CHEST, 0),
|
|
||||||
Survival_Games_Horseman_Skeleton_Horse(KitModifierType.SurvivalGames_HorsemanKit, "Skeleton Horse", new String[] {"Placeholder"}, Material.BONE, 0),
|
|
||||||
Survival_Games_Horseman_Zombie_Horse(KitModifierType.SurvivalGames_HorsemanKit, "Zombie Horse", new String[] {"Placeholder"}, Material.ROTTEN_FLESH, 0),
|
|
||||||
Survival_Games_Horseman_Donkey(KitModifierType.SurvivalGames_HorsemanKit, "Donkey", new String[] {"Placeholder"}, Material.CHEST, 0),
|
|
||||||
Survival_Games_Necromancer_Wither_Skeleton(KitModifierType.SurvivalGames_NecromancerKit, "Wither Skeleton", new String[] {"Placeholder"}, Material.SKULL_ITEM, (byte) 1, 0),
|
|
||||||
Survival_Games_Necromancer_Zombie(KitModifierType.SurvivalGames_NecromancerKit, "Zombie", new String[] {"Placeholder"}, Material.SKULL_ITEM, (byte) 2, 0);
|
|
||||||
|
|
||||||
private final KitModifierType _kitModifierType;
|
|
||||||
private final String _name;
|
|
||||||
private final String[] _lore;
|
|
||||||
private final Material _material;
|
|
||||||
private final byte _data;
|
|
||||||
private final int _cost;
|
|
||||||
|
|
||||||
KitModifier(KitModifierType kitModifierType, String name, String[] lore, Material material, int cost)
|
|
||||||
{
|
|
||||||
this(kitModifierType, name, lore, material, (byte) 0, cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
KitModifier(KitModifierType kitModifierType, String name, String[] lore, Material material, byte data, int cost)
|
|
||||||
{
|
|
||||||
_kitModifierType = kitModifierType;
|
|
||||||
_name = name;
|
|
||||||
_lore = lore;
|
|
||||||
_material = material;
|
|
||||||
_data = data;
|
|
||||||
_cost = cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KitModifierType getKitModifierType()
|
|
||||||
{
|
|
||||||
return _kitModifierType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getLore()
|
|
||||||
{
|
|
||||||
return _lore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material getMaterial()
|
|
||||||
{
|
|
||||||
return _material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getData()
|
|
||||||
{
|
|
||||||
return _data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCost()
|
|
||||||
{
|
|
||||||
return _cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
package mineplex.core.gadget.gadgets.gamemodifiers.kits;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.LineFormat;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import mineplex.core.common.util.UtilText;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lists types of KitGameModifier's
|
|
||||||
*
|
|
||||||
* @author LCastr0
|
|
||||||
*/
|
|
||||||
public enum KitModifierType
|
|
||||||
{
|
|
||||||
|
|
||||||
Bridges_AppleKit(GameModifierType.Bridges, "Apple", new String[]{"Placeholder"}, Material.APPLE, (byte) 0),
|
|
||||||
SurvivalGames_BeastmasterKit(GameModifierType.SurvivalGames, "Beastmaster", new String[]{"Placeholder"}, Material.BONE, (byte) 0),
|
|
||||||
SurvivalGames_HorsemanKit(GameModifierType.SurvivalGames, "Horseman", new String[]{"Placeholder"}, Material.MONSTER_EGG, UtilEnt.getEntityEggData(EntityType.HORSE)),
|
|
||||||
SurvivalGames_NecromancerKit(GameModifierType.SurvivalGames, "Necromancer", new String[]{"Placeholder"}, Material.SKULL_ITEM, (byte) 0);
|
|
||||||
|
|
||||||
private final GameModifierType _type;
|
|
||||||
private final String _kitName;
|
|
||||||
private final List<String> _desc;
|
|
||||||
private final Material _mat;
|
|
||||||
private final byte _data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param kitName
|
|
||||||
* @param desc
|
|
||||||
* @param mat
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
KitModifierType(GameModifierType type, String kitName, String[] desc, Material mat, byte data)
|
|
||||||
{
|
|
||||||
_type = type;
|
|
||||||
_kitName = kitName;
|
|
||||||
_desc = UtilText.splitLines(desc, LineFormat.LORE);
|
|
||||||
_mat = mat;
|
|
||||||
_data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameModifierType getGameModifierType()
|
|
||||||
{
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKitName() {
|
|
||||||
return _kitName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getDescription()
|
|
||||||
{
|
|
||||||
return _desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack()
|
|
||||||
{
|
|
||||||
return ItemStackFactory.Instance.CreateStack(_mat, _data, 1, C.cGreenB + _kitName, _desc);
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,63 +9,33 @@ import mineplex.core.common.util.C;
|
|||||||
import mineplex.core.common.util.LineFormat;
|
import mineplex.core.common.util.LineFormat;
|
||||||
import mineplex.core.common.util.UtilText;
|
import mineplex.core.common.util.UtilText;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||||
import mineplex.core.gadget.types.GameModifierGadget;
|
import mineplex.core.gadget.types.GameModifierGadget;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
/**
|
|
||||||
* A gamemodifier to apply custom skin data to {@link GameModifierType#MineStrike} weapons
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class GameModifierMineStrikeSkin extends GameModifierGadget
|
public class GameModifierMineStrikeSkin extends GameModifierGadget
|
||||||
{
|
{
|
||||||
|
|
||||||
private String _weapon;
|
private final String _weapon;
|
||||||
private Material _skinMat;
|
private final Material _skinMat;
|
||||||
private byte _skinData;
|
private final byte _skinData;
|
||||||
|
|
||||||
/**
|
public GameModifierMineStrikeSkin(GadgetManager manager, GameCosmeticCategory category, String name, String[] lore, String weaponName, Material newSkin, byte newSkinData, int cost, Material displayMat, int displayData)
|
||||||
* @param manager Normal gadget manager
|
|
||||||
* @param name Display name of skin
|
|
||||||
* @param lore Lore description of skin
|
|
||||||
* @param weaponName The exact name of the weapon which this skin will replace
|
|
||||||
* @param newSkin Skin material
|
|
||||||
* @param newSkinData Skin item data
|
|
||||||
* @param cost Cost of this MineStrike skin
|
|
||||||
* @param displayMat Display material for GUI, no in-game impact
|
|
||||||
* @param displayData Display data for GUI, no in-game impact
|
|
||||||
*/
|
|
||||||
public GameModifierMineStrikeSkin(GadgetManager manager, String name, String[] lore, String weaponName, Material newSkin, byte newSkinData,
|
|
||||||
int cost, Material displayMat, int displayData)
|
|
||||||
{
|
{
|
||||||
super(manager, GameModifierType.MineStrike, name,
|
super(manager, category, name, UtilText.splitLinesToArray(lore, LineFormat.LORE), cost, displayMat, (byte) displayData);
|
||||||
UtilText.splitLinesToArray(lore, LineFormat.LORE), cost, displayMat, (byte) displayData, true);
|
|
||||||
_weapon = weaponName;
|
_weapon = weaponName;
|
||||||
_skinMat = newSkin;
|
_skinMat = newSkin;
|
||||||
_skinData = newSkinData;
|
_skinData = newSkinData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GameModifierMineStrikeSkin(GadgetManager manager, GameCosmeticCategory category, MineStrikeSkin skin, int cost)
|
||||||
* Return a {@link GameModifierMineStrikeSkin} with empty lore
|
|
||||||
* @param manager Normal gadget manager
|
|
||||||
* @param skin {@link MineStrikeSkin} used to apply name, item data and display data from
|
|
||||||
* @param cost Cost of this MineStrike skin
|
|
||||||
*/
|
|
||||||
public GameModifierMineStrikeSkin(GadgetManager manager, MineStrikeSkin skin, int cost)
|
|
||||||
{
|
{
|
||||||
this(manager, skin, new String[]{C.cGray + "Weapon: " + C.cYellow + skin.getWeaponName()}, cost);
|
this(manager, category, skin, new String[]{C.cGray + "Weapon: " + C.cYellow + skin.getWeaponName()}, cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public GameModifierMineStrikeSkin(GadgetManager manager, GameCosmeticCategory category, MineStrikeSkin skin, String[] lore, int cost)
|
||||||
* Return a {@link GameModifierMineStrikeSkin} using the {@link MineStrikeSkin} to apply additional data
|
|
||||||
* @param manager Normal gadget manager
|
|
||||||
* @param skin {@link MineStrikeSkin} used to apply name, item data and display data from
|
|
||||||
* @param lore Lore to apply to the gadget
|
|
||||||
* @param cost Cost of this MineStrike skin
|
|
||||||
*/
|
|
||||||
public GameModifierMineStrikeSkin(GadgetManager manager, MineStrikeSkin skin, String[] lore, int cost)
|
|
||||||
{
|
{
|
||||||
this(manager, skin.getSkinName(), lore, skin.getWeaponName(), skin.getSkinMaterial(), skin.getSkinData(), cost,
|
this(manager, category, skin.getSkinName(), lore, skin.getWeaponName(), skin.getSkinMaterial(), skin.getSkinData(), cost, skin.getSkinMaterial(), skin.getSkinData());
|
||||||
skin.getSkinMaterial(), skin.getSkinData());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWeaponName()
|
public String getWeaponName()
|
||||||
@ -86,13 +56,14 @@ public class GameModifierMineStrikeSkin extends GameModifierGadget
|
|||||||
@Override
|
@Override
|
||||||
public void enableCustom(Player player, boolean message)
|
public void enableCustom(Player player, boolean message)
|
||||||
{
|
{
|
||||||
Manager.getGameModifiers(getGameType()).stream().filter(getWeaponFilter(_weapon).and(weapon -> weapon != this)).forEach(g -> g.disable(player));
|
Manager.getGameCosmeticManager().getGadgetsFrom(GameDisplay.MineStrike).stream().filter(getWeaponFilter(_weapon).and(weapon -> weapon != this)).forEach(g -> g.disable(player));
|
||||||
|
|
||||||
super.enableCustom(player, message);
|
super.enableCustom(player, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple {@link GameModifierGadget} filter which filters out {@link GameModifierMineStrikeSkin} gadgets depending on weapon name
|
* A simple {@link GameModifierGadget} filter which filters out {@link GameModifierMineStrikeSkin} gadgets depending on weapon name
|
||||||
|
*
|
||||||
* @param weaponName Exact weapon name to test for
|
* @param weaponName Exact weapon name to test for
|
||||||
* @return Returns a weapon filter which will filter out any {@link GameModifierGadget}
|
* @return Returns a weapon filter which will filter out any {@link GameModifierGadget}
|
||||||
* which is not instance of {@link GameModifierMineStrikeSkin} and which does not match the provided weapon name
|
* which is not instance of {@link GameModifierMineStrikeSkin} and which does not match the provided weapon name
|
||||||
@ -101,5 +72,4 @@ public class GameModifierMineStrikeSkin extends GameModifierGadget
|
|||||||
{
|
{
|
||||||
return g -> g instanceof GameModifierMineStrikeSkin && ((GameModifierMineStrikeSkin) g).getWeaponName().equals(weaponName);
|
return g -> g instanceof GameModifierMineStrikeSkin && ((GameModifierMineStrikeSkin) g).getWeaponName().equals(weaponName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,24 +19,24 @@ public enum MineStrikeSkin
|
|||||||
XM1014_Pig_Gun( "XM1014", "XM1014 Pig Gun", Material.LEATHER, (byte) 0, 2),
|
XM1014_Pig_Gun( "XM1014", "XM1014 Pig Gun", Material.LEATHER, (byte) 0, 2),
|
||||||
PP_Bizon_Streak( "PP-Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4, 3),
|
PP_Bizon_Streak( "PP-Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4, 3),
|
||||||
P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0, 3),
|
P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0, 3),
|
||||||
SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12, 4),
|
SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12, 5),
|
||||||
AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0, 4),
|
AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0, 5),
|
||||||
P2000_Fire_Elemental( "P2000", "P2000 Fire Elemental", Material.INK_SACK, (byte) 6, 1),
|
P2000_Fire_Elemental( "P2000", "P2000 Fire Elemental", Material.INK_SACK, (byte) 6, 1),
|
||||||
FAMAS_Pulse( "FAMAS", "FAMAS Pulse", Material.CLAY_BALL, (byte) 0, 4),
|
FAMAS_Pulse( "FAMAS", "FAMAS Pulse", Material.CLAY_BALL, (byte) 0, 4),
|
||||||
M4A4_Howl( "M4A4", "M4A4 Howl", Material.INK_SACK, (byte) 11, 4),
|
M4A4_Howl( "M4A4", "M4A4 Howl", Material.INK_SACK, (byte) 11, 4),
|
||||||
M4A4_Enderman( "M4A4", "Enderman M4", Material.COAL, (byte) 0, 4),
|
M4A4_Enderman( "M4A4", "Enderman M4", Material.COAL, (byte) 0, 4),
|
||||||
Steyr_AUG_Torque( "Steyr AUG", "Steyr AUG Torque", Material.BLAZE_ROD, (byte) 0, 4),
|
Steyr_AUG_Torque( "Steyr AUG", "Steyr AUG Torque", Material.BLAZE_ROD, (byte) 0, 5),
|
||||||
Glock_18_Fade( "Glock 18", "Glock 18 Fade", Material.INK_SACK, (byte) 9, 1),
|
Glock_18_Fade( "Glock 18", "Glock 18 Fade", Material.INK_SACK, (byte) 9, 1),
|
||||||
Galil_AR_Eco( "Galil AR", "Galil AR Eco", Material.INK_SACK, (byte) 10, 1),
|
Galil_AR_Eco( "Galil AR", "Galil AR Eco", Material.INK_SACK, (byte) 10, 1),
|
||||||
AK_47_Vulcan( "AK-47", "AK-47 Vulcan", Material.INK_SACK, (byte) 7, 4),
|
AK_47_Vulcan( "AK-47", "AK-47 Vulcan", Material.INK_SACK, (byte) 7, 4),
|
||||||
AK_47_Guardian( "AK-47", "Guardian AK", Material.PRISMARINE_SHARD, (byte) 0, 4),
|
AK_47_Guardian( "AK-47", "Guardian AK", Material.PRISMARINE_SHARD, (byte) 0, 4),
|
||||||
SG553_Pulse( "SG553", "SG553 Pulse", Material.INK_SACK, (byte) 5, 4),
|
SG553_Pulse( "SG553", "SG553 Pulse", Material.INK_SACK, (byte) 5, 5),
|
||||||
|
|
||||||
|
|
||||||
Knife_M9_Bayonette_Fade( "Knife", "M9 Bayonette Fade", Material.DIAMOND_SWORD, (byte) 0, 5),
|
Knife_M9_Bayonette_Fade( "Knife", "M9 Bayonette Fade", Material.DIAMOND_SWORD, (byte) 0, 6),
|
||||||
Knife_Counter_Terrorist_Sword("Knife", "Counter Terrorist Sword", Material.STICK, (byte) 0, 5),
|
Knife_Counter_Terrorist_Sword("Knife", "Counter Terrorist Sword", Material.STICK, (byte) 0, 6),
|
||||||
Knife_Terrorist_Sword( "Knife", "Terrorist Sword", Material.FEATHER, (byte) 0, 5),
|
Knife_Terrorist_Sword( "Knife", "Terrorist Sword", Material.FEATHER, (byte) 0, 6),
|
||||||
Knife_M9_Bayonette_Glass( "Knife", "Glass M9 Bayonette", Material.QUARTZ, (byte) 0, 5);
|
Knife_M9_Bayonette_Glass( "Knife", "Glass M9 Bayonette", Material.QUARTZ, (byte) 0, 6);
|
||||||
|
|
||||||
private static final Map<Integer, List<MineStrikeSkin>> BY_CATEGORY;
|
private static final Map<Integer, List<MineStrikeSkin>> BY_CATEGORY;
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import mineplex.core.common.util.BukkitFuture;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.database.PlayerKeyValueRepository;
|
import mineplex.core.database.PlayerKeyValueRepository;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GameModifierGadget;
|
import mineplex.core.gadget.types.GameModifierGadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
@ -57,7 +58,9 @@ public class UserGadgetPersistence
|
|||||||
break;
|
break;
|
||||||
case GAME_MODIFIER:
|
case GAME_MODIFIER:
|
||||||
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
GameModifierGadget gameModifierGadget = (GameModifierGadget) gadget;
|
||||||
if (gameModifierGadget.canAllowMultiple())
|
GameCosmeticCategory category = gameModifierGadget.getCategory();
|
||||||
|
|
||||||
|
if (category.isAllowingMultiple())
|
||||||
{
|
{
|
||||||
if (!values.containsKey(gadget.getName()))
|
if (!values.containsKey(gadget.getName()))
|
||||||
continue;
|
continue;
|
||||||
@ -69,7 +72,7 @@ public class UserGadgetPersistence
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
String dataKey = "activeModifier" + gameModifierGadget.getGameType().getName().replace(" ", "");
|
String dataKey = "active" + category.getType().getName().replace(" ", "");
|
||||||
if (!values.containsKey(dataKey))
|
if (!values.containsKey(dataKey))
|
||||||
continue;
|
continue;
|
||||||
if (values.get(dataKey).equals(gadget.getName()))
|
if (values.get(dataKey).equals(gadget.getName()))
|
||||||
|
@ -6,41 +6,18 @@ import org.bukkit.entity.Player;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory;
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstract wrapper for Gadgets of the type GameModifiers
|
|
||||||
*/
|
|
||||||
public class GameModifierGadget extends Gadget
|
public class GameModifierGadget extends Gadget
|
||||||
{
|
{
|
||||||
|
|
||||||
protected final GameModifierType _type;
|
private final GameCosmeticCategory _category;
|
||||||
private final boolean _allowMultiple;
|
|
||||||
|
|
||||||
/**
|
public GameModifierGadget(GadgetManager manager, GameCosmeticCategory category, String name, String[] desc, int cost, Material mat, byte data)
|
||||||
* @param manager Normal GadgetManager
|
|
||||||
* @param type The type of the GameModifier, normally a specific game mode
|
|
||||||
* @param name The display name of the GameModifier
|
|
||||||
* @param desc The lore description of the GameModifier
|
|
||||||
* @param cost The shard cost of the GameModifier
|
|
||||||
* @param mat The display material used in GUIs
|
|
||||||
* @param data The display data used in GUIs
|
|
||||||
*/
|
|
||||||
public GameModifierGadget(GadgetManager manager, GameModifierType type, String name, String[] desc, int cost, Material mat, byte data, boolean allowMultiple)
|
|
||||||
{
|
{
|
||||||
super(manager, GadgetType.GAME_MODIFIER, name, desc, cost, mat, data);
|
super(manager, GadgetType.GAME_MODIFIER, name, desc, cost, mat, data);
|
||||||
_type = type;
|
|
||||||
_allowMultiple = allowMultiple;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameModifierType getGameType()
|
_category = category;
|
||||||
{
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canAllowMultiple()
|
|
||||||
{
|
|
||||||
return _allowMultiple;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,4 +30,9 @@ public class GameModifierGadget extends Gadget
|
|||||||
UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.elem(getName()) + "."));
|
UtilPlayer.message(player, F.main("Gadget", "You enabled " + F.elem(getName()) + "."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameCosmeticCategory getCategory()
|
||||||
|
{
|
||||||
|
return _category;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,10 @@ public class GoogleSheetsManager extends MiniPlugin
|
|||||||
for (int j = 0; j < values.size(); j++)
|
for (int j = 0; j < values.size(); j++)
|
||||||
{
|
{
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
Iterator<JsonElement> iterator = values.get(j).getAsJsonArray().iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext())
|
for (JsonElement jsonElement : values.get(j).getAsJsonArray())
|
||||||
{
|
{
|
||||||
String value = iterator.next().getAsString();
|
String value = jsonElement.getAsString();
|
||||||
list.add(value);
|
list.add(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,7 +1014,7 @@ public class RewardManager
|
|||||||
|
|
||||||
public UnknownPackageReward addMineStrikeSkin(Type type, MineStrikeSkin skin, RewardRarity rarity, int weight, int shards)
|
public UnknownPackageReward addMineStrikeSkin(Type type, MineStrikeSkin skin, RewardRarity rarity, int weight, int shards)
|
||||||
{
|
{
|
||||||
Gadget gadget = _gadgetManager.getGameModifier(skin);
|
Gadget gadget = _gadgetManager.getGameCosmeticManager().getGadgetFrom(skin.getSkinName());
|
||||||
return addGadget(type, gadget, gadget.getDisplayName() + " (Minestrike Weapon Skin)", rarity, weight, shards);
|
return addGadget(type, gadget, gadget.getDisplayName() + " (Minestrike Weapon Skin)", rarity, weight, shards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +69,9 @@ import mineplex.core.common.util.UtilTextMiddle;
|
|||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.recharge.RechargedEvent;
|
import mineplex.core.recharge.RechargedEvent;
|
||||||
@ -902,9 +902,8 @@ public class GunModule implements Listener
|
|||||||
{
|
{
|
||||||
Player damager = event.GetDamagerPlayer(false);
|
Player damager = event.GetDamagerPlayer(false);
|
||||||
|
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
GameCosmeticManager cosmeticManager = Manager.getCosmeticManager().getGadgetManager().getGameCosmeticManager();
|
||||||
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(damager,
|
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) cosmeticManager.getActiveCosmetic(damager, GameDisplay.MineStrike, "Knife");
|
||||||
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
|
|
||||||
|
|
||||||
ItemStack inHand = damager.getItemInHand();
|
ItemStack inHand = damager.getItemInHand();
|
||||||
//Cancel Non-Knife Melee
|
//Cancel Non-Knife Melee
|
||||||
|
@ -46,11 +46,11 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTextMiddle;
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
||||||
import mineplex.core.gadget.types.Gadget;
|
import mineplex.core.gadget.types.Gadget;
|
||||||
import mineplex.core.gadget.types.GadgetType;
|
import mineplex.core.gadget.types.GadgetType;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -257,9 +257,9 @@ public class Minestrike extends TeamGame
|
|||||||
GameTeam team = GetTeam(event.getPlayer());
|
GameTeam team = GetTeam(event.getPlayer());
|
||||||
if (team == null)
|
if (team == null)
|
||||||
return;
|
return;
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
|
||||||
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) gadgetManager.getActiveGameModifier(event.getPlayer(),
|
GameCosmeticManager cosmeticManager = Manager.getCosmeticManager().getGadgetManager().getGameCosmeticManager();
|
||||||
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter("Knife"));
|
GameModifierMineStrikeSkin knifeSkin = (GameModifierMineStrikeSkin) cosmeticManager.getActiveCosmetic(event.getPlayer(), GameDisplay.MineStrike, "Knife");
|
||||||
|
|
||||||
Material mat = Material.IRON_AXE;
|
Material mat = Material.IRON_AXE;
|
||||||
byte data = 0;
|
byte data = 0;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package nautilus.game.arcade.game.games.minestrike.items.guns;
|
package nautilus.game.arcade.game.games.minestrike.items.guns;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -31,12 +30,13 @@ import mineplex.core.common.util.UtilServer;
|
|||||||
import mineplex.core.common.util.UtilTextBottom;
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
|
||||||
|
import mineplex.core.game.GameDisplay;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.recharge.RechargedEvent;
|
import mineplex.core.recharge.RechargedEvent;
|
||||||
import mineplex.core.stats.PlayerStats;
|
import mineplex.core.stats.PlayerStats;
|
||||||
|
|
||||||
import nautilus.game.arcade.game.games.minestrike.GunModule;
|
import nautilus.game.arcade.game.games.minestrike.GunModule;
|
||||||
import nautilus.game.arcade.game.games.minestrike.data.Bullet;
|
import nautilus.game.arcade.game.games.minestrike.data.Bullet;
|
||||||
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
|
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
|
||||||
@ -460,8 +460,7 @@ public class Gun extends StrikeItem
|
|||||||
|
|
||||||
public void updateSkin(Player owner, GadgetManager gadgetmanager)
|
public void updateSkin(Player owner, GadgetManager gadgetmanager)
|
||||||
{
|
{
|
||||||
GameModifierMineStrikeSkin skin = (GameModifierMineStrikeSkin) gadgetmanager.getActiveGameModifier(owner,
|
GameModifierMineStrikeSkin skin = (GameModifierMineStrikeSkin) gadgetmanager.getGameCosmeticManager().getActiveCosmetic(owner, GameDisplay.MineStrike, _gunStats.getGunType().getName(), GameModifierMineStrikeSkin.getWeaponFilter(getName()));
|
||||||
GameModifierType.MineStrike, GameModifierMineStrikeSkin.getWeaponFilter(getName()));
|
|
||||||
|
|
||||||
if(skin == null) return;
|
if(skin == null) return;
|
||||||
|
|
||||||
|
@ -1,17 +1,5 @@
|
|||||||
package nautilus.game.arcade.kit.perks;
|
package nautilus.game.arcade.kit.perks;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
|
||||||
import mineplex.core.common.util.UtilAction;
|
|
||||||
import mineplex.core.common.util.UtilEnt;
|
|
||||||
import mineplex.core.common.util.UtilInv;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
|
||||||
import mineplex.core.itemstack.ItemStackFactory;
|
|
||||||
import mineplex.core.projectile.IThrown;
|
|
||||||
import mineplex.core.projectile.ProjectileUser;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
|
||||||
import nautilus.game.arcade.kit.Perk;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -25,7 +13,18 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilAction;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import mineplex.core.projectile.IThrown;
|
||||||
|
import mineplex.core.projectile.ProjectileUser;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
public class PerkApple extends Perk implements IThrown
|
public class PerkApple extends Perk implements IThrown
|
||||||
{
|
{
|
||||||
@ -62,10 +61,10 @@ public class PerkApple extends Perk implements IThrown
|
|||||||
if (!Manager.GetGame().IsAlive(player))
|
if (!Manager.GetGame().IsAlive(player))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, getMessage(player), _spawnDelay, false, false))
|
if (!Recharge.Instance.use(player, "Apple Spawn Throw", _spawnDelay, false, false))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(getMaterial(player)));
|
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.APPLE));
|
||||||
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
|
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +78,7 @@ public class PerkApple extends Perk implements IThrown
|
|||||||
if (event.getPlayer().getItemInHand() == null)
|
if (event.getPlayer().getItemInHand() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.getPlayer().getItemInHand().getType() != getMaterial(event.getPlayer()))
|
if (event.getPlayer().getItemInHand().getType() != Material.APPLE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -87,17 +86,17 @@ public class PerkApple extends Perk implements IThrown
|
|||||||
if (!Kit.HasKit(player))
|
if (!Kit.HasKit(player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, getMessage(player) + " Throw", _throwDelay, false, false))
|
if (!Recharge.Instance.use(player, "Apple Spawn Throw", _throwDelay, false, false))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
UtilInv.remove(player, getMaterial(player), (byte)0, 1);
|
UtilInv.remove(player, Material.APPLE, (byte)0, 1);
|
||||||
UtilInv.Update(player);
|
UtilInv.Update(player);
|
||||||
|
|
||||||
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(getMaterial(player)));
|
org.bukkit.entity.Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.APPLE));
|
||||||
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
|
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
|
||||||
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.5f);
|
Manager.GetProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.5f);
|
||||||
}
|
}
|
||||||
@ -126,7 +125,7 @@ public class PerkApple extends Perk implements IThrown
|
|||||||
|
|
||||||
//Re-Drop
|
//Re-Drop
|
||||||
if (data.getThrown() instanceof Item && data.getThrown() instanceof Player)
|
if (data.getThrown() instanceof Item && data.getThrown() instanceof Player)
|
||||||
data.getThrown().getWorld().dropItem(data.getThrown().getLocation(), ItemStackFactory.Instance.CreateStack(getMaterial((Player) data.getThrower()))).setPickupDelay(60);
|
data.getThrown().getWorld().dropItem(data.getThrown().getLocation(), ItemStackFactory.Instance.CreateStack(Material.APPLE)).setPickupDelay(60);
|
||||||
|
|
||||||
data.getThrown().remove();
|
data.getThrown().remove();
|
||||||
}
|
}
|
||||||
@ -159,22 +158,4 @@ public class PerkApple extends Perk implements IThrown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material getMaterial(Player player)
|
|
||||||
{
|
|
||||||
if (Manager.getCosmeticManager().getGadgetManager().isKitModifierActive(KitModifier.Bridges_Apple_Potato, player))
|
|
||||||
{
|
|
||||||
return Material.POTATO_ITEM;
|
|
||||||
}
|
|
||||||
return Material.APPLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMessage(Player player)
|
|
||||||
{
|
|
||||||
if (Manager.getCosmeticManager().getGadgetManager().isKitModifierActive(KitModifier.Bridges_Apple_Potato, player))
|
|
||||||
{
|
|
||||||
return "Potato Spawn";
|
|
||||||
}
|
|
||||||
return "Apple Spawn";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,6 @@ import mineplex.core.common.util.UtilItem;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -69,34 +66,7 @@ public class PerkHorsePet extends Perk
|
|||||||
|
|
||||||
Manager.GetGame().CreatureAllowOverride = true;
|
Manager.GetGame().CreatureAllowOverride = true;
|
||||||
|
|
||||||
KitModifier kitModifier = getHorseType(player);
|
Horse horse = UtilVariant.spawnHorse(player.getLocation(), Variant.HORSE);
|
||||||
final Horse.Variant variant;
|
|
||||||
if (kitModifier != null)
|
|
||||||
{
|
|
||||||
switch (getHorseType(player))
|
|
||||||
{
|
|
||||||
case Survival_Games_Horseman_Mule:
|
|
||||||
variant = Variant.MULE;
|
|
||||||
break;
|
|
||||||
case Survival_Games_Horseman_Skeleton_Horse:
|
|
||||||
variant = Variant.SKELETON_HORSE;
|
|
||||||
break;
|
|
||||||
case Survival_Games_Horseman_Zombie_Horse:
|
|
||||||
variant = Variant.UNDEAD_HORSE;
|
|
||||||
break;
|
|
||||||
case Survival_Games_Horseman_Donkey:
|
|
||||||
variant = Variant.DONKEY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
variant = Variant.HORSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
variant = Variant.HORSE;
|
|
||||||
}
|
|
||||||
Horse horse = UtilVariant.spawnHorse(player.getLocation(), variant);
|
|
||||||
horse.setAdult();
|
horse.setAdult();
|
||||||
horse.setAgeLock(true);
|
horse.setAgeLock(true);
|
||||||
horse.setColor(Color.BROWN);
|
horse.setColor(Color.BROWN);
|
||||||
@ -320,10 +290,4 @@ public class PerkHorsePet extends Perk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private KitModifier getHorseType(Player player)
|
|
||||||
{
|
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
|
||||||
return gadgetManager.getActiveKitModifier(KitModifierType.SurvivalGames_HorsemanKit, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,13 +31,8 @@ import mineplex.core.common.util.UtilAlg;
|
|||||||
import mineplex.core.common.util.UtilEnt;
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.disguise.disguises.DisguiseZombie;
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.core.utils.UtilVariant;
|
|
||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
@ -109,46 +104,10 @@ public class PerkSkeletons extends Perk
|
|||||||
|
|
||||||
Manager.GetGame().CreatureAllowOverride = true;
|
Manager.GetGame().CreatureAllowOverride = true;
|
||||||
|
|
||||||
KitModifier kitModifier = getSkeletonType(killer);
|
Skeleton skel = killed.getWorld().spawn(killed.getLocation(), Skeleton.class);
|
||||||
final Skeleton.SkeletonType type;
|
|
||||||
if (kitModifier != null)
|
|
||||||
{
|
|
||||||
switch (kitModifier)
|
|
||||||
{
|
|
||||||
case Survival_Games_Necromancer_Wither_Skeleton:
|
|
||||||
type = Skeleton.SkeletonType.WITHER;
|
|
||||||
break;
|
|
||||||
case Survival_Games_Necromancer_Zombie:
|
|
||||||
type = Skeleton.SkeletonType.NORMAL;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
type = Skeleton.SkeletonType.NORMAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
type = Skeleton.SkeletonType.NORMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Skeleton skel;
|
|
||||||
if (type == Skeleton.SkeletonType.NORMAL)
|
|
||||||
{
|
|
||||||
skel = killer.getWorld().spawn(killed.getLocation(), Skeleton.class);
|
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
skel = UtilVariant.spawnWitherSkeleton(killed.getLocation());
|
|
||||||
}
|
|
||||||
|
|
||||||
Manager.GetGame().CreatureAllowOverride = false;
|
Manager.GetGame().CreatureAllowOverride = false;
|
||||||
|
|
||||||
if (kitModifier != null && kitModifier == KitModifier.Survival_Games_Necromancer_Zombie)
|
|
||||||
{
|
|
||||||
DisguiseZombie disguiseZombie = new DisguiseZombie(skel);
|
|
||||||
Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseZombie);
|
|
||||||
}
|
|
||||||
|
|
||||||
UtilEnt.removeGoalSelectors(skel);
|
UtilEnt.removeGoalSelectors(skel);
|
||||||
|
|
||||||
skel.setMaxHealth(30);
|
skel.setMaxHealth(30);
|
||||||
@ -376,10 +335,4 @@ public class PerkSkeletons extends Perk
|
|||||||
{
|
{
|
||||||
return _minions.get(player);
|
return _minions.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KitModifier getSkeletonType(Player player)
|
|
||||||
{
|
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
|
||||||
return gadgetManager.getActiveKitModifier(KitModifierType.SurvivalGames_NecromancerKit, player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature;
|
|||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftWolf;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Wolf;
|
import org.bukkit.entity.Wolf;
|
||||||
@ -38,11 +37,6 @@ import mineplex.core.common.util.UtilMath;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.disguise.disguises.DisguiseGuardian;
|
|
||||||
import mineplex.core.disguise.disguises.DisguiseSquid;
|
|
||||||
import mineplex.core.gadget.GadgetManager;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
|
|
||||||
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
|
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
@ -123,7 +117,6 @@ public class PerkWolfPet extends Perk
|
|||||||
_petMap.get(cur).add(wolf);
|
_petMap.get(cur).add(wolf);
|
||||||
Manager.GetGame().CreatureAllowOverride = false;
|
Manager.GetGame().CreatureAllowOverride = false;
|
||||||
cur.playSound(cur.getLocation(), Sound.WOLF_HOWL, 1f, 1f);
|
cur.playSound(cur.getLocation(), Sound.WOLF_HOWL, 1f, 1f);
|
||||||
disguise(wolf, cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,47 +372,4 @@ public class PerkWolfPet extends Perk
|
|||||||
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
|
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
|
||||||
event.AddMod("Wolf Minion", "Damage", damage, false);
|
event.AddMod("Wolf Minion", "Damage", damage, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disguise(Entity wolf, Player player)
|
|
||||||
{
|
|
||||||
EntityType entityType = getDisguiseType(player);
|
|
||||||
if (entityType != null)
|
|
||||||
{
|
|
||||||
if (entityType.equals(EntityType.GUARDIAN))
|
|
||||||
{
|
|
||||||
DisguiseGuardian disguiseGuardian = new DisguiseGuardian(wolf);
|
|
||||||
Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseGuardian);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (entityType.equals(EntityType.SQUID))
|
|
||||||
{
|
|
||||||
DisguiseSquid disguiseSquid = new DisguiseSquid(wolf);
|
|
||||||
Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseSquid);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*DisguiseAnimalBase disguiseAnimal = new DisguiseAnimalBase(entityType, wolf); // TODO: what does this even do?
|
|
||||||
Manager.getCosmeticManager().getGadgetManager().getDisguiseManager().disguise(disguiseAnimal);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityType getDisguiseType(Player player)
|
|
||||||
{
|
|
||||||
GadgetManager gadgetManager = Manager.getCosmeticManager().getGadgetManager();
|
|
||||||
KitModifier kitModifier = gadgetManager.getActiveKitModifier(KitModifierType.SurvivalGames_BeastmasterKit, player);
|
|
||||||
if (kitModifier != null)
|
|
||||||
{
|
|
||||||
switch (kitModifier)
|
|
||||||
{
|
|
||||||
case Survival_Games_Beastmaster_Chicken:
|
|
||||||
return EntityType.CHICKEN;
|
|
||||||
case Survival_Games_Beastmaster_Mini_Guardian:
|
|
||||||
return EntityType.GUARDIAN;
|
|
||||||
case Survival_Games_Beastmaster_Pig:
|
|
||||||
return EntityType.PIG;
|
|
||||||
case Survival_Games_Beastmaster_Squid:
|
|
||||||
return EntityType.SQUID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
package mineplex.gemhunters;
|
package mineplex.gemhunters;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
import mineplex.core.CustomTagFix;
|
import mineplex.core.CustomTagFix;
|
||||||
import mineplex.core.FoodDupeFix;
|
import mineplex.core.FoodDupeFix;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
@ -72,7 +80,6 @@ import mineplex.gemhunters.loot.InventoryModule;
|
|||||||
import mineplex.gemhunters.loot.LootModule;
|
import mineplex.gemhunters.loot.LootModule;
|
||||||
import mineplex.gemhunters.map.ItemMapModule;
|
import mineplex.gemhunters.map.ItemMapModule;
|
||||||
import mineplex.gemhunters.moderation.ModerationModule;
|
import mineplex.gemhunters.moderation.ModerationModule;
|
||||||
import mineplex.gemhunters.mount.MountModule;
|
|
||||||
import mineplex.gemhunters.persistence.PersistenceModule;
|
import mineplex.gemhunters.persistence.PersistenceModule;
|
||||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||||
import mineplex.gemhunters.quest.QuestModule;
|
import mineplex.gemhunters.quest.QuestModule;
|
||||||
@ -91,12 +98,6 @@ import mineplex.gemhunters.worldevent.WorldEventModule;
|
|||||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.spigotmc.SpigotConfig;
|
|
||||||
|
|
||||||
import static mineplex.core.Managers.require;
|
import static mineplex.core.Managers.require;
|
||||||
|
|
||||||
@ -281,7 +282,6 @@ public class GemHunters extends JavaPlugin
|
|||||||
require(ItemMapModule.class);
|
require(ItemMapModule.class);
|
||||||
require(JoinModule.class);
|
require(JoinModule.class);
|
||||||
require(ModerationModule.class);
|
require(ModerationModule.class);
|
||||||
require(MountModule.class);
|
|
||||||
require(PersistenceModule.class);
|
require(PersistenceModule.class);
|
||||||
require(PlayerStatusModule.class);
|
require(PlayerStatusModule.class);
|
||||||
require(QuestModule.class);
|
require(QuestModule.class);
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
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;
|
|
||||||
private long _cooldown;
|
|
||||||
|
|
||||||
public void setMountType(MountType mountType)
|
|
||||||
{
|
|
||||||
_mountType = mountType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MountType getMountType()
|
|
||||||
{
|
|
||||||
return _mountType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEntity(LivingEntity entity)
|
|
||||||
{
|
|
||||||
_entity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LivingEntity getEntity()
|
|
||||||
{
|
|
||||||
return _entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCooldown(long cooldown)
|
|
||||||
{
|
|
||||||
_cooldown = cooldown;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCooldown()
|
|
||||||
{
|
|
||||||
return _cooldown;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
package mineplex.gemhunters.mount;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Horse;
|
|
||||||
import org.bukkit.entity.Horse.Color;
|
|
||||||
import org.bukkit.entity.Horse.Style;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Tameable;
|
|
||||||
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.F;
|
|
||||||
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 = "MOUNT";
|
|
||||||
|
|
||||||
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 (!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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Recharge.Instance.usable(player, _moduleName))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int cooldown = Integer.parseInt(lootItem.getMetadata().split(" ")[1]) * 1000;
|
|
||||||
|
|
||||||
spawnMount(player, cooldown);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnMount(Player player, long cooldown)
|
|
||||||
{
|
|
||||||
GameModifierMount mount = ((GameModifierMount) _gadget.getActiveGameModifier(player, GameModifierType.GemHunters, g -> g != null));
|
|
||||||
MountType mountType = null;
|
|
||||||
|
|
||||||
if (mount != null)
|
|
||||||
{
|
|
||||||
mountType = mount.getMountType();
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage(F.main(_moduleName, "Mounts are currently disabled."));
|
|
||||||
//spawnMount(player, mountType, cooldown);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnMount(Player player, MountType mountType, long cooldown)
|
|
||||||
{
|
|
||||||
MountData data = Get(player);
|
|
||||||
LivingEntity entity = data.getEntity();
|
|
||||||
EntityType entityType = mountType == null ? EntityType.HORSE : mountType.getEntityType();
|
|
||||||
|
|
||||||
despawnMount(player);
|
|
||||||
|
|
||||||
entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation().add(0, 1, 0), entityType);
|
|
||||||
|
|
||||||
if (entity instanceof Tameable)
|
|
||||||
{
|
|
||||||
Tameable tameable = (Tameable) entity;
|
|
||||||
|
|
||||||
tameable.setOwner(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof Horse)
|
|
||||||
{
|
|
||||||
Horse horse = (Horse) entity;
|
|
||||||
|
|
||||||
horse.setAdult();
|
|
||||||
horse.setAgeLock(true);
|
|
||||||
horse.setColor(Color.BROWN);
|
|
||||||
horse.setStyle(Style.NONE);
|
|
||||||
horse.setMaxDomestication(1);
|
|
||||||
horse.setJumpStrength(0.8);
|
|
||||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
|
||||||
horse.getInventory().setArmor(new ItemStack(player.getItemInHand().getType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.setCustomName(player.getName() + "\'s Mount");
|
|
||||||
entity.setCustomNameVisible(true);
|
|
||||||
entity.setCanPickupItems(false);
|
|
||||||
entity.setMaxHealth(40);
|
|
||||||
entity.setHealth(40);
|
|
||||||
|
|
||||||
data.setEntity(entity);
|
|
||||||
data.setMountType(mountType);
|
|
||||||
data.setCooldown(cooldown);
|
|
||||||
|
|
||||||
entity.setPassenger(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void despawnMount(Player player)
|
|
||||||
{
|
|
||||||
MountData data = Get(player);
|
|
||||||
LivingEntity entity = data.getEntity();
|
|
||||||
|
|
||||||
if (entity != null)
|
|
||||||
{
|
|
||||||
entity.remove();
|
|
||||||
|
|
||||||
Recharge.Instance.use(player, _moduleName, data.getCooldown(), true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive(Player player)
|
|
||||||
{
|
|
||||||
return Get(player).getEntity() != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package mineplex.gemhunters.mount.event;
|
|
||||||
|
|
||||||
public class MountSpawnEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user