Add descriptions to shop items

This commit is contained in:
Sam 2018-06-19 22:43:13 +01:00 committed by Alexander Meech
parent 3054ac2cfb
commit 4435ceac26
4 changed files with 59 additions and 32 deletions

View File

@ -480,21 +480,21 @@ public class CombatManager extends MiniPlugin
if (killer != null)
{
killer.sendMessage(F.main("Death", "You " + combatEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "."));
killer.sendMessage(F.main(getName(), "You " + combatEvent.getKilledWord() + " " + F.elem(deadPlayer) + " with " + F.item(weapon) + "."));
}
event.getEntity().sendMessage(F.main("Death", killPlayer + C.mBody + " " + combatEvent.getKilledWord() + " you with " + F.item(weapon) + "."));
event.getEntity().sendMessage(F.main(getName(), killPlayer + C.mBody + " " + combatEvent.getKilledWord() + " you with " + F.item(weapon) + "."));
}
else
{
if (log.GetAttackers().isEmpty())
{
UtilPlayer.message(event.getEntity(), F.main("Death", "You have died."));
UtilPlayer.message(event.getEntity(), F.main(getName(), "You have died."));
}
else
{
UtilPlayer.message(event.getEntity(), F.main("Death", "You were " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
UtilPlayer.message(event.getEntity(), F.main(getName(), "You were " + combatEvent.getKilledWord() + " by " + F.name(log.GetAttackers().getFirst().GetName())) + C.mBody + ".");
}
}
}

View File

@ -336,7 +336,7 @@ public class CakeShopModule extends CakeModule
Location location = cakeTeam.getCake().clone();
DustSpellColor color = new DustSpellColor(team.GetColorBase());
int radius = getHealingStationRadius(level);
double deltaTheta = Math.PI / (25 - (5 * level));
double deltaTheta = Math.PI / (27 - (7 * level));
for (double theta = 0; theta < 2 * Math.PI; theta += deltaTheta)
{

View File

@ -8,8 +8,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilText;
import mineplex.core.itemstack.ItemBuilder;
public enum CakeTeamItem implements CakeItem
@ -18,8 +22,9 @@ public enum CakeTeamItem implements CakeItem
PROTECTION(
"Protection",
new ItemStack(Material.DIAMOND_CHESTPLATE),
4,
10
"Gives your entire team %s.",
Pair.create("Protection I", 4),
Pair.create("Protection II", 10)
)
{
@Override
@ -37,8 +42,9 @@ public enum CakeTeamItem implements CakeItem
HASTE(
"Haste",
new ItemStack(Material.GOLD_PICKAXE),
4,
10
"Gives your entire team %s.",
Pair.create("Haste I", 4),
Pair.create("Haste II", 10)
)
{
@Override
@ -50,8 +56,9 @@ public enum CakeTeamItem implements CakeItem
SHARPNESS(
"Sharpness",
new ItemStack(Material.DIAMOND_SWORD),
8,
12
"Gives your entire team %s.",
Pair.create("Sharpness I", 8),
Pair.create("Haste II", 12)
)
{
@Override
@ -67,10 +74,11 @@ public enum CakeTeamItem implements CakeItem
}
},
POWER(
"Sharpness",
new ItemStack(Material.DIAMOND_SWORD),
8,
12
"Power",
new ItemStack(Material.BOW),
"Gives your entire team %s.",
Pair.create("Power I", 8),
Pair.create("Power II", 12)
)
{
@Override
@ -88,14 +96,16 @@ public enum CakeTeamItem implements CakeItem
RESOURCE(
"Resource Generator",
new ItemStack(Material.NETHER_STAR),
10,
20
"When an item generates in your generator it also generate %s extra.",
Pair.create("1", 10),
Pair.create("2", 20)
),
REGENERATION(
"Healing Station",
new ItemStack(Material.GOLDEN_APPLE),
8,
12
"Receive %s when within %s of your cake.",
Pair.create("Regeneration I;5 blocks", 8),
Pair.create("Regeneration I;8 blocks", 12)
)
{
@Override
@ -105,8 +115,7 @@ public enum CakeTeamItem implements CakeItem
if (UtilMath.offset2dSquared(player.getLocation(), cake) < maxDist * maxDist)
{
player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, level - 1, true, false));
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 60, 0, true, false), true);
}
}
},
@ -114,16 +123,19 @@ public enum CakeTeamItem implements CakeItem
private final String _name;
private final ItemStack _itemStack;
private final int[] _costs;
private final String _description;
private final Pair<String, Integer>[] _levels;
CakeTeamItem(String name, ItemStack itemStack, int... costs)
@SafeVarargs
CakeTeamItem(String name, ItemStack itemStack, String description, Pair<String, Integer>... levels)
{
_name = name;
_itemStack = new ItemBuilder(itemStack)
.setTitle(name)
.setGlow(true)
.build();
_costs = costs;
_description = description;
_levels = levels;
}
public void apply(Player player, int level, Location cake)
@ -147,9 +159,22 @@ public enum CakeTeamItem implements CakeItem
return _itemStack;
}
public int[] getCosts()
public String[] getDescription(int level)
{
return _costs;
String description = C.mBody + _description;
String[] vars = _levels[level].getLeft().split(";");
for (String var : vars)
{
description = description.replaceFirst("%s", C.cGreen + var + C.mBody);
}
return UtilText.splitLineToArray(description, LineFormat.LORE);
}
public Pair<String, Integer>[] getLevels()
{
return _levels;
}
@Override

View File

@ -15,7 +15,6 @@ import mineplex.core.common.util.UtilText;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.cakewars.shop.CakeItem;
@ -63,11 +62,11 @@ public class CakeResourceStarPage extends CakeResourcePage
int level = _cakeTeam.getUpgrades().get(item);
ItemStack itemStack = _resource.getItemStack();
if (level == teamItem.getCosts().length)
if (level == teamItem.getLevels().length)
{
return CakeShopResult.MAX_TIER;
}
else if (!UtilInv.contains(_player, itemStack.getType(), itemStack.getData().getData(), teamItem.getCosts()[level]))
else if (!UtilInv.contains(_player, itemStack.getType(), itemStack.getData().getData(), teamItem.getLevels()[level].getRight()))
{
return CakeShopResult.NOT_ENOUGH_RESOURCES;
}
@ -97,9 +96,12 @@ public class CakeResourceStarPage extends CakeResourcePage
}
else
{
builder.addLore("");
builder.addLore(teamItem.getDescription(level));
builder.addLore(
"",
"Cost: " + _resource.getChatColor() + teamItem.getCosts()[level] + " " + _resource.getName() + "s",
"Cost: " + _resource.getChatColor() + teamItem.getLevels()[level].getRight() + " " + _resource.getName() + "s",
"",
result.getColour() + result.getFeedback()
);
@ -139,7 +141,7 @@ public class CakeResourceStarPage extends CakeResourcePage
}
ItemStack resource = _resource.getItemStack();
UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getCosts()[_level]);
UtilInv.remove(player, resource.getType(), resource.getData().getData(), _item.getLevels()[_level].getRight());
int newLevel = _level + 1;
String name = F.name(_item.getName() + " " + UtilText.toRomanNumeral(newLevel));
@ -157,7 +159,7 @@ public class CakeResourceStarPage extends CakeResourcePage
for (Entry<CakeTeamItem, Integer> entry : _cakeTeam.getUpgrades().entrySet())
{
if (entry.getValue() != entry.getKey().getCosts().length)
if (entry.getValue() != entry.getKey().getLevels().length)
{
ownsAll = false;
break;