Changes to wizards
This commit is contained in:
parent
9b4f1a491e
commit
72e61a02df
@ -1,27 +0,0 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
|
||||||
|
|
||||||
import mineplex.core.shop.item.SingleButton;
|
|
||||||
import nautilus.game.arcade.game.games.wizards.SpellType.SpellElement;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class ElementButton extends SingleButton
|
|
||||||
{
|
|
||||||
|
|
||||||
private SpellElement _element;
|
|
||||||
private SpellMenuPage _spellPage;
|
|
||||||
|
|
||||||
public ElementButton(SpellMenuPage spellPage, SpellElement element)
|
|
||||||
{
|
|
||||||
_element = element;
|
|
||||||
_spellPage = spellPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void Clicked(Player player)
|
|
||||||
{
|
|
||||||
_spellPage.getWizards().getWizard(player).selectedPage = _element;
|
|
||||||
_spellPage.BuildPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +1,39 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public abstract class Spell implements Listener
|
public abstract class Spell implements Listener
|
||||||
{
|
{
|
||||||
public interface SpellRightClick
|
|
||||||
{
|
|
||||||
public void castSpell(Player player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SpellRightClickEntity
|
private SpellType Spell;
|
||||||
{
|
protected WizardBattles Wizards;
|
||||||
public void castSpell(Player player, Entity entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface SpellRightClickBlock
|
|
||||||
{
|
|
||||||
public void castSpell(Player player, Block block);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected WizardBattles wizards;
|
|
||||||
protected SpellType spell;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Charges him for the cost of the spell
|
* Charges him for the cost of the spell
|
||||||
*/
|
*/
|
||||||
public void charge(Player player)
|
public void charge(Player player)
|
||||||
{
|
{
|
||||||
WizardBattles.Wizard wizard = wizards.getWizard(player);
|
Wizard wizard = Wizards.getWizard(player);
|
||||||
wizard.mana -= spell.getManaCost(wizard.knownSpells.get(spell));
|
int spellLevel = wizard.getSpellLevel(getSpell());
|
||||||
wizard.cooldowns.put(spell, System.currentTimeMillis() + (1000L * spell.getSpellCooldown(wizard.knownSpells.get(spell))));
|
wizard.setMana(wizard.getMana() - getSpell().getManaCost(spellLevel));
|
||||||
wizards.displayBossbar(player);
|
wizard.setUsedSpell(getSpell());
|
||||||
|
Wizards.displayBossbar(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpellType getSpell()
|
||||||
|
{
|
||||||
|
return Spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSpellLevel(Player player)
|
protected int getSpellLevel(Player player)
|
||||||
{
|
{
|
||||||
return wizards.getWizard(player).knownSpells.get(spell);
|
return Wizards.getWizard(player).getSpellLevel(getSpell());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpellType(SpellType spell)
|
||||||
|
{
|
||||||
|
Spell = spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class SpellButton extends SingleButton
|
|||||||
{
|
{
|
||||||
item = _spell.makeSpell(_spellPage.getWizards(), item);
|
item = _spell.makeSpell(_spellPage.getWizards(), item);
|
||||||
player.setItemInHand(item);
|
player.setItemInHand(item);
|
||||||
player.sendMessage(C.cBlue + "Set spell on wand to " + _spell.getElement().getColor() + _spell.get_spellName());
|
player.sendMessage(C.cBlue + "Set spell on wand to " + _spell.getElement().getColor() + _spell.getSpellName());
|
||||||
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1);
|
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 10, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
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.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
@ -7,7 +9,6 @@ import mineplex.core.itemstack.ItemBuilder;
|
|||||||
import mineplex.core.shop.item.ShopItem;
|
import mineplex.core.shop.item.ShopItem;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import nautilus.game.arcade.game.games.wizards.SpellType.SpellElement;
|
import nautilus.game.arcade.game.games.wizards.SpellType.SpellElement;
|
||||||
import nautilus.game.arcade.game.games.wizards.WizardBattles.Wizard;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -29,10 +30,17 @@ public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenu
|
|||||||
protected void BuildPage()
|
protected void BuildPage()
|
||||||
{
|
{
|
||||||
Wizard wizard = getWizards().getWizard(Player);
|
Wizard wizard = getWizards().getWizard(Player);
|
||||||
|
|
||||||
|
ArrayList<Integer> usedNumbers = new ArrayList<Integer>();
|
||||||
|
|
||||||
for (SpellElement ele : SpellElement.values())
|
for (SpellElement ele : SpellElement.values())
|
||||||
{
|
{
|
||||||
AddButton(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true), new ElementButton(this,
|
AddItem(ele.getSlot(), new ShopItem(ele.getIcon(), ele.name(), ele.name(), 1, true, true));
|
||||||
ele));
|
|
||||||
|
for (int i = ele.getFirstSlot(); i <= ele.getSecondSlot(); i++)
|
||||||
|
{
|
||||||
|
usedNumbers.add(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 9; i < 54; i++)
|
for (int i = 9; i < 54; i++)
|
||||||
@ -40,38 +48,39 @@ public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenu
|
|||||||
SpellType spell = null;
|
SpellType spell = null;
|
||||||
for (SpellType spells : SpellType.values())
|
for (SpellType spells : SpellType.values())
|
||||||
{
|
{
|
||||||
if (spells.getElement() == wizard.selectedPage && spells.get_slot() == i)
|
if (spells.getSlot() == i)
|
||||||
{
|
{
|
||||||
spell = spells;
|
spell = spells;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spell == null)
|
|
||||||
|
if (usedNumbers.contains(i % 9) && spell != null)
|
||||||
{
|
{
|
||||||
RemoveButton(i);
|
|
||||||
}
|
int spellLevel = wizard.getSpellLevel(spell);
|
||||||
else
|
|
||||||
|
if (spellLevel > 0)
|
||||||
{
|
{
|
||||||
if (wizard.knownSpells.containsKey(spell))
|
|
||||||
{
|
|
||||||
int level = wizard.knownSpells.get(spell);
|
|
||||||
ItemBuilder builder = new ItemBuilder(spell.getSpellItem());
|
ItemBuilder builder = new ItemBuilder(spell.getSpellItem());
|
||||||
builder.setTitle(C.Bold + C.cDPurple + "Spell: " + spell.getElement().getColor() + spell.get_spellName());
|
builder.setTitle(C.cDPurple + C.Bold + "Spell: " + spell.getElement().getColor() + spell.getSpellName());
|
||||||
builder.addLore(C.Bold + C.cBlue + "Spell Level: " + C.cDAqua + level);
|
builder.addLore(C.cBlue + C.Bold + "Spell Level: " + C.cDAqua + spellLevel);
|
||||||
builder.addLore(C.Bold + C.cBlue + "Mana Cost: " + C.cDAqua + spell.getManaCost(level));
|
builder.addLore(C.cBlue + C.Bold + "Mana Cost: " + C.cDAqua + spell.getManaCost(spellLevel));
|
||||||
builder.addLore(C.Bold + C.cBlue + "Cooldown: " + C.cDAqua + spell.getSpellCooldown(level) + C.cGray);
|
builder.addLore(C.cBlue + C.Bold + "Cooldown: " + C.cDAqua + spell.getSpellCooldown(spellLevel) + C.cGray);
|
||||||
|
builder.addLore("");
|
||||||
|
|
||||||
for (String lore : spell.getDesc())
|
for (String lore : spell.getDesc())
|
||||||
{
|
{
|
||||||
builder.addLore(C.cGreen + lore, 40);
|
builder.addLore(C.cGreen + lore, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton(this,
|
AddButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton(this,
|
||||||
spell));
|
spell));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddItem(i,
|
AddItem(i, new ShopItem(new ItemBuilder(Material.INK_SACK, 1, (byte) 8).setTitle(C.cRed + C.Bold + "Unknown")
|
||||||
new ShopItem(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (byte) 7).setTitle(
|
.build(), "Unknown", "Unknown", 1, true, true));
|
||||||
ChatColor.RED + "Unknown Spell").build(), "Unknown Spell", "Unknown Spell", 1, true, true));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import nautilus.game.arcade.game.games.wizards.spells.*;
|
import nautilus.game.arcade.game.games.wizards.spells.*;
|
||||||
@ -13,101 +11,245 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
public enum SpellType // ❤
|
public enum SpellType // ❤
|
||||||
{
|
{
|
||||||
|
|
||||||
|
WizardsCompass(SpellElement.MISC, // Spell element
|
||||||
|
"Wizard's Compass", // Spell name
|
||||||
|
new ItemStack(Material.COMPASS), // Spell icon
|
||||||
|
SpellWizardsCompass.class, // Spell class
|
||||||
|
1, // Spell max level
|
||||||
|
10, // Mana cost
|
||||||
|
4, // Spell cooldown
|
||||||
|
0, // Mana cost change per level
|
||||||
|
0, // Cooldown change per level
|
||||||
|
0, // Item amount in loot
|
||||||
|
|
||||||
|
"Displays particles pointing to the closest enemy!"),
|
||||||
|
|
||||||
|
Bridge(SpellElement.MISC, // Spell element
|
||||||
|
"Bridge", // Spell name
|
||||||
|
new ItemStack(Material.FENCE), // Spell icon
|
||||||
|
SpellBridge.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
50, // Mana cost
|
||||||
|
20, // Spell cooldown
|
||||||
|
0, // Mana cost change per level
|
||||||
|
-5, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Length: " + C.Bold + C.cWhite + "Spell Level x 10",
|
||||||
|
|
||||||
|
"Right click on the block before the chasm",
|
||||||
|
|
||||||
|
"and a mighty dirt bridge will appear!"),
|
||||||
|
|
||||||
|
Drain(SpellElement.MISC, // Spell element
|
||||||
|
"Drain", // Spell name
|
||||||
|
new ItemStack(Material.BUCKET), // Spell icon
|
||||||
|
SpellDrain.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
30, // Mana cost
|
||||||
|
20, // Spell cooldown
|
||||||
|
-3, // Mana cost change per level
|
||||||
|
-4, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Drained Mana: " + C.Bold + C.cWhite + "Spell Level x 40",
|
||||||
|
|
||||||
|
"Right click other players with this spell",
|
||||||
|
|
||||||
|
"to empty their mana reserves!",
|
||||||
|
|
||||||
|
"You gain a third of the absorbed mana!"),
|
||||||
|
|
||||||
Droom(SpellElement.ATTACK, // Spell element
|
Droom(SpellElement.ATTACK, // Spell element
|
||||||
"Droom", // Spell name
|
"Droom", // Spell name
|
||||||
new ItemStack(Material.ANVIL), // Spell icon
|
new ItemStack(Material.ANVIL), // Spell icon
|
||||||
Droom.class, // Spell class
|
SpellDroom.class, // Spell class
|
||||||
3, // Spell max level
|
3, // Spell max level
|
||||||
50, // Mana cost
|
50, // Mana cost
|
||||||
20, // Spell cooldown
|
20, // Spell cooldown
|
||||||
-3, // Mana cost change per level
|
-3, // Mana cost change per level
|
||||||
-4, // Cooldown change per level
|
-4, // Cooldown change per level
|
||||||
3, // Chance in ? to find
|
3, // Item amount in loot
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Explosion Size: " + C.cAqua + "1 + (Spell Level / 2)",
|
C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "(Spell Level / 2) + 1",
|
||||||
|
|
||||||
"Summons exploding anvils over everyone near you!"),
|
"Summons exploding anvils over everyone near you!"),
|
||||||
|
|
||||||
Lance(SpellElement.ATTACK, // Spell element
|
Fireball(SpellElement.ATTACK, // Spell element
|
||||||
"Lance", // Spell name
|
"Fireball", // Spell name
|
||||||
new ItemStack(Material.STICK), // Spell icon
|
new ItemStack(Material.FIREBALL), // Spell icon
|
||||||
Lance.class, // Spell class
|
SpellFireball.class, // Spell class
|
||||||
3, // Spell max level
|
3, // Spell max level
|
||||||
75, // Mana cost
|
30, // Mana cost
|
||||||
60, // Spell cooldown
|
20, // Spell cooldown
|
||||||
|
-3, // Mana cost change per level
|
||||||
|
-2, // Cooldown change per level
|
||||||
|
5, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "Spell Level x 0.8",
|
||||||
|
|
||||||
|
"Be a object of fear and awe!",
|
||||||
|
|
||||||
|
"Summon a blazing fireball!"),
|
||||||
|
|
||||||
|
Flash(SpellElement.SUPPORT, // Spell element
|
||||||
|
"Flash", // Spell name
|
||||||
|
new ItemStack(Material.REDSTONE_TORCH_ON), // Spell icon
|
||||||
|
SpellFlash.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
50, // Mana cost
|
||||||
|
50, // Spell cooldown
|
||||||
0, // Mana cost change per level
|
0, // Mana cost change per level
|
||||||
-10, // Cooldown change per level
|
-5, // Cooldown change per level
|
||||||
3, // Chance in ? to find
|
3, // Item amount in loot
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Lance Size: " + C.cAqua + "Spell Level * 6",
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 10)+ 20",
|
||||||
|
|
||||||
"Summons a lance of explosions!"),
|
"Teleport to the block you are looking at!"),
|
||||||
|
|
||||||
Heal(SpellElement.SUPPORT, // Spell element
|
Heal(SpellElement.SUPPORT, // Spell element
|
||||||
"Heal", // Spell name
|
"Heal", // Spell name
|
||||||
new ItemStack(Material.POTION, 1, (short) 8261), // Spell icon
|
new ItemStack(Material.POTION, 1, (short) 8261), // Spell icon
|
||||||
Heal.class, // Spell class
|
SpellHeal.class, // Spell class
|
||||||
5, // Spell max level
|
5, // Spell max level
|
||||||
50, // Mana cost
|
50, // Mana cost
|
||||||
5, // Spell cooldown
|
5, // Spell cooldown
|
||||||
0, // Mana cost change per level
|
0, // Mana cost change per level
|
||||||
10, // Cooldown change per level
|
10, // Cooldown change per level
|
||||||
5, // Chance in ? to find
|
5, // Item amount in loot
|
||||||
C.Bold + C.cBlue + "Heals: " + C.cAqua + "2 * Spell Level",
|
|
||||||
|
C.cGold + C.Bold + "Heals: " + C.Bold + C.cWhite + "Spell Level x 2",
|
||||||
|
|
||||||
"Low on health and need to retreat?",
|
"Low on health and need to retreat?",
|
||||||
|
|
||||||
"Use this! Heal yourself up!"),
|
"Use this! Heal yourself up!"),
|
||||||
|
|
||||||
|
Implode(SpellElement.MISC, // Spell element
|
||||||
|
"Implode", // Spell name
|
||||||
|
new ItemStack(Material.TNT), // Spell icon
|
||||||
|
SpellFlash.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
50, // Mana cost
|
||||||
|
30, // Spell cooldown
|
||||||
|
-2, // Mana cost change per level
|
||||||
|
-3, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "50",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Implosion Height: " + C.Bold + C.cWhite + "Spell Level",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Implosion Width: " + C.Bold + C.cWhite + "Spell Level x 2",
|
||||||
|
|
||||||
|
"Gathers the blocks at target location",
|
||||||
|
|
||||||
|
"and scatters them about the area"),
|
||||||
|
|
||||||
|
Lance(SpellElement.ATTACK, // Spell element
|
||||||
|
"Lance", // Spell name
|
||||||
|
new ItemStack(Material.STICK), // Spell icon
|
||||||
|
SpellLance.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
75, // Mana cost
|
||||||
|
60, // Spell cooldown
|
||||||
|
0, // Mana cost change per level
|
||||||
|
-10, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Lance Size: " + C.Bold + C.cWhite + "Spell Level * 6",
|
||||||
|
|
||||||
|
"Summons a lance of explosions!"),
|
||||||
|
|
||||||
|
LightningStrike(SpellElement.ATTACK, // Spell element
|
||||||
|
"Lightning Strike", // Spell name
|
||||||
|
new ItemStack(Material.WOOD_AXE), // Spell icon
|
||||||
|
SpellLightningStrike.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
80, // Mana cost
|
||||||
|
20, // Spell cooldown
|
||||||
|
0, // Mana cost change per level
|
||||||
|
0, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Length: " + C.Bold + C.cWhite + "Spell Level x 10",
|
||||||
|
|
||||||
|
"Right click on the block before the chasm",
|
||||||
|
|
||||||
|
"and a mighty dirt bridge will appear!"),
|
||||||
|
|
||||||
MagicMissile(SpellElement.ATTACK, // Spell element
|
MagicMissile(SpellElement.ATTACK, // Spell element
|
||||||
"Magic Missile", // Spell name
|
"Magic Missile", // Spell name
|
||||||
new ItemStack(Material.STICK), // Spell icon
|
new ItemStack(Material.STICK), // Spell icon
|
||||||
MagicMissile.class, // Spell class
|
SpellMagicMissile.class, // Spell class
|
||||||
3, // Spell max level
|
3, // Spell max level
|
||||||
20, // Mana cost
|
20, // Mana cost
|
||||||
10, // Spell cooldown
|
10, // Spell cooldown
|
||||||
-2, // Mana cost change per level
|
-2, // Mana cost change per level
|
||||||
-2, // Cooldown change per level
|
-2, // Cooldown change per level
|
||||||
10, // Chance in ? to find
|
10, // Item amount in loot
|
||||||
C.Bold + C.cBlue + "Damage: " + C.cAqua + "0.5 + (Spell Level / 2)",
|
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Range: " + C.cAqua + "15 x Spell Level",
|
C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level / 2) + 0.5",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 15",
|
||||||
|
|
||||||
"The basic spell all beginner mages are taught.",
|
"The basic spell all beginner mages are taught.",
|
||||||
|
|
||||||
"This creates a magic missile that is commonly attributed to the magic profession."),
|
"This creates a magic missile that is commonly attributed to the magic profession."),
|
||||||
|
|
||||||
|
TeleportRune(SpellElement.RUNES, // Spell element
|
||||||
|
"Teleport Rune", // Spell name
|
||||||
|
new ItemStack(Material.ENDER_PEARL), // Spell icon
|
||||||
|
SpellTeleportRune.class, // Spell class
|
||||||
|
3, // Spell max level
|
||||||
|
70, // Mana cost
|
||||||
|
40, // Spell cooldown
|
||||||
|
-5, // Mana cost change per level
|
||||||
|
-5, // Cooldown change per level
|
||||||
|
10, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 25",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Size: " + C.Bold + C.cWhite + "Spell Level x 1.5",
|
||||||
|
|
||||||
|
"This draws a teleport rune on the ground",
|
||||||
|
|
||||||
|
"The created rune is usable by anyone and lasts",
|
||||||
|
|
||||||
|
"for 5 seconds after the 2 second warmup period.",
|
||||||
|
|
||||||
|
"The teleport is one way, you cannot return."),
|
||||||
|
|
||||||
RainbowBeam(SpellElement.ATTACK, // Spell element
|
RainbowBeam(SpellElement.ATTACK, // Spell element
|
||||||
"Rainbow Beam", // Spell name
|
"Rainbow Beam", // Spell name
|
||||||
new ItemStack(Material.EMERALD), // Spell icon
|
new ItemStack(Material.EMERALD), // Spell icon
|
||||||
RainbowBeam.class, // Spell class
|
SpellRainbowBeam.class, // Spell class
|
||||||
5, // Spell max level
|
5, // Spell max level
|
||||||
5, // Mana cost
|
5, // Mana cost
|
||||||
8, // Spell cooldown
|
8, // Spell cooldown
|
||||||
3, // Mana cost change per level
|
3, // Mana cost change per level
|
||||||
1, // Cooldown change per level
|
1, // Cooldown change per level
|
||||||
3, // Chance in ? to find
|
3, // Item amount in loot
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Damage: " + C.cAqua + "0.75 * Spell Level",
|
C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "Spell Level x 0.75",
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Ramge: " + C.cAqua + "20 x Spell Level",
|
C.cGold + C.Bold + "Ramge: " + C.Bold + C.cWhite + "Spell Level x 20",
|
||||||
|
|
||||||
"A beam of rainbows!", "This doesn't do much damage", "But has practically no cooldown!"),
|
"A magical girl beam of rainbows!", "This doesn't do much damage", "But has practically no cooldown!"),
|
||||||
|
|
||||||
Rumble(SpellElement.ATTACK, // Spell element
|
Rumble(SpellElement.ATTACK, // Spell element
|
||||||
"Rumble", // Spell name
|
"Rumble", // Spell name
|
||||||
new ItemStack(Material.DIRT), // Spell icon
|
new ItemStack(Material.DIRT), // Spell icon
|
||||||
Rumble.class, // Spell class
|
SpellRumble.class, // Spell class
|
||||||
10, // Spell max level
|
10, // Spell max level
|
||||||
30, // Mana cost
|
30, // Mana cost
|
||||||
5, // Spell cooldown
|
5, // Spell cooldown
|
||||||
0, // Mana cost change per level
|
0, // Mana cost change per level
|
||||||
0, // Cooldown change per level
|
0, // Cooldown change per level
|
||||||
3, // Chance in ? to find
|
3, // Item amount in loot
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Damage: " + C.cAqua + "0.5 + (Spell Level / 2)",
|
C.cGold + C.Bold + "Damage: " + C.Bold + C.cWhite + "(Spell Level / 2) + 0.5",
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Range: " + C.cAqua + "10 x Spell Level",
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "Spell Level x 10",
|
||||||
|
|
||||||
"Summons a targeted earthquake",
|
"Summons a targeted earthquake",
|
||||||
|
|
||||||
@ -115,60 +257,89 @@ public enum SpellType // ❤
|
|||||||
|
|
||||||
"from the block you right click!"),
|
"from the block you right click!"),
|
||||||
|
|
||||||
StoneWall(SpellElement.SUPPORT, // Spell element
|
SpeedBoost(SpellElement.SUPPORT, // Spell element
|
||||||
|
"Speed Boost", // Spell name
|
||||||
|
new ItemStack(Material.FEATHER), // Spell icon
|
||||||
|
SpellSpeedBoost.class, // Spell class
|
||||||
|
2, // Spell max level
|
||||||
|
20, // Mana cost
|
||||||
|
100, // Spell cooldown
|
||||||
|
0, // Mana cost change per level
|
||||||
|
0, // Cooldown change per level
|
||||||
|
3, // Item amount in loot
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Length: " + C.Bold + C.cWhite + "(Spell Level x 30) + 60",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Strength: " + C.Bold + C.cWhite + "Spell Level",
|
||||||
|
|
||||||
|
"Gain a speed potion effect to outrun your enemies"),
|
||||||
|
|
||||||
|
StoneWall(SpellElement.MISC, // Spell element
|
||||||
"Stone Wall", // Spell name
|
"Stone Wall", // Spell name
|
||||||
new ItemStack(Material.STONE), // Spell icon
|
new ItemStack(Material.STONE), // Spell icon
|
||||||
StoneWall.class, // Spell class
|
SpellStoneWall.class, // Spell class
|
||||||
3, // Spell max level
|
3, // Spell max level
|
||||||
60, // Mana cost
|
60, // Mana cost
|
||||||
10, // Spell cooldown
|
10, // Spell cooldown
|
||||||
0, // Mana cost change per level
|
0, // Mana cost change per level
|
||||||
-5, // Cooldown change per level
|
-5, // Cooldown change per level
|
||||||
3, // Chance in ? to find
|
3, // Item amount in loot
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Height: " + C.cAqua + "1 + Spell Level",
|
C.cGold + C.Bold + "Height: " + C.Bold + C.cWhite + "Spell Level + 1",
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Width: " + C.cAqua + "5 x Spell Level",
|
C.cGold + C.Bold + "Width: " + C.Bold + C.cWhite + "Spell Level x 5",
|
||||||
|
|
||||||
"Create a wall of stone!", "Width = SpellLevel x 5", "Height = 1 + SpellLevel"),
|
"Create a wall of stone!"),
|
||||||
|
|
||||||
TrapRune(SpellElement.ATTACK, // Spell element
|
TrapRune(SpellElement.RUNES, // Spell element
|
||||||
"Trap Rune", // Spell name
|
"Trap Rune", // Spell name
|
||||||
new ItemStack(Material.FIREBALL), // Spell icon
|
new ItemStack(Material.TRAP_DOOR), // Spell icon
|
||||||
TrapRune.class, // Spell class
|
SpellTrapRune.class, // Spell class
|
||||||
3, // Spell max level
|
3, // Spell max level
|
||||||
50, // Mana cost
|
50, // Mana cost
|
||||||
30, // Spell cooldown
|
30, // Spell cooldown
|
||||||
0, // Mana cost change per level
|
0, // Mana cost change per level
|
||||||
-5, // Cooldown change per level
|
-5, // Cooldown change per level
|
||||||
30, // Chance in ? to find
|
30, // Item amount in loot
|
||||||
C.Bold + C.cBlue + "Range: " + C.cAqua + "12 + (4 x Spell Level)",
|
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Rune Size: " + C.cAqua + "Spell Level",
|
C.cGold + C.Bold + "Range: " + C.Bold + C.cWhite + "(Spell Level x 4) + 12",
|
||||||
|
|
||||||
C.Bold + C.cBlue + "Explosion Size: " + C.cAqua + "Spell Level",
|
C.cGold + C.Bold + "Rune Size: " + C.Bold + C.cWhite + "Spell Level",
|
||||||
|
|
||||||
|
C.cGold + C.Bold + "Explosion Size: " + C.Bold + C.cWhite + "Spell Level",
|
||||||
|
|
||||||
"Draws a explosion rune on the ground!",
|
"Draws a explosion rune on the ground!",
|
||||||
|
|
||||||
"The rune takes 5 seconds to prepare",
|
"The rune takes 5 seconds to prepare and will damage even you!");
|
||||||
|
|
||||||
"and will damage even you!");
|
|
||||||
|
|
||||||
public enum SpellElement
|
public enum SpellElement
|
||||||
{
|
{
|
||||||
ATTACK(1, new ItemBuilder(Material.IRON_SWORD).setTitle(ChatColor.RED + "Attack Spells").build(), C.cRed),
|
ATTACK(1, 1, 1, new ItemBuilder(Material.IRON_SWORD).setTitle(ChatColor.RED + "Attack Spells")
|
||||||
|
.addLore(C.cGray + C.Italics + "Spells of destruction").build(), C.cRed),
|
||||||
|
|
||||||
DEFENSE(4, new ItemBuilder(Material.IRON_CHESTPLATE).setTitle(ChatColor.GRAY + "Defense Spells").build(), C.cGray),
|
RUNES(3, 3, 3, new ItemBuilder(Material.NETHER_STAR).setTitle(ChatColor.GOLD + "Rune Spells")
|
||||||
|
.addLore(C.cGray + "Spells for creation of runes").build(), C.cGold),
|
||||||
|
|
||||||
SUPPORT(7, new ItemBuilder(Material.IRON_BOOTS).setTitle(C.cDGreen + "Support Spells").build(), C.cDGreen);
|
MISC(7, 7, 7, new ItemBuilder(Material.COAL_BLOCK).setTitle(ChatColor.GRAY + "Misc Spells").addLore(
|
||||||
|
|
||||||
|
C.cGray + C.Italics + "Misc spells that don't fit in",
|
||||||
|
|
||||||
|
"These spells generally effect the world itself").build(), C.cGray),
|
||||||
|
|
||||||
|
SUPPORT(5, 5, 5, new ItemBuilder(Material.IRON_BOOTS).setTitle(C.cDGreen + "Support Spells")
|
||||||
|
.addLore(C.cGray + C.Italics + "Spells of assistance").build(), C.cDGreen);
|
||||||
|
|
||||||
private String _chatColor;
|
private String _chatColor;
|
||||||
|
private int _firstSlot;
|
||||||
private ItemStack _icon;
|
private ItemStack _icon;
|
||||||
|
private int _secondSlot;
|
||||||
private int _slot;
|
private int _slot;
|
||||||
|
|
||||||
private SpellElement(int slot, ItemStack icon, String color)
|
private SpellElement(int slot, int firstSlot, int secondSlot, ItemStack icon, String color)
|
||||||
{
|
{
|
||||||
_slot = slot;
|
_slot = slot;
|
||||||
|
_firstSlot = firstSlot;
|
||||||
|
_secondSlot = secondSlot;
|
||||||
_icon = icon;
|
_icon = icon;
|
||||||
_chatColor = color;
|
_chatColor = color;
|
||||||
}
|
}
|
||||||
@ -178,11 +349,21 @@ public enum SpellType // ❤
|
|||||||
return _chatColor;
|
return _chatColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFirstSlot()
|
||||||
|
{
|
||||||
|
return _firstSlot;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack getIcon()
|
public ItemStack getIcon()
|
||||||
{
|
{
|
||||||
return _icon;
|
return _icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSecondSlot()
|
||||||
|
{
|
||||||
|
return _secondSlot;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSlot()
|
public int getSlot()
|
||||||
{
|
{
|
||||||
return _slot;
|
return _slot;
|
||||||
@ -197,15 +378,35 @@ public enum SpellType // ❤
|
|||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
for (SpellType s1 : values())
|
for (SpellType spell : values())
|
||||||
{
|
{
|
||||||
s1._slot = 9;
|
spell._slot = 9 + spell.getElement().getFirstSlot();
|
||||||
for (SpellType s : values())
|
|
||||||
|
for (SpellType spell2 : values())
|
||||||
{
|
{
|
||||||
if (s != s1 && s.getElement() == s1.getElement() && s._slot >= s1._slot)
|
if (spell != spell2 && spell.getElement() == spell2.getElement() && spell._slot <= spell2._slot)
|
||||||
{
|
{
|
||||||
s1._slot = s._slot + 1;
|
spell._slot = spell2._slot;
|
||||||
|
int divSlot = spell._slot % 9;
|
||||||
|
|
||||||
|
if (divSlot >= 8 || divSlot + 1 > spell.getElement().getSecondSlot())
|
||||||
|
{
|
||||||
|
|
||||||
|
spell._slot = (spell._slot - divSlot) + 9 + spell.getElement().getFirstSlot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
spell._slot = spell._slot + 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spell._slot > 54)
|
||||||
|
{
|
||||||
|
System.out.print("Assigning " + spell.name() + " to " + spell._slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +415,7 @@ public enum SpellType // ❤
|
|||||||
{
|
{
|
||||||
for (SpellType spell : values())
|
for (SpellType spell : values())
|
||||||
{
|
{
|
||||||
if (spell.get_spellName().equals(spellName))
|
if (spell.getSpellName().equals(spellName))
|
||||||
{
|
{
|
||||||
return spell;
|
return spell;
|
||||||
}
|
}
|
||||||
@ -222,10 +423,10 @@ public enum SpellType // ❤
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _chanceInWhat;
|
|
||||||
private int _cooldownChangePerLevel;
|
private int _cooldownChangePerLevel;
|
||||||
private String[] _desc;
|
private String[] _desc;
|
||||||
private ItemStack _item;
|
private ItemStack _item;
|
||||||
|
private int _itemAmount;
|
||||||
private int _manaChangePerLevel;
|
private int _manaChangePerLevel;
|
||||||
private int _maxLevel;
|
private int _maxLevel;
|
||||||
private int _slot;
|
private int _slot;
|
||||||
@ -233,12 +434,10 @@ public enum SpellType // ❤
|
|||||||
private int _spellCooldown;
|
private int _spellCooldown;
|
||||||
private int _spellCost;
|
private int _spellCost;
|
||||||
private String _spellName;
|
private String _spellName;
|
||||||
|
|
||||||
private SpellElement _type;
|
private SpellElement _type;
|
||||||
|
|
||||||
private SpellType(SpellElement type, String spellName, ItemStack spellItem, Class<? extends Spell> spell, int maxLevel,
|
private SpellType(SpellElement type, String spellName, ItemStack spellItem, Class<? extends Spell> spell, int maxLevel,
|
||||||
int spellCost, int spellCooldown, int manaChangePerLevel, int cooldownChangePerLevel, int oneChanceInWhatToFind,
|
int spellCost, int spellCooldown, int manaChangePerLevel, int cooldownChangePerLevel, int itemAmount, String... desc)
|
||||||
String... desc)
|
|
||||||
{
|
{
|
||||||
_maxLevel = maxLevel;
|
_maxLevel = maxLevel;
|
||||||
_item = spellItem;
|
_item = spellItem;
|
||||||
@ -250,26 +449,7 @@ public enum SpellType // ❤
|
|||||||
_spellCooldown = spellCooldown;
|
_spellCooldown = spellCooldown;
|
||||||
_cooldownChangePerLevel = cooldownChangePerLevel;
|
_cooldownChangePerLevel = cooldownChangePerLevel;
|
||||||
_manaChangePerLevel = manaChangePerLevel;
|
_manaChangePerLevel = manaChangePerLevel;
|
||||||
}
|
_itemAmount = itemAmount;
|
||||||
|
|
||||||
public int get_maxLevel()
|
|
||||||
{
|
|
||||||
return _maxLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int get_slot()
|
|
||||||
{
|
|
||||||
return _slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends Spell> get_spellClass()
|
|
||||||
{
|
|
||||||
return _spellClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String get_spellName()
|
|
||||||
{
|
|
||||||
return _spellName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getDesc()
|
public String[] getDesc()
|
||||||
@ -282,11 +462,37 @@ public enum SpellType // ❤
|
|||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getItemAmount()
|
||||||
|
{
|
||||||
|
return _itemAmount;
|
||||||
|
}
|
||||||
|
|
||||||
public int getManaCost(int level)
|
public int getManaCost(int level)
|
||||||
{
|
{
|
||||||
return Math.max(0, (_manaChangePerLevel * level) + _spellCost);
|
return Math.max(0, (_manaChangePerLevel * level) + _spellCost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxLevel()
|
||||||
|
{
|
||||||
|
return _maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot()
|
||||||
|
{
|
||||||
|
return _slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getSpellBook(WizardBattles wizards)
|
||||||
|
{
|
||||||
|
return makeSpell(wizards, new ItemBuilder(Material.ENCHANTED_BOOK).addLore(C.cAqua + "Click on this to learn a spell")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends Spell> getSpellClass()
|
||||||
|
{
|
||||||
|
return _spellClass;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSpellCooldown(int level)
|
public int getSpellCooldown(int level)
|
||||||
{
|
{
|
||||||
return Math.max(0, (_cooldownChangePerLevel * level) + _spellCooldown);
|
return Math.max(0, (_cooldownChangePerLevel * level) + _spellCooldown);
|
||||||
@ -297,21 +503,15 @@ public enum SpellType // ❤
|
|||||||
return _item;
|
return _item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChanceToFind()
|
public String getSpellName()
|
||||||
{
|
{
|
||||||
return _chanceInWhat <= 0 || new Random().nextInt(_chanceInWhat) == 0;
|
return _spellName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack makeSpell(WizardBattles wizards, ItemStack item)
|
public ItemStack makeSpell(WizardBattles wizards, ItemStack item)
|
||||||
{
|
{
|
||||||
ItemBuilder builder = new ItemBuilder(item);
|
ItemBuilder builder = new ItemBuilder(item);
|
||||||
String s = "";
|
builder.setTitle(C.cDBlue + C.Bold + "Spell: " + _type._chatColor + getSpellName() + wizards.buildTime());
|
||||||
for (char c : ("" + System.nanoTime()).toCharArray())
|
|
||||||
{
|
|
||||||
s += "§" + c;
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setTitle(C.cDBlue + C.Bold + "Spell: " + _type._chatColor + get_spellName() + s);
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
|
||||||
|
public class Wizard
|
||||||
|
{
|
||||||
|
|
||||||
|
private NautHashMap<SpellType, Long> _cooldowns = new NautHashMap<SpellType, Long>();
|
||||||
|
private NautHashMap<SpellType, Integer> _knownSpells = new NautHashMap<SpellType, Integer>();
|
||||||
|
private float _mana;
|
||||||
|
private float _manaPerTick = 0.125F;
|
||||||
|
private float _maxMana;
|
||||||
|
|
||||||
|
public Wizard(float maxMana)
|
||||||
|
{
|
||||||
|
learnSpell(SpellType.MagicMissile);
|
||||||
|
learnSpell(SpellType.WizardsCompass);
|
||||||
|
_maxMana = maxMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCooldown(SpellType type)
|
||||||
|
{
|
||||||
|
if (_cooldowns.containsKey(type))
|
||||||
|
{
|
||||||
|
return _cooldowns.get(type);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMana()
|
||||||
|
{
|
||||||
|
return _mana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getManaPerTick()
|
||||||
|
{
|
||||||
|
return _manaPerTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getMaxMana()
|
||||||
|
{
|
||||||
|
return _maxMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSpellLevel(SpellType type)
|
||||||
|
{
|
||||||
|
if (_knownSpells.containsKey(type))
|
||||||
|
{
|
||||||
|
return _knownSpells.get(type);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void learnSpell(SpellType type)
|
||||||
|
{
|
||||||
|
_knownSpells.put(type, getSpellLevel(type) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMana(float newMana)
|
||||||
|
{
|
||||||
|
_mana = newMana;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedSpell(SpellType spell)
|
||||||
|
{
|
||||||
|
_cooldowns.put(spell, System.currentTimeMillis() + (1000L * spell.getSpellCooldown(_knownSpells.get(spell))));
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,24 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
import mineplex.core.common.util.UtilTextTop;
|
import mineplex.core.common.util.UtilTextTop;
|
||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
|
import mineplex.core.hologram.Hologram;
|
||||||
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;
|
||||||
@ -17,56 +26,59 @@ import nautilus.game.arcade.ArcadeManager;
|
|||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.SoloGame;
|
import nautilus.game.arcade.game.SoloGame;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.kit.KitWizard;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClickBlock;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClickEntity;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickBlock;
|
||||||
import nautilus.game.arcade.game.games.wizards.SpellType.SpellElement;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickEntity;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.IllegalClassException;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
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;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.block.DoubleChest;
|
import org.bukkit.block.DoubleChest;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class WizardBattles extends SoloGame
|
public class WizardBattles extends SoloGame
|
||||||
{
|
{
|
||||||
|
|
||||||
public class Wizard
|
private NautHashMap<String, SpellType> _learnedSpellChests = new NautHashMap<String, SpellType>();
|
||||||
{
|
/**
|
||||||
public Wizard()
|
* The entry is so I can randomize the amounts of the items found
|
||||||
{
|
*/
|
||||||
knownSpells.put(SpellType.MagicMissile, 1);
|
private ArrayList<Entry<ItemStack, Integer>> _randomItems = new ArrayList<Entry<ItemStack, Integer>>();
|
||||||
}
|
|
||||||
|
|
||||||
float manaPerTick = 0.125F;
|
|
||||||
float mana;
|
|
||||||
NautHashMap<SpellType, Integer> knownSpells = new NautHashMap<SpellType, Integer>();
|
|
||||||
NautHashMap<SpellType, Long> cooldowns = new NautHashMap<SpellType, Long>();
|
|
||||||
SpellElement selectedPage = SpellElement.ATTACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NautHashMap<String, Wizard> _wizards = new NautHashMap<String, Wizard>();
|
|
||||||
private NautHashMap<SpellType, Spell> _spells = new NautHashMap<SpellType, Spell>();
|
private NautHashMap<SpellType, Spell> _spells = new NautHashMap<SpellType, Spell>();
|
||||||
private WizardSpellMenu _wizard;
|
private WizardSpellMenu _wizard;
|
||||||
|
|
||||||
|
private NautHashMap<String, Wizard> _wizards = new NautHashMap<String, Wizard>();
|
||||||
|
|
||||||
public WizardBattles(ArcadeManager manager)
|
public WizardBattles(ArcadeManager manager)
|
||||||
{
|
{
|
||||||
super(manager, GameType.WizardBattles, new Kit[0], new String[]
|
super(manager, GameType.WizardBattles, new Kit[0], new String[]
|
||||||
@ -96,74 +108,199 @@ public class WizardBattles extends SoloGame
|
|||||||
SoupEnabled = false;
|
SoupEnabled = false;
|
||||||
AllowParticles = false;
|
AllowParticles = false;
|
||||||
DamageTeamSelf = true;
|
DamageTeamSelf = true;
|
||||||
|
|
||||||
|
createLoot();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRandomItem(int amount, Material itemType, int newDurability, int minAmount, int maxAmount)
|
||||||
|
{
|
||||||
|
int a = minAmount;
|
||||||
|
for (int i = 0; i < amount; i++)
|
||||||
|
{
|
||||||
|
_randomItems.add(new HashMap.SimpleEntry(new ItemStack(itemType, a, (short) newDurability), maxAmount - minAmount));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String buildTime()
|
||||||
|
{
|
||||||
|
String s = "";
|
||||||
|
for (char c : ("" + System.nanoTime()).toCharArray())
|
||||||
|
{
|
||||||
|
s += "§" + c;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateChestCraftEnchant()
|
||||||
|
{
|
||||||
|
ArrayList<Location> chests = WorldData.GetCustomLocs("54");
|
||||||
|
|
||||||
|
System.out.println("Map Chest Locations: " + chests.size());
|
||||||
|
|
||||||
|
// Enchants
|
||||||
|
System.out.println("Enchanting Tables: " + Math.min(5, chests.size()));
|
||||||
|
for (int i = 0; i < 5 && !chests.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
Location loc = chests.remove(UtilMath.r(chests.size()));
|
||||||
|
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int spawn = 0;
|
||||||
|
Location spawnPoint = UtilWorld.averageLocation(GetTeamList().get(0).GetSpawns());
|
||||||
|
|
||||||
|
// Chests
|
||||||
|
System.out.println("Chests: " + Math.min(250, chests.size()));
|
||||||
|
for (int i = 0; i < 250 && !chests.isEmpty(); i++)
|
||||||
|
{
|
||||||
|
Location loc = chests.remove(UtilMath.r(chests.size()));
|
||||||
|
|
||||||
|
fillWithLoot(loc.getBlock());
|
||||||
|
if (UtilMath.offset2d(loc, spawnPoint) < 8)
|
||||||
|
spawn++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Location loc : chests)
|
||||||
|
{
|
||||||
|
if (spawn < 10 && UtilMath.offset(loc, spawnPoint) < 8)
|
||||||
|
{
|
||||||
|
spawn++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
loc.getBlock().setType(Material.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createLoot()
|
||||||
|
{
|
||||||
|
for (SpellType spellType : SpellType.values())
|
||||||
|
{
|
||||||
|
for (int i = 0; i < spellType.getItemAmount(); i++)
|
||||||
|
{
|
||||||
|
_randomItems.add(new HashMap.SimpleEntry(spellType.getSpellBook(this), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
_randomItems.add(new HashMap.SimpleEntry(makeUnusedWand(), 0));
|
||||||
|
// TODO Handle looting of spell wands
|
||||||
|
}
|
||||||
|
|
||||||
|
addRandomItem(5, Material.RAW_FISH, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.RAW_BEEF, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.RAW_CHICKEN, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.POTATO_ITEM, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.CARROT_ITEM, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.WHEAT, 0, 1, 2);
|
||||||
|
addRandomItem(1, Material.TNT, 0, 1, 1);
|
||||||
|
// Below is cocoa beans
|
||||||
|
addRandomItem(5, Material.INK_SACK, 3, 1, 2);
|
||||||
|
addRandomItem(5, Material.ROTTEN_FLESH, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.STICK, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.WOOD, 0, 1, 10);
|
||||||
|
addRandomItem(5, Material.WOOD_AXE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.STONE_AXE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.BOAT, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.FLINT, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.FEATHER, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.GOLD_INGOT, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.SHEARS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.LEATHER_BOOTS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.LEATHER_CHESTPLATE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.LEATHER_HELMET, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.LEATHER_LEGGINGS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.CHAINMAIL_BOOTS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.CHAINMAIL_CHESTPLATE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.CHAINMAIL_HELMET, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.CHAINMAIL_LEGGINGS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.FISHING_ROD, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.BOW, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.ARROW, 0, 1, 5);
|
||||||
|
addRandomItem(5, Material.SNOW_BALL, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.EGG, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.PORK, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.BAKED_POTATO, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.CAKE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.COOKED_BEEF, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.COOKED_CHICKEN, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.COOKED_FISH, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.GRILLED_PORK, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.COOKIE, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.PUMPKIN_PIE, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.APPLE, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.BOWL, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.IRON_INGOT, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.DIAMOND, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.EXP_BOTTLE, 0, 1, 2);
|
||||||
|
addRandomItem(5, Material.IRON_BOOTS, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.IRON_CHESTPLATE, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.IRON_HELMET, 0, 1, 1);
|
||||||
|
addRandomItem(5, Material.IRON_LEGGINGS, 0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onGameEnd(GameStateChangeEvent event)
|
public void CreateRandomChests(GameStateChangeEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetState() == GameState.End || event.GetState() == GameState.Dead)
|
if (event.GetState() != GameState.Recruit)
|
||||||
{
|
return;
|
||||||
HandlerList.unregisterAll(_wizard);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
HashSet<Material> ignore = new HashSet<Material>();
|
||||||
public void onSecond(UpdateEvent event)
|
|
||||||
{
|
|
||||||
if ((event.getType() == UpdateType.TICK) && GetState() == GameState.Live)
|
|
||||||
{
|
|
||||||
Iterator<Entry<String, Wizard>> itel = _wizards.entrySet().iterator();
|
|
||||||
|
|
||||||
while (itel.hasNext())
|
ignore.add(Material.LEAVES);
|
||||||
{
|
|
||||||
Entry<String, Wizard> entry = itel.next();
|
|
||||||
Player player = Bukkit.getPlayerExact(entry.getKey());
|
|
||||||
|
|
||||||
Wizard wizard = _wizards.get(player.getName());
|
int xDiff = WorldData.MaxX - WorldData.MinX;
|
||||||
wizard.mana += wizard.manaPerTick;
|
int zDiff = WorldData.MaxZ - WorldData.MinZ;
|
||||||
displayBossbar(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
int done = 0;
|
||||||
public void onSwapItem(PlayerItemHeldEvent event)
|
|
||||||
{
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
ItemStack item = p.getItemInHand();
|
|
||||||
|
|
||||||
if (item != null && item.getType() == Material.BLAZE_ROD && item.getItemMeta().hasDisplayName() && IsAlive(p))
|
while (done < 40)
|
||||||
{
|
{
|
||||||
displayBossbar(p);
|
|
||||||
|
Block block = UtilBlock.getHighest(WorldData.World, WorldData.MinX + UtilMath.r(xDiff),
|
||||||
|
WorldData.MinZ + UtilMath.r(zDiff), ignore);
|
||||||
|
|
||||||
|
if (!UtilBlock.airFoliage(block) || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
block.setTypeIdAndData(54, (byte) UtilMath.r(4), true);
|
||||||
|
fillWithLoot(block);
|
||||||
|
done++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayBossbar(Player player)
|
void displayBossbar(Player player)
|
||||||
|
{
|
||||||
|
Wizard wizard = _wizards.get(player.getName());
|
||||||
|
|
||||||
|
if (wizard != null)
|
||||||
{
|
{
|
||||||
ItemStack item = player.getItemInHand();
|
ItemStack item = player.getItemInHand();
|
||||||
|
|
||||||
|
UtilTextTop.displayTextBar(
|
||||||
|
player,
|
||||||
|
Math.min(1, wizard.getMana() / wizard.getMaxMana()),
|
||||||
|
(int) Math.floor(wizard.getMana()) + "/" + (int) wizard.getMaxMana() + " mana "
|
||||||
|
+ UtilTime.convert((int) (wizard.getManaPerTick() * 20000), 1, TimeUnit.SECONDS) + "mps");
|
||||||
|
|
||||||
if (item != null && item.getType() == Material.BLAZE_ROD && item.getItemMeta().hasDisplayName())
|
if (item != null && item.getType() == Material.BLAZE_ROD && item.getItemMeta().hasDisplayName())
|
||||||
{
|
{
|
||||||
|
|
||||||
SpellType type = getSpell(item.getItemMeta().getDisplayName());
|
SpellType type = getSpell(item.getItemMeta().getDisplayName());
|
||||||
|
|
||||||
if (type != null)
|
if (type != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
Wizard wizard = _wizards.get(player.getName());
|
int spellLevel = wizard.getSpellLevel(type);
|
||||||
int spellLevel = wizard.knownSpells.get(type);
|
|
||||||
|
|
||||||
String display = ChatColor.DARK_PURPLE + "Spell: " + ChatColor.RESET + type.getElement().getColor()
|
|
||||||
+ type.get_spellName() + ChatColor.RESET + ChatColor.BOLD + " :" + ChatColor.RESET + ChatColor.DARK_AQUA
|
|
||||||
+ " Mana: " + ChatColor.RESET + type.getManaCost(spellLevel) + ChatColor.RESET + ChatColor.BOLD + " :";
|
|
||||||
|
|
||||||
double usableTime = 0;// Time in seconds till usable
|
double usableTime = 0;// Time in seconds till usable
|
||||||
|
|
||||||
if (wizard.mana < type.getManaCost(spellLevel))
|
if (wizard.getMana() < type.getManaCost(spellLevel))
|
||||||
{
|
{
|
||||||
usableTime = (type.getManaCost(spellLevel) - wizard.mana) / (20 * wizard.manaPerTick);
|
usableTime = (type.getManaCost(spellLevel) - wizard.getMana()) / (20 * wizard.getManaPerTick());
|
||||||
}
|
}
|
||||||
|
|
||||||
double cooldown = wizard.cooldowns.containsKey(type) ? (double) (wizard.cooldowns.get(type) - System
|
double cooldown = wizard.getCooldown(type) != 0 ? (double) (wizard.getCooldown(type) - System
|
||||||
.currentTimeMillis()) / 1000D : 0;
|
.currentTimeMillis()) / 1000D : 0;
|
||||||
|
|
||||||
if (cooldown > 0 && cooldown > usableTime)
|
if (cooldown > 0 && cooldown > usableTime)
|
||||||
@ -171,86 +308,116 @@ public class WizardBattles extends SoloGame
|
|||||||
usableTime = cooldown;
|
usableTime = cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double maxSeconds = Math.max(type.getSpellCooldown(spellLevel),
|
||||||
|
type.getManaCost(spellLevel) / (wizard.getManaPerTick() * 20));
|
||||||
|
|
||||||
if (usableTime > 0)
|
if (usableTime > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
display += ChatColor.RED + " Usable in "
|
UtilTextBottom.displayProgress(type.getElement().getColor() + type.getSpellName(),
|
||||||
+ UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT);
|
1f - (usableTime / maxSeconds),
|
||||||
|
UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT), player);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
String display = type.getElement().getColor() + type.getSpellName() + ChatColor.RESET + ChatColor.BOLD
|
||||||
|
|
||||||
|
+ " :" + ChatColor.RESET + ChatColor.DARK_AQUA
|
||||||
|
|
||||||
|
+ " Mana: " + ChatColor.RESET + type.getManaCost(spellLevel) + ChatColor.RESET + ChatColor.BOLD
|
||||||
|
|
||||||
|
+ " : " + ChatColor.RED
|
||||||
|
|
||||||
|
+ "Cooldown: " + ChatColor.RESET
|
||||||
|
|
||||||
display += ChatColor.RED + " Cooldown: " + ChatColor.RESET
|
|
||||||
+ UtilTime.convertString((long) (type.getSpellCooldown(spellLevel) * 1000), 0, TimeUnit.FIT);
|
+ UtilTime.convertString((long) (type.getSpellCooldown(spellLevel) * 1000), 0, TimeUnit.FIT);
|
||||||
|
|
||||||
|
UtilTextBottom.display(display, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double maxSeconds = Math.max(type.getSpellCooldown(spellLevel), type.getManaCost(spellLevel)
|
|
||||||
/ (wizard.manaPerTick * 20));
|
|
||||||
UtilTextTop.displayTextBar(player, 1f - (usableTime / maxSeconds), display);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
private void dropSpells(Player player)
|
||||||
public void onDeath(PlayerDeathEvent event)
|
|
||||||
{
|
{
|
||||||
_wizards.remove(event.getEntity().getName());
|
HashSet<SpellType> spells = new HashSet<SpellType>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
ItemStack item = player.getInventory().getItem(i);
|
||||||
|
if (item != null && item.getType() == Material.BLAZE_ROD)
|
||||||
|
{
|
||||||
|
SpellType type = getSpell(item.getItemMeta().getDisplayName());
|
||||||
|
if (type != null)
|
||||||
|
{
|
||||||
|
spells.add(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.getInventory().setItem(i, new ItemStack(Material.AIR));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
ArrayList<ItemStack> itemsToDrop = new ArrayList<ItemStack>();
|
||||||
public void onQuit(PlayerQuitEvent event)
|
|
||||||
|
for (SpellType type : spells)
|
||||||
{
|
{
|
||||||
_wizards.remove(event.getPlayer().getName());
|
itemsToDrop.add(type.getSpellBook(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
if (UtilMath.r(5) == 0)
|
||||||
public void onLive(GameStateChangeEvent event)
|
|
||||||
{
|
{
|
||||||
if (event.GetState() == GameState.Live)
|
itemsToDrop.add(makeUnusedWand());
|
||||||
{
|
|
||||||
for (Player player : GetPlayers(true))
|
|
||||||
{
|
|
||||||
_wizards.put(player.getName(), new Wizard());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.shuffle(itemsToDrop, new Random());
|
||||||
|
|
||||||
|
double beginnerAngle = Math.random() * 360;
|
||||||
|
|
||||||
|
for (SpellType type : spells)
|
||||||
|
{
|
||||||
|
Item item = player.getWorld().dropItem(player.getLocation(), type.getSpellBook(this));
|
||||||
|
item.setPickupDelay(60);
|
||||||
|
|
||||||
|
beginnerAngle += 360D / spells.size();
|
||||||
|
double angle = ((2 * Math.PI) / 360) * beginnerAngle % 360;
|
||||||
|
double x = 0.5 * Math.cos(angle);
|
||||||
|
double z = 0.5 * Math.sin(angle);
|
||||||
|
|
||||||
|
item.setVelocity(new Vector(x, 0.5, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
private void fillWithLoot(Block block)
|
||||||
public void onEndOrPrepare(GameStateChangeEvent event)
|
|
||||||
{
|
{
|
||||||
if (event.GetState() == GameState.Live)
|
BlockState state = block.getState();
|
||||||
|
if (state instanceof InventoryHolder)
|
||||||
{
|
{
|
||||||
for (SpellType spells : SpellType.values())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Spell spell = spells.get_spellClass().newInstance();
|
|
||||||
|
|
||||||
if (!(spell instanceof SpellRightClick || spell instanceof SpellRightClickBlock || spell instanceof SpellRightClickEntity))
|
InventoryHolder holder = (InventoryHolder) state;
|
||||||
throw new Exception(spells.get_spellName() + "'s spell class doesn't extend a spell interface");
|
Inventory inv = holder.getInventory();
|
||||||
|
boolean addedSpell = false;
|
||||||
spell.spell = spells;
|
for (int i = 0; i < 5; i++)
|
||||||
spell.wizards = this;
|
|
||||||
|
|
||||||
_spells.put(spells, spell);
|
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(spell, getArcadeManager().GetPlugin());
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
Entry<ItemStack, Integer> entry = _randomItems.get(UtilMath.r(_randomItems.size()));
|
||||||
}
|
ItemStack item = entry.getKey().clone();
|
||||||
}
|
|
||||||
}
|
// Don't allow 2 books in one chest, else I'd have to do better code to display learned spells after the previous
|
||||||
else if (event.GetState() == GameState.Dead || event.GetState() == GameState.End)
|
// expired.
|
||||||
|
if (item.getType() == Material.ENCHANTED_BOOK)
|
||||||
{
|
{
|
||||||
for (Spell spell : _spells.values())
|
if (addedSpell)
|
||||||
{
|
{
|
||||||
HandlerList.unregisterAll(spell);
|
i--;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
_spells.clear();
|
addedSpell = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.setAmount(item.getAmount() + UtilMath.r(entry.getValue() + 1));
|
||||||
|
inv.setItem(UtilMath.r(inv.getSize()), item);
|
||||||
|
}
|
||||||
|
state.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,16 +427,25 @@ public class WizardBattles extends SoloGame
|
|||||||
|
|
||||||
for (SpellType spell : SpellType.values())
|
for (SpellType spell : SpellType.values())
|
||||||
{
|
{
|
||||||
if (spell.get_spellName().equals(title))
|
if (spell.getSpellName().equals(title))
|
||||||
return spell;
|
return spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInteractEntity(PlayerInteractEntityEvent event)
|
public Wizard getWizard(org.bukkit.entity.Player player)
|
||||||
{
|
{
|
||||||
onCastSpell(event.getPlayer(), event.getRightClicked());
|
return _wizards.get(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack makeUnusedWand()
|
||||||
|
{
|
||||||
|
ItemBuilder builder = new ItemBuilder(Material.BLAZE_ROD);
|
||||||
|
builder.setTitle(ChatColor.WHITE + "Spell Wand" + buildTime());
|
||||||
|
builder.addLore(C.cGreen + C.Bold + "LEFT CLICK" + C.cBlue + " Open Spellbook", C.cPurple + C.Bold + "RIGHT CLICK"
|
||||||
|
+ C.cDGreen + " Cast spell");
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCastSpell(Player player, Object obj)
|
private void onCastSpell(Player player, Object obj)
|
||||||
@ -277,7 +453,7 @@ public class WizardBattles extends SoloGame
|
|||||||
ItemStack item = player.getItemInHand();
|
ItemStack item = player.getItemInHand();
|
||||||
|
|
||||||
if (GetState() == GameState.Live && IsAlive(player) && item != null && item.getType() == Material.BLAZE_ROD
|
if (GetState() == GameState.Live && IsAlive(player) && item != null && item.getType() == Material.BLAZE_ROD
|
||||||
&& item.getItemMeta().hasDisplayName())
|
&& item.getItemMeta().hasDisplayName() && player.getInventory().getHeldItemSlot() < 5)
|
||||||
{
|
{
|
||||||
|
|
||||||
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
||||||
@ -285,14 +461,14 @@ public class WizardBattles extends SoloGame
|
|||||||
{
|
{
|
||||||
|
|
||||||
Wizard wizard = _wizards.get(player.getName());
|
Wizard wizard = _wizards.get(player.getName());
|
||||||
if (wizard.knownSpells.containsKey(spell))
|
int spellLevel = wizard.getSpellLevel(spell);
|
||||||
|
if (spellLevel > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
int spellLevel = wizard.knownSpells.get(spell);
|
if (wizard.getMana() >= spell.getManaCost(spellLevel))
|
||||||
if (wizard.mana >= spell.getManaCost(spellLevel))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((wizard.cooldowns.containsKey(spell) ? wizard.cooldowns.get(spell) : 0) < System.currentTimeMillis())
|
if (wizard.getCooldown(spell) < System.currentTimeMillis())
|
||||||
{
|
{
|
||||||
|
|
||||||
Spell sp = _spells.get(spell);
|
Spell sp = _spells.get(spell);
|
||||||
@ -325,13 +501,182 @@ public class WizardBattles extends SoloGame
|
|||||||
player.sendMessage(ChatColor.BLUE + "You do not have enough mana!");
|
player.sendMessage(ChatColor.BLUE + "You do not have enough mana!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClick(InventoryClickEvent event)
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.BLUE + "You do not know that spell!");
|
ItemStack item = event.getCurrentItem();
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
Player p = (Player) event.getWhoClicked();
|
||||||
|
|
||||||
|
if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (item != null && item.getType() == Material.ENCHANTED_BOOK && item.getItemMeta().hasDisplayName())
|
||||||
|
{
|
||||||
|
|
||||||
|
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
||||||
|
if (spell != null)
|
||||||
|
{
|
||||||
|
if (onSpellLearn(p, spell))
|
||||||
|
{
|
||||||
|
event.setCurrentItem(new ItemStack(Material.AIR));
|
||||||
|
_learnedSpellChests.put(p.getName(), spell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() == Material.BLAZE_ROD
|
||||||
|
&& (event.getClickedInventory().getType() != InventoryType.PLAYER || event.getSlot() > 4))
|
||||||
|
{
|
||||||
|
|
||||||
|
int slot = p.getInventory().first(Material.STAINED_GLASS_PANE);
|
||||||
|
|
||||||
|
if (slot >= 0 && slot < 5)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
p.getInventory().setItem(slot, item);
|
||||||
|
event.setCurrentItem(new ItemStack(Material.AIR));
|
||||||
|
|
||||||
|
p.updateInventory();
|
||||||
|
UtilTextMiddle.display("", C.cGold + "Gained a wand", p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onClose(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
Player p = (Player) event.getPlayer();
|
||||||
|
if (IsAlive(p) && _learnedSpellChests.containsKey(p.getName()))
|
||||||
|
{
|
||||||
|
SpellType spell = _learnedSpellChests.remove(p.getName());
|
||||||
|
|
||||||
|
Wizard wizard = getWizard(p);
|
||||||
|
UtilTextMiddle.display(null,
|
||||||
|
spell.getElement().getColor() + spell.getSpellName() + " " + wizard.getSpellLevel(spell), 5, 40, 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
if (IsAlive(event.getEntity()))
|
||||||
|
{
|
||||||
|
dropSpells(event.getEntity());
|
||||||
|
}
|
||||||
|
_wizards.remove(event.getEntity().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDropItem(ItemSpawnEvent event)
|
||||||
|
{
|
||||||
|
ItemStack item = event.getEntity().getItemStack();
|
||||||
|
|
||||||
|
if (item.getType() == Material.ENCHANTED_BOOK && item.getItemMeta().hasDisplayName())
|
||||||
|
{
|
||||||
|
|
||||||
|
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
||||||
|
|
||||||
|
if (spell != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
Hologram holo = new Hologram(getArcadeManager().getHologramManager(),
|
||||||
|
|
||||||
|
event.getEntity().getLocation().add(0, 1, 0),
|
||||||
|
|
||||||
|
C.cDPurple + C.Bold + "Spellbook",
|
||||||
|
|
||||||
|
spell.getElement().getColor() + spell.getSpellName());
|
||||||
|
|
||||||
|
holo.setFollowEntity(event.getEntity());
|
||||||
|
|
||||||
|
holo.setRemoveOnEntityDeath();
|
||||||
|
|
||||||
|
holo.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.getType() == Material.BLAZE_ROD)
|
||||||
|
{
|
||||||
|
|
||||||
|
Hologram holo = new Hologram(getArcadeManager().getHologramManager(),
|
||||||
|
|
||||||
|
event.getEntity().getLocation().add(0, 1, 0),
|
||||||
|
|
||||||
|
C.Bold + "Spell Wand");
|
||||||
|
|
||||||
|
holo.setFollowEntity(event.getEntity());
|
||||||
|
|
||||||
|
holo.setRemoveOnEntityDeath();
|
||||||
|
|
||||||
|
holo.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().getInventory().getHeldItemSlot() < 5)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEndOrPrepare(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() == GameState.Live)
|
||||||
|
{
|
||||||
|
for (SpellType spells : SpellType.values())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Spell spell = spells.getSpellClass().newInstance();
|
||||||
|
|
||||||
|
if (!(spell instanceof SpellRightClick || spell instanceof SpellRightClickBlock || spell instanceof SpellRightClickEntity))
|
||||||
|
throw new IllegalClassException(spells.getSpellName() + "'s spell class doesn't extend a spell interface");
|
||||||
|
|
||||||
|
spell.setSpellType(spells);
|
||||||
|
spell.Wizards = this;
|
||||||
|
|
||||||
|
_spells.put(spells, spell);
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().registerEvents(spell, getArcadeManager().GetPlugin());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.GetState() == GameState.Dead || event.GetState() == GameState.End)
|
||||||
|
{
|
||||||
|
for (Spell spell : _spells.values())
|
||||||
|
{
|
||||||
|
HandlerList.unregisterAll(spell);
|
||||||
|
}
|
||||||
|
_spells.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onGameEnd(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() == GameState.End || event.GetState() == GameState.Dead)
|
||||||
|
{
|
||||||
|
HandlerList.unregisterAll(_wizard);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -351,20 +696,107 @@ public class WizardBattles extends SoloGame
|
|||||||
onCastSpell(p, event.getClickedBlock());
|
onCastSpell(p, event.getClickedBlock());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onInteractEntity(PlayerInteractEntityEvent event)
|
||||||
|
{
|
||||||
|
onCastSpell(event.getPlayer(), event.getRightClicked());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onItemClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
if (event.getSlot() >= 0 && event.getClickedInventory().getType() == InventoryType.PLAYER && event.getSlot() < 5)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLive(GameStateChangeEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetState() == GameState.Live)
|
||||||
|
{
|
||||||
|
for (Player player : GetPlayers(true))
|
||||||
|
{
|
||||||
|
_wizards.put(player.getName(), new Wizard(100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPickup(PlayerPickupItemEvent event)
|
||||||
|
{
|
||||||
|
ItemStack item = event.getItem().getItemStack();
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
if (event.getItem().getItemStack().getType() == Material.BLAZE_ROD)
|
||||||
|
{
|
||||||
|
|
||||||
|
int slot = p.getInventory().first(Material.STAINED_GLASS_PANE);
|
||||||
|
|
||||||
|
if (slot >= 0 && slot < 5)
|
||||||
|
{
|
||||||
|
p.getInventory().remove(slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (item.getType() == Material.ENCHANTED_BOOK && item.getItemMeta().hasDisplayName())
|
else if (item.getType() == Material.ENCHANTED_BOOK && item.getItemMeta().hasDisplayName())
|
||||||
{
|
{
|
||||||
|
|
||||||
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
||||||
|
|
||||||
if (spell != null)
|
if (spell != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (onSpellLearn(p, spell))
|
if (onSpellLearn(p, spell))
|
||||||
{
|
{
|
||||||
p.setItemInHand(new ItemStack(Material.AIR));
|
Wizard wizard = getWizard(p);
|
||||||
|
UtilTextMiddle.display(null,
|
||||||
|
spell.getElement().getColor() + spell.getSpellName() + " " + wizard.getSpellLevel(spell), 5, 40, 5);
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getItem().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
if (IsAlive(event.getPlayer()))
|
||||||
|
{
|
||||||
|
dropSpells(event.getPlayer());
|
||||||
|
}
|
||||||
|
_wizards.remove(event.getPlayer().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSecond(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if ((event.getType() == UpdateType.TICK) && GetState() == GameState.Live)
|
||||||
|
{
|
||||||
|
Iterator<Entry<String, Wizard>> itel = _wizards.entrySet().iterator();
|
||||||
|
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
Entry<String, Wizard> entry = itel.next();
|
||||||
|
Player player = Bukkit.getPlayerExact(entry.getKey());
|
||||||
|
|
||||||
|
Wizard wizard = _wizards.get(player.getName());
|
||||||
|
float newMana = wizard.getMana();
|
||||||
|
|
||||||
|
if (newMana < wizard.getMaxMana())
|
||||||
|
{
|
||||||
|
newMana = Math.min(newMana + wizard.getManaPerTick(), wizard.getMaxMana());
|
||||||
|
wizard.setMana(newMana);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayBossbar(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,106 +804,40 @@ public class WizardBattles extends SoloGame
|
|||||||
{
|
{
|
||||||
Wizard wiz = _wizards.get(p.getName());
|
Wizard wiz = _wizards.get(p.getName());
|
||||||
|
|
||||||
if (!wiz.knownSpells.containsKey(spell) || wiz.knownSpells.get(spell) < spell.get_maxLevel())
|
int spellLevel = wiz.getSpellLevel(spell);
|
||||||
|
if (spellLevel < spell.getMaxLevel())
|
||||||
{
|
{
|
||||||
|
wiz.learnSpell(spell);
|
||||||
if (!wiz.knownSpells.containsKey(spell))
|
|
||||||
{
|
|
||||||
|
|
||||||
p.sendMessage(ChatColor.GREEN + "You have learned the spell " + spell.getElement().getColor()
|
|
||||||
+ spell.get_spellName());
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
p.sendMessage(ChatColor.GREEN + "You have leveled up the spell " + spell.getElement().getColor()
|
|
||||||
+ spell.get_spellName() + ChatColor.GREEN + " to level " + ChatColor.BOLD
|
|
||||||
+ (wiz.knownSpells.get(spell) + 1));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wiz.knownSpells.put(spell, (wiz.knownSpells.containsKey(spell) ? wiz.knownSpells.get(spell) : 0) + 1);
|
|
||||||
|
|
||||||
if (wiz.knownSpells.get(spell) >= spell.get_maxLevel())
|
|
||||||
{
|
|
||||||
|
|
||||||
p.sendMessage(ChatColor.GREEN + "The spell has just reached the max level!");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(InventoryClickEvent event)
|
public void onSwapItem(PlayerItemHeldEvent event)
|
||||||
{
|
|
||||||
if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest)
|
|
||||||
{
|
{
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
ItemStack item = p.getItemInHand();
|
||||||
|
|
||||||
ItemStack item = event.getCurrentItem();
|
if (item != null && item.getType() == Material.BLAZE_ROD && item.getItemMeta().hasDisplayName() && IsAlive(p))
|
||||||
Player p = (Player) event.getWhoClicked();
|
|
||||||
|
|
||||||
if (item != null && item.getType() == Material.ENCHANTED_BOOK && item.getItemMeta().hasDisplayName())
|
|
||||||
{
|
{
|
||||||
|
displayBossbar(p);
|
||||||
SpellType spell = getSpell(item.getItemMeta().getDisplayName());
|
|
||||||
if (spell != null)
|
|
||||||
{
|
|
||||||
if (onSpellLearn(p, spell))
|
|
||||||
{
|
|
||||||
event.setCurrentItem(new ItemStack(Material.AIR));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onGameState(GameStateChangeEvent event)
|
public void onUnplaceablePlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.GetState() == GameState.Prepare)
|
if (event.getPlayer().getInventory().getHeldItemSlot() < 5)
|
||||||
{
|
{
|
||||||
for (Location chestLoc : WorldData.GetCustomLocs("54"))
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
|
|
||||||
BlockState state = chestLoc.getBlock().getState();
|
|
||||||
if (state instanceof InventoryHolder)
|
|
||||||
{
|
|
||||||
|
|
||||||
InventoryHolder holder = (InventoryHolder) state;
|
|
||||||
Inventory inv = holder.getInventory();
|
|
||||||
for (int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
SpellType spell = SpellType.values()[new Random().nextInt(SpellType.values().length)];
|
|
||||||
|
|
||||||
if (spell.hasChanceToFind())
|
|
||||||
{
|
|
||||||
inv.setItem(
|
|
||||||
new Random().nextInt(inv.getSize()),
|
|
||||||
|
|
||||||
spell.makeSpell(
|
|
||||||
this,
|
|
||||||
new ItemBuilder(Material.ENCHANTED_BOOK).addLore(
|
|
||||||
C.cGreen + C.Italics + "Learn the spell " + spell.get_spellName())
|
|
||||||
|
|
||||||
.build()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Wizard getWizard(org.bukkit.entity.Player player)
|
@Override
|
||||||
|
public void ParseData()
|
||||||
{
|
{
|
||||||
return _wizards.get(player.getName());
|
CreateChestCraftEnchant();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
public class WizardSpellMenu extends MiniPlugin
|
public class WizardSpellMenu extends MiniPlugin
|
||||||
{
|
{
|
||||||
private WizardSpellMenuShop _wizardShop;
|
|
||||||
private WizardBattles _wizards;
|
private WizardBattles _wizards;
|
||||||
|
private WizardSpellMenuShop _wizardShop;
|
||||||
|
|
||||||
public WizardSpellMenu(String moduleName, JavaPlugin plugin, WizardBattles wizards)
|
public WizardSpellMenu(String moduleName, JavaPlugin plugin, WizardBattles wizards)
|
||||||
{
|
{
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards;
|
package nautilus.game.arcade.game.games.wizards.kit;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.itemstack.ItemBuilder;
|
import mineplex.core.itemstack.ItemBuilder;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.WizardBattles;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
import nautilus.game.arcade.kit.KitAvailability;
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
import nautilus.game.arcade.kit.Perk;
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -25,16 +26,24 @@ public class KitWizard extends Kit
|
|||||||
@Override
|
@Override
|
||||||
public void GiveItems(Player player)
|
public void GiveItems(Player player)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
ItemBuilder builder = new ItemBuilder(Material.BLAZE_ROD);
|
if (i < 3)
|
||||||
String s = "";
|
|
||||||
for (char c : ("" + System.nanoTime()).toCharArray())
|
|
||||||
{
|
{
|
||||||
s += "§" + c;
|
player.getInventory().addItem(((WizardBattles) Manager.GetGame()).makeUnusedWand());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.getInventory().addItem(
|
||||||
|
|
||||||
|
new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 8)
|
||||||
|
|
||||||
|
.setTitle(C.cGray + "Empty wand slot" + ((WizardBattles) Manager.GetGame()).buildTime())
|
||||||
|
|
||||||
|
.addLore(C.cGray + C.Italics + "Wands can be found in chests and on dead players")
|
||||||
|
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
builder.setTitle(ChatColor.WHITE + "Unused Wand" + s);
|
|
||||||
player.getInventory().addItem(builder.build());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spellinterfaces;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface SpellRightClick
|
||||||
|
{
|
||||||
|
public void castSpell(Player player);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spellinterfaces;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface SpellRightClickBlock
|
||||||
|
{
|
||||||
|
public void castSpell(Player player, Block block);
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spellinterfaces;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface SpellRightClickEntity
|
||||||
|
{
|
||||||
|
public void castSpell(Player player, Entity entity);
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilShapes;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickBlock;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class SpellBridge extends Spell implements SpellRightClickBlock
|
||||||
|
{
|
||||||
|
final BlockFace[] radial =
|
||||||
|
{
|
||||||
|
BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH,
|
||||||
|
BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p, final Block target)
|
||||||
|
{
|
||||||
|
final BlockFace facing = radial[Math.round(p.getEyeLocation().getYaw() / 45f) & 0x7];
|
||||||
|
|
||||||
|
p.getWorld().playEffect(target.getLocation(), Effect.STEP_SOUND, Material.DIRT.getId());
|
||||||
|
|
||||||
|
final int maxDist = 10 * getSpellLevel(p);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
Block block = target;
|
||||||
|
int blocks = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!Wizards.IsLive() || blocks++ >= maxDist)
|
||||||
|
{
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = block.getRelative(facing);
|
||||||
|
Block bs[] = UtilShapes.getSideBlocks(block, facing);
|
||||||
|
|
||||||
|
bs = new Block[]
|
||||||
|
{
|
||||||
|
bs[0], bs[1], block
|
||||||
|
};
|
||||||
|
|
||||||
|
for (Block b : bs)
|
||||||
|
{
|
||||||
|
if (UtilBlock.solid(b))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
b.setType(Material.DIRT);
|
||||||
|
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getTypeId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}.runTaskTimer(Wizards.getArcadeManager().GetPlugin(), 5, 1);
|
||||||
|
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Wizard;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickEntity;
|
||||||
|
|
||||||
|
public class SpellDrain extends Spell implements SpellRightClickEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player player, Entity entity)
|
||||||
|
{
|
||||||
|
if (entity instanceof Player)
|
||||||
|
{
|
||||||
|
if (Wizards.IsAlive(entity))
|
||||||
|
{
|
||||||
|
|
||||||
|
Wizard wiz = Wizards.getWizard((Player) entity);
|
||||||
|
float leftoverMana = wiz.getMana();
|
||||||
|
|
||||||
|
if (leftoverMana > 10)
|
||||||
|
{
|
||||||
|
float toDrain = Math.min(getSpellLevel(player) * 40, leftoverMana);
|
||||||
|
leftoverMana = Math.max(0, leftoverMana - getSpellLevel(player) * 40);
|
||||||
|
wiz.setMana(leftoverMana);
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.WITHER_SPAWN, 1, 0);
|
||||||
|
|
||||||
|
Wizard wizard = Wizards.getWizard(player);
|
||||||
|
|
||||||
|
wizard.setMana(Math.min(wizard.getMaxMana(), wizard.getMana() + (toDrain / 3)));
|
||||||
|
|
||||||
|
player.sendMessage(C.cGold + "Drained " + (int) (toDrain / 3) + " mana");
|
||||||
|
|
||||||
|
charge(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -18,7 +18,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
public class Droom extends Spell implements SpellRightClick
|
public class SpellDroom extends Spell implements SpellRightClick
|
||||||
{
|
{
|
||||||
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
private ArrayList<FallingBlock> _fallingBlocks = new ArrayList<FallingBlock>();
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public class Droom extends Spell implements SpellRightClick
|
|||||||
|
|
||||||
for (Entity entity : player.getNearbyEntities(radius, radius * 3, radius))
|
for (Entity entity : player.getNearbyEntities(radius, radius * 3, radius))
|
||||||
{
|
{
|
||||||
if (entity instanceof Player && wizards.IsAlive(entity))
|
if (entity instanceof Player && Wizards.IsAlive(entity))
|
||||||
{
|
{
|
||||||
players.add((Player) entity);
|
players.add((Player) entity);
|
||||||
}
|
}
|
||||||
@ -54,9 +54,9 @@ public class Droom extends Spell implements SpellRightClick
|
|||||||
|
|
||||||
FallingBlock anvil = p.getWorld().spawnFallingBlock(loc.getBlock().getLocation().add(0.5, 0.5, 0.5),
|
FallingBlock anvil = p.getWorld().spawnFallingBlock(loc.getBlock().getLocation().add(0.5, 0.5, 0.5),
|
||||||
Material.ANVIL, (byte) 0);
|
Material.ANVIL, (byte) 0);
|
||||||
anvil.setMetadata("ExplosionSize", new FixedMetadataValue(wizards.getArcadeManager().GetPlugin(),
|
anvil.setMetadata("ExplosionSize", new FixedMetadataValue(Wizards.getArcadeManager().GetPlugin(),
|
||||||
1 + (getSpellLevel(player) / 2F)));
|
1 + (getSpellLevel(player) / 2F)));
|
||||||
anvil.setMetadata("Wizard", new FixedMetadataValue(wizards.getArcadeManager().GetPlugin(), player));
|
anvil.setMetadata("Wizard", new FixedMetadataValue(Wizards.getArcadeManager().GetPlugin(), player));
|
||||||
anvil.getWorld().playSound(anvil.getLocation(), Sound.ANVIL_USE, 2, 0);
|
anvil.getWorld().playSound(anvil.getLocation(), Sound.ANVIL_USE, 2, 0);
|
||||||
newFallingBlocks.add(anvil);
|
newFallingBlocks.add(anvil);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class Droom extends Spell implements SpellRightClick
|
|||||||
{
|
{
|
||||||
_fallingBlocks.remove(entity);
|
_fallingBlocks.remove(entity);
|
||||||
|
|
||||||
new CustomExplosion(wizards.getArcadeManager().GetDamage(), entity.getLocation(), (float) entity
|
new CustomExplosion(Wizards.getArcadeManager().GetDamage(), entity.getLocation(), (float) entity
|
||||||
.getMetadata("ExplosionSize").get(0).asDouble(), (Player) entity.getMetadata("Wizard").get(0).value(), "Droom",
|
.getMetadata("ExplosionSize").get(0).asDouble(), (Player) entity.getMetadata("Wizard").get(0).value(), "Droom",
|
||||||
true);
|
true);
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
public class SpellFireball extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHit(ProjectileHitEvent event)
|
||||||
|
{
|
||||||
|
Projectile projectile = event.getEntity();
|
||||||
|
if (projectile.hasMetadata("FireballSpell"))
|
||||||
|
{
|
||||||
|
projectile.remove();
|
||||||
|
new CustomExplosion(Wizards.getArcadeManager().GetDamage(), projectile.getLocation(),
|
||||||
|
((org.bukkit.entity.Fireball) projectile).getYield(), (Player) projectile.getMetadata("FireballSpell").get(0)
|
||||||
|
.value(), "Fireball", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p)
|
||||||
|
{
|
||||||
|
org.bukkit.entity.Fireball fireball = (org.bukkit.entity.Fireball) p.getWorld().spawnEntity(p.getEyeLocation(),
|
||||||
|
EntityType.FIREBALL);
|
||||||
|
fireball.setVelocity(p.getEyeLocation().getDirection());
|
||||||
|
fireball.setShooter(p);
|
||||||
|
p.getWorld().playSound(p.getLocation(), Sound.BLAZE_BREATH, 0.5F, 5F);
|
||||||
|
fireball.setYield(getSpellLevel(p) * 0.8F);
|
||||||
|
fireball.setMetadata("FireballSpell", new FixedMetadataValue(Wizards.getArcadeManager().GetPlugin(), p));
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SpellFlash extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player player)
|
||||||
|
{
|
||||||
|
int maxTeleportDistance = 20 + (10 * getSpellLevel(player));
|
||||||
|
|
||||||
|
List<Block> list = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, maxTeleportDistance);
|
||||||
|
|
||||||
|
if (list.size() > 1 && list.get(1).getType() != Material.AIR)
|
||||||
|
{
|
||||||
|
Block b = list.get(0);
|
||||||
|
|
||||||
|
if (b.getLocation().distance(player.getLocation()) > 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
Location loc = b.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F);
|
||||||
|
player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9);
|
||||||
|
|
||||||
|
player.setFallDistance(0);
|
||||||
|
player.teleport(loc);
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1.2F);
|
||||||
|
player.getWorld().playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 9);
|
||||||
|
|
||||||
|
charge(player);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,15 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards.spells;
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClickEntity;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickEntity;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Heal extends Spell implements SpellRightClick, SpellRightClickEntity
|
public class SpellHeal extends Spell implements SpellRightClick, SpellRightClickEntity
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -0,0 +1,61 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.ContainerBlock;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
public class SpellImplode extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p)
|
||||||
|
{
|
||||||
|
List<Block> list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 50);
|
||||||
|
if (list.size() > 1)
|
||||||
|
{
|
||||||
|
BlockFace face = list.get(0).getFace(list.get(1));
|
||||||
|
Block b = list.get(0);
|
||||||
|
int maxDist = (int) Math.floor(b.getLocation().distance(p.getLocation().getBlock().getLocation())) / 2;
|
||||||
|
for (int i = 0; i < Math.min(maxDist, getSpellLevel(p) * 2); i++)
|
||||||
|
{
|
||||||
|
if (b.getRelative(face) != null)
|
||||||
|
b = b.getRelative(face);
|
||||||
|
}
|
||||||
|
if (b.getType() == Material.AIR)
|
||||||
|
return;
|
||||||
|
Location a1 = b.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
|
b.getWorld().playSound(b.getLocation(), Sound.ENDERDRAGON_GROWL, 1.5F, 1.5F);
|
||||||
|
for (int x = -getSpellLevel(p) * 2; x <= getSpellLevel(p) * 2; x++)
|
||||||
|
{
|
||||||
|
for (int y = -getSpellLevel(p); y <= getSpellLevel(p); y++)
|
||||||
|
{
|
||||||
|
for (int z = -getSpellLevel(p) * 2; z <= getSpellLevel(p) * 2; z++)
|
||||||
|
{
|
||||||
|
Block a = b.getRelative(x, y, z);
|
||||||
|
Location a2 = a.getLocation().clone().add(0.5, 0.5, 0.5);
|
||||||
|
if (a.getLocation().distance(b.getLocation()) <= getSpellLevel(p) * 2
|
||||||
|
&& !(a.getState() instanceof ContainerBlock))
|
||||||
|
{
|
||||||
|
FallingBlock block = a.getWorld().spawnFallingBlock(a.getLocation(), a.getType(), a.getData());
|
||||||
|
a.setType(Material.AIR);
|
||||||
|
block.setVelocity(a1.toVector().subtract(a2.toVector()).normalize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,9 +18,9 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
public class Lance extends Spell implements SpellRightClick
|
public class SpellLance extends Spell implements SpellRightClick
|
||||||
{
|
{
|
||||||
private ArrayList<Entry<ArrayList<Location>, Player>> _locations = new ArrayList<Entry<ArrayList<Location>, Player>>();
|
private ArrayList<Entry<ArrayList<Location>, Player>> _locations = new ArrayList<Entry<ArrayList<Location>, Player>>();
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public class Lance extends Spell implements SpellRightClick
|
|||||||
// {
|
// {
|
||||||
List<Block> b = player.getLastTwoTargetBlocks(UtilBlock.blockPassSet, 6 * getSpellLevel(player));
|
List<Block> b = player.getLastTwoTargetBlocks(UtilBlock.blockPassSet, 6 * getSpellLevel(player));
|
||||||
if (!b.isEmpty())
|
if (!b.isEmpty())
|
||||||
l = b.get(0).getLocation().add(0.5, 0.5, 0.5);
|
l = b.get(0).getLocation().add(0.5, 0.5, 0.5).add(player.getEyeLocation().getDirection().normalize().multiply(2));
|
||||||
/* }
|
/* }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -90,6 +90,6 @@ public class Lance extends Spell implements SpellRightClick
|
|||||||
|
|
||||||
private void explode(Location loc, Player player)
|
private void explode(Location loc, Player player)
|
||||||
{
|
{
|
||||||
new CustomExplosion(wizards.getArcadeManager().GetDamage(), loc, 1.2F, player, "Lance", false);
|
new CustomExplosion(Wizards.getArcadeManager().GetDamage(), loc, 1.2F, player, "Lance", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.LightningStrike;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
public class SpellLightningStrike extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p)
|
||||||
|
{
|
||||||
|
List<Block> list = p.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 150);
|
||||||
|
if (list.size() > 1)
|
||||||
|
{
|
||||||
|
LightningStrike lightning = p.getWorld().strikeLightning(
|
||||||
|
p.getWorld().getHighestBlockAt(list.get(0).getLocation()).getLocation());
|
||||||
|
|
||||||
|
lightning.setMetadata("Damager", new FixedMetadataValue(Wizards.getArcadeManager().GetPlugin(), p));
|
||||||
|
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamage(EntityDamageByEntityEvent event)
|
||||||
|
{
|
||||||
|
if (event.getDamager() instanceof LightningStrike && event.getEntity() instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
if (event.getDamager().hasMetadata("Damager"))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
Wizards.getArcadeManager()
|
||||||
|
.GetDamage()
|
||||||
|
.NewDamageEvent((LivingEntity) event.getEntity(),
|
||||||
|
(Player) event.getDamager().getMetadata("Damager").get(0).value(), null, DamageCause.LIGHTNING,
|
||||||
|
event.getDamage(), false, true, false, "Lightning Strike", "Lightning Strike");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package nautilus.game.arcade.game.games.wizards.spells;
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@ -15,9 +14,9 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
public class MagicMissile extends Spell implements SpellRightClick
|
public class SpellMagicMissile extends Spell implements SpellRightClick
|
||||||
{
|
{
|
||||||
|
|
||||||
public void castSpell(final Player player)
|
public void castSpell(final Player player)
|
||||||
@ -47,9 +46,9 @@ public class MagicMissile extends Spell implements SpellRightClick
|
|||||||
&& Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.8)) - loc.getY()) <= entity.getEyeHeight() / 2)
|
&& Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.8)) - loc.getY()) <= entity.getEyeHeight() / 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (entity != player && (!(entity instanceof Player) || wizards.IsAlive(entity)))
|
if (entity != player && (!(entity instanceof Player) || Wizards.IsAlive(entity)))
|
||||||
{
|
{
|
||||||
wizards.Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true,
|
Wizards.Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true,
|
||||||
true, false, "Magic Missile", "Magic Missile");
|
true, false, "Magic Missile", "Magic Missile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +61,7 @@ public class MagicMissile extends Spell implements SpellRightClick
|
|||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (loc.distance(orig) > maxRange || !player.isOnline() || !wizards.Manager.IsAlive(player))
|
if (loc.distance(orig) > maxRange || !player.isOnline() || !Wizards.Manager.IsAlive(player))
|
||||||
{
|
{
|
||||||
burst();
|
burst();
|
||||||
}
|
}
|
||||||
@ -114,7 +113,7 @@ public class MagicMissile extends Spell implements SpellRightClick
|
|||||||
loc.getWorld().playSound(loc, Sound.ORB_PICKUP, 0.7F, 0);
|
loc.getWorld().playSound(loc, Sound.ORB_PICKUP, 0.7F, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(wizards.Manager.GetPlugin(), 0, 0);
|
}.runTaskTimer(Wizards.Manager.GetPlugin(), 0, 0);
|
||||||
|
|
||||||
charge(player);
|
charge(player);
|
||||||
}
|
}
|
@ -4,16 +4,17 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilShapes;
|
import mineplex.core.common.util.UtilShapes;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
public class RainbowBeam extends Spell implements SpellRightClick
|
public class SpellRainbowBeam extends Spell implements SpellRightClick
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,10 +35,11 @@ public class RainbowBeam extends Spell implements SpellRightClick
|
|||||||
p.getEyeLocation().getDirection().normalize()
|
p.getEyeLocation().getDirection().normalize()
|
||||||
.multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation())));
|
.multiply(0.3 + p.getEyeLocation().distance(((LivingEntity) entityTarget).getEyeLocation())));
|
||||||
// The above code makes the beam appear to hit them where you aimed.
|
// The above code makes the beam appear to hit them where you aimed.
|
||||||
wizards.getArcadeManager()
|
Wizards.getArcadeManager()
|
||||||
.GetDamage()
|
.GetDamage()
|
||||||
.NewDamageEvent((LivingEntity) entityTarget, p, null, DamageCause.CUSTOM, getSpellLevel(p) * 1.5F, true,
|
.NewDamageEvent((LivingEntity) entityTarget, p, null, DamageCause.CUSTOM, getSpellLevel(p) * 1.5F, true,
|
||||||
true, false, "Rainbow Beam", "Rainbow Beam");
|
true, false, "Rainbow Beam", "Rainbow Beam");
|
||||||
|
p.playSound(entityTarget.getLocation(), Sound.LEVEL_UP, 1.5F, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -51,8 +53,9 @@ public class RainbowBeam extends Spell implements SpellRightClick
|
|||||||
l.getWorld().spigot().playEffect(l, Effect.POTION_SWIRL, 0, 0, 0, 0, 0, 500, 1, 30);
|
l.getWorld().spigot().playEffect(l, Effect.POTION_SWIRL, 0, 0, 0, 0, 0, 500, 1, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
charge(p);
|
p.playSound(p.getLocation(), Sound.LEVEL_UP, 1.5F, 1);
|
||||||
|
|
||||||
|
charge(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.wizards.spells;
|
|||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
import mineplex.core.common.util.UtilShapes;
|
import mineplex.core.common.util.UtilShapes;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClickBlock;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickBlock;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class Rumble extends Spell implements SpellRightClickBlock
|
public class SpellRumble extends Spell implements SpellRightClickBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
final private BlockFace[] _radial =
|
final private BlockFace[] _radial =
|
||||||
@ -44,7 +44,7 @@ public class Rumble extends Spell implements SpellRightClickBlock
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!player.isOnline() || !wizards.IsAlive(player))
|
if (!player.isOnline() || !Wizards.IsAlive(player))
|
||||||
{
|
{
|
||||||
cancel();
|
cancel();
|
||||||
return;
|
return;
|
||||||
@ -86,7 +86,7 @@ public class Rumble extends Spell implements SpellRightClickBlock
|
|||||||
if (entity instanceof LivingEntity && player != entity)
|
if (entity instanceof LivingEntity && player != entity)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (entity instanceof Player && !wizards.IsAlive(entity))
|
if (entity instanceof Player && !Wizards.IsAlive(entity))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ public class Rumble extends Spell implements SpellRightClickBlock
|
|||||||
double height = loc.getY() - b.getY();
|
double height = loc.getY() - b.getY();
|
||||||
if (height >= 0 && height <= 2)
|
if (height >= 0 && height <= 2)
|
||||||
{
|
{
|
||||||
wizards.Manager.GetDamage().NewDamageEvent((LivingEntity) entity, player, null,
|
Wizards.Manager.GetDamage().NewDamageEvent((LivingEntity) entity, player, null,
|
||||||
DamageCause.CUSTOM, damage, false, true, false, "Rumble", "Rumble");
|
DamageCause.CUSTOM, damage, false, true, false, "Rumble", "Rumble");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class Rumble extends Spell implements SpellRightClickBlock
|
|||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(wizards.getArcadeManager().GetPlugin(), 5, 1);
|
}.runTaskTimer(Wizards.getArcadeManager().GetPlugin(), 5, 1);
|
||||||
|
|
||||||
charge(player);
|
charge(player);
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class SpellSpeedBoost extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p)
|
||||||
|
{
|
||||||
|
int ticks = (20 * 90) * getSpellLevel(p);
|
||||||
|
int potionLevel = getSpellLevel(p);
|
||||||
|
|
||||||
|
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, ticks, potionLevel), true);
|
||||||
|
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ package nautilus.game.arcade.game.games.wizards.spells;
|
|||||||
|
|
||||||
import mineplex.core.common.util.UtilShapes;
|
import mineplex.core.common.util.UtilShapes;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClickBlock;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClickBlock;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,7 +11,7 @@ import org.bukkit.block.BlockFace;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class StoneWall extends Spell implements SpellRightClickBlock
|
public class SpellStoneWall extends Spell implements SpellRightClickBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,7 +59,7 @@ public class StoneWall extends Spell implements SpellRightClickBlock
|
|||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(wizards.getArcadeManager().GetPlugin(), 0, 5);
|
}.runTaskTimer(Wizards.getArcadeManager().GetPlugin(), 0, 5);
|
||||||
|
|
||||||
charge(player);
|
charge(player);
|
||||||
}
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spells.subclasses.TeleportRune;
|
||||||
|
|
||||||
|
public class SpellTeleportRune extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
private ArrayList<TeleportRune> _teleportRunes = new ArrayList<TeleportRune>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTick(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() == UpdateType.TICK)
|
||||||
|
{
|
||||||
|
Iterator<TeleportRune> itel = _teleportRunes.iterator();
|
||||||
|
|
||||||
|
while (itel.hasNext())
|
||||||
|
{
|
||||||
|
TeleportRune rune = itel.next();
|
||||||
|
|
||||||
|
if (rune.tickRune())
|
||||||
|
{
|
||||||
|
itel.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player player)
|
||||||
|
{
|
||||||
|
Block b = player.getTargetBlock(null, 25 * getSpellLevel(player));
|
||||||
|
|
||||||
|
while (b.getType() != Material.AIR && b.getY() < 250)
|
||||||
|
{
|
||||||
|
b = b.getRelative(BlockFace.UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.getRelative(BlockFace.DOWN).getType() == Material.AIR)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "Unable to place a rune!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location firstTeleport = player.getLocation();
|
||||||
|
Location secondTeleport = b.getLocation().add(0.5, 0, 0.5);
|
||||||
|
|
||||||
|
TeleportRune teleportRune = new TeleportRune(firstTeleport, secondTeleport, getSpellLevel(player));
|
||||||
|
|
||||||
|
_teleportRunes.add(teleportRune);
|
||||||
|
|
||||||
|
charge(player);
|
||||||
|
}
|
||||||
|
}
|
@ -2,8 +2,6 @@ package nautilus.game.arcade.game.games.wizards.spells;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -21,43 +19,36 @@ import mineplex.core.updater.UpdateType;
|
|||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
import mineplex.minecraft.game.core.explosion.CustomExplosion;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell;
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
import nautilus.game.arcade.game.games.wizards.Spell.SpellRightClick;
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spells.subclasses.TrapRune;
|
||||||
|
|
||||||
public class TrapRune extends Spell implements SpellRightClick
|
public class SpellTrapRune extends Spell implements SpellRightClick
|
||||||
{
|
{
|
||||||
private ArrayList<Rune> _runes = new ArrayList<Rune>();
|
private ArrayList<TrapRune> _runes = new ArrayList<TrapRune>();
|
||||||
|
|
||||||
private class Rune
|
|
||||||
{
|
|
||||||
private Location runeLocation;
|
|
||||||
private float runeSize;
|
|
||||||
private Player runeCaster;
|
|
||||||
private int ticksLived;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTick(UpdateEvent event)
|
public void onTick(UpdateEvent event)
|
||||||
{
|
{
|
||||||
if (event.getType() == UpdateType.TICK)
|
if (event.getType() == UpdateType.TICK)
|
||||||
{
|
{
|
||||||
Iterator<Rune> itel = _runes.iterator();
|
Iterator<TrapRune> itel = _runes.iterator();
|
||||||
while (itel.hasNext())
|
while (itel.hasNext())
|
||||||
{
|
{
|
||||||
Rune rune = itel.next();
|
TrapRune rune = itel.next();
|
||||||
if (!rune.runeCaster.isOnline() || rune.runeCaster.getGameMode() == GameMode.CREATIVE)
|
if (!rune.RuneCaster.isOnline() || rune.RuneCaster.getGameMode() == GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
else if (rune.ticksLived++ > 2000)
|
else if (rune.TicksLived++ > 2000)
|
||||||
{
|
{
|
||||||
itel.remove();
|
itel.remove();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rune.ticksLived <= 100)
|
if (rune.TicksLived <= 100)
|
||||||
{
|
{
|
||||||
if (rune.ticksLived % 15 == 0)
|
if (rune.TicksLived % 15 == 0)
|
||||||
initialParticles(rune.runeLocation, rune.runeSize);
|
initialParticles(rune.RuneLocation, rune.RuneSize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -68,9 +59,9 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (Player player : wizards.GetPlayers(true))
|
for (Player player : Wizards.GetPlayers(true))
|
||||||
{
|
{
|
||||||
if (isInTrap(rune.runeLocation, player.getLocation(), rune.runeSize))
|
if (isInTrap(rune.RuneLocation, player.getLocation(), rune.RuneSize))
|
||||||
{
|
{
|
||||||
trapCard(rune);
|
trapCard(rune);
|
||||||
itel.remove();
|
itel.remove();
|
||||||
@ -114,10 +105,12 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
private ArrayList<Location> getBoxCorners(Location center, double boxSize)
|
private ArrayList<Location> getBoxCorners(Location center, double boxSize)
|
||||||
{
|
{
|
||||||
ArrayList<Location> boxPoints = new ArrayList<Location>();
|
ArrayList<Location> boxPoints = new ArrayList<Location>();
|
||||||
|
|
||||||
boxPoints.add(center.clone().add(-boxSize, 0, -boxSize));
|
boxPoints.add(center.clone().add(-boxSize, 0, -boxSize));
|
||||||
boxPoints.add(center.clone().add(boxSize, 0, -boxSize));
|
boxPoints.add(center.clone().add(boxSize, 0, -boxSize));
|
||||||
boxPoints.add(center.clone().add(boxSize, 0, boxSize));
|
boxPoints.add(center.clone().add(boxSize, 0, boxSize));
|
||||||
boxPoints.add(center.clone().add(-boxSize, 0, boxSize));
|
boxPoints.add(center.clone().add(-boxSize, 0, boxSize));
|
||||||
|
|
||||||
return boxPoints;
|
return boxPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,14 +129,14 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValid(Rune rune)
|
private boolean isValid(TrapRune rune)
|
||||||
{
|
{
|
||||||
for (double x = -rune.runeSize; x <= rune.runeSize; x++)
|
for (double x = -rune.RuneSize; x <= rune.RuneSize; x++)
|
||||||
{
|
{
|
||||||
for (double z = -rune.runeSize; z <= rune.runeSize; z++)
|
for (double z = -rune.RuneSize; z <= rune.RuneSize; z++)
|
||||||
{
|
{
|
||||||
|
|
||||||
Block b = rune.runeLocation.clone().add(x, 0, z).getBlock();
|
Block b = rune.RuneLocation.clone().add(x, 0, z).getBlock();
|
||||||
if (UtilBlock.solid(b) || !UtilBlock.solid(b.getRelative(BlockFace.DOWN)))
|
if (UtilBlock.solid(b) || !UtilBlock.solid(b.getRelative(BlockFace.DOWN)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -154,18 +147,18 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trapCard(Rune rune)
|
public void trapCard(TrapRune rune)
|
||||||
{
|
{
|
||||||
rune.runeLocation.getWorld().playSound(rune.runeLocation, Sound.WITHER_SHOOT, 5, (float) rune.runeSize * 2);
|
rune.RuneLocation.getWorld().playSound(rune.RuneLocation, Sound.WITHER_SHOOT, 5, (float) rune.RuneSize * 2);
|
||||||
|
|
||||||
new CustomExplosion(wizards.getArcadeManager().GetDamage(), rune.runeLocation.clone().add(0, 0.3, 0),
|
new CustomExplosion(Wizards.getArcadeManager().GetDamage(), rune.RuneLocation.clone().add(0, 0.3, 0),
|
||||||
(float) rune.runeSize * 1.2F, rune.runeCaster, "Trap Rune", true);
|
(float) rune.RuneSize * 1.2F, rune.RuneCaster, "Trap Rune", true);
|
||||||
|
|
||||||
for (Location loc : getBox(rune.runeLocation, rune.runeSize, 0.3))
|
for (Location loc : getBox(rune.RuneLocation, rune.RuneSize, 0.3))
|
||||||
{
|
{
|
||||||
for (double y = 0; y < 1; y += 0.2)
|
for (double y = 0; y < 1; y += 0.2)
|
||||||
{
|
{
|
||||||
rune.runeLocation.getWorld().spigot().playEffect(loc, Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 30);
|
rune.RuneLocation.getWorld().spigot().playEffect(loc, Effect.FLAME, 0, 0, 0, 0, 0, 0, 1, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,6 +168,7 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
{
|
{
|
||||||
Vector vector = p.getEyeLocation().getDirection();
|
Vector vector = p.getEyeLocation().getDirection();
|
||||||
vector.normalize().multiply(0.5);
|
vector.normalize().multiply(0.5);
|
||||||
|
|
||||||
Vector v = p.getEyeLocation().toVector();
|
Vector v = p.getEyeLocation().toVector();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
@ -183,6 +177,7 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
while (i++ < (trapSize * 4) + 12)
|
while (i++ < (trapSize * 4) + 12)
|
||||||
{
|
{
|
||||||
v.add(vector);
|
v.add(vector);
|
||||||
|
|
||||||
Block b = v.toLocation(p.getWorld()).getBlock();
|
Block b = v.toLocation(p.getWorld()).getBlock();
|
||||||
|
|
||||||
if (UtilBlock.solid(b))
|
if (UtilBlock.solid(b))
|
||||||
@ -194,6 +189,7 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
+ Math.pow(v.getZ() - v.getBlockZ(), 2)) + 0.01;
|
+ Math.pow(v.getZ() - v.getBlockZ(), 2)) + 0.01;
|
||||||
b = v.subtract(vector.normalize().multiply(dist)).toLocation(p.getWorld()).getBlock();
|
b = v.subtract(vector.normalize().multiply(dist)).toLocation(p.getWorld()).getBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = v.toLocation(p.getWorld());
|
loc = v.toLocation(p.getWorld());
|
||||||
loc.setY(loc.getBlockY());
|
loc.setY(loc.getBlockY());
|
||||||
|
|
||||||
@ -203,14 +199,14 @@ public class TrapRune extends Spell implements SpellRightClick
|
|||||||
if (loc == null)
|
if (loc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Rune rune = new Rune();
|
TrapRune rune = new TrapRune();
|
||||||
rune.runeCaster = p;
|
rune.RuneCaster = p;
|
||||||
rune.runeSize = trapSize;
|
rune.RuneSize = trapSize;
|
||||||
rune.runeLocation = loc;
|
rune.RuneLocation = loc;
|
||||||
|
|
||||||
if (!isValid(rune))
|
if (!isValid(rune))
|
||||||
{
|
{
|
||||||
p.sendMessage(C.cGreen + "Unable to find a flat empty area to draw rune");
|
p.sendMessage(C.cGreen + "Area isn't flat and empty, cannot draw rune.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.UtilShapes;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.Spell;
|
||||||
|
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellRightClick;
|
||||||
|
|
||||||
|
public class SpellWizardsCompass extends Spell implements SpellRightClick
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void castSpell(Player p)
|
||||||
|
{
|
||||||
|
double dist = 9999;
|
||||||
|
Player closestPlayer = null;
|
||||||
|
|
||||||
|
for (Player player : Wizards.GetPlayers(true))
|
||||||
|
{
|
||||||
|
double newDist = player.getLocation().distance(p.getLocation());
|
||||||
|
|
||||||
|
if (newDist > 10 && (closestPlayer == null || newDist < dist))
|
||||||
|
{
|
||||||
|
|
||||||
|
closestPlayer = player;
|
||||||
|
dist = newDist;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closestPlayer != null)
|
||||||
|
{
|
||||||
|
int particlesPlayed = 0;
|
||||||
|
|
||||||
|
for (Location loc : UtilShapes.getLinesDistancedPoints(
|
||||||
|
p.getEyeLocation().subtract(p.getEyeLocation().getDirection().normalize().multiply(-0.3)).subtract(0, .5, 0),
|
||||||
|
closestPlayer.getEyeLocation(), 0.3))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (particlesPlayed++ > 13)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
loc.getWorld().spigot().playEffect(loc, Effect.HAPPY_VILLAGER, 0, 0, 0.1F, 0.1F, 0.1F, 0, 4, 25);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
charge(p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
p.sendMessage(C.cRed + "All players are less than 10 blocks from you!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells.subclasses;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilParticle;
|
||||||
|
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||||
|
import mineplex.core.common.util.UtilShapes;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
|
public class TeleportRune
|
||||||
|
{
|
||||||
|
private Location _firstLoc, _secondLoc;
|
||||||
|
private int _ticksLived;
|
||||||
|
private double _runeSize;
|
||||||
|
|
||||||
|
public TeleportRune(Location firstLocation, Location secondLocation, int runeLevel)
|
||||||
|
{
|
||||||
|
_firstLoc = firstLocation;
|
||||||
|
_secondLoc = secondLocation;
|
||||||
|
_runeSize = 1.5D * runeLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true on remove
|
||||||
|
*/
|
||||||
|
public boolean tickRune()
|
||||||
|
{
|
||||||
|
if (_ticksLived >= 150)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ticksLived % 5 == 0)
|
||||||
|
{
|
||||||
|
resendRunes();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ticksLived % 40 == 0 && _ticksLived < 150)
|
||||||
|
{
|
||||||
|
_firstLoc.getWorld().playSound(_firstLoc, Sound.PORTAL, (float) Math.min(3, _runeSize), 0F);
|
||||||
|
_firstLoc.getWorld().playSound(_secondLoc, Sound.PORTAL, (float) Math.min(3, _runeSize), 0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ticksLived > 0)
|
||||||
|
{
|
||||||
|
for (LivingEntity entity : _firstLoc.getWorld().getEntitiesByClass(LivingEntity.class))
|
||||||
|
{
|
||||||
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
|
if (loc.distance(_firstLoc) <= _runeSize && loc.getBlockY() >= _firstLoc.getBlockY()
|
||||||
|
&& loc.getBlockY() <= _firstLoc.getBlockY() + 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (double y = 0; y < 2; y += 0.5)
|
||||||
|
{
|
||||||
|
UtilParticle.PlayParticle(ParticleType.PORTAL, _secondLoc.clone().add(0, y, 0), 1.5F, 1.5F, 1.5F, 0F, 40);
|
||||||
|
}
|
||||||
|
UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, _secondLoc.clone().add(0, 1, 0), 0, 0, 0, 0, 5);
|
||||||
|
|
||||||
|
_secondLoc.getWorld().playSound(_secondLoc, Sound.ENDERMAN_TELEPORT, 3, 0);
|
||||||
|
|
||||||
|
Location newLoc = _secondLoc.clone();
|
||||||
|
newLoc.setDirection(entity.getEyeLocation().getDirection());
|
||||||
|
entity.setFallDistance(0F);
|
||||||
|
|
||||||
|
entity.teleport(newLoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_ticksLived++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeCircle(Location loc, double distance)
|
||||||
|
{
|
||||||
|
for (Location l : UtilShapes.getPointsInCircle(loc, (int) Math.ceil(Math.PI * distance * 2), distance))
|
||||||
|
{
|
||||||
|
UtilParticle.PlayParticle(_ticksLived >= 0 ? ParticleType.FIREWORKS_SPARK : ParticleType.RED_DUST, l, 0, 0, 0, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void redrawRunes(Location runeLoc)
|
||||||
|
{
|
||||||
|
runeLoc = runeLoc.clone();
|
||||||
|
if (_ticksLived >= 0)
|
||||||
|
{
|
||||||
|
for (double y = 0; y < 1; y += 0.4)
|
||||||
|
{
|
||||||
|
runeLoc.add(0, y, 0);
|
||||||
|
makeCircle(runeLoc, _runeSize);
|
||||||
|
makeCircle(runeLoc, (_runeSize / 3) * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
makeCircle(runeLoc, _runeSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resending runes resends the particles.
|
||||||
|
*/
|
||||||
|
public void resendRunes()
|
||||||
|
{
|
||||||
|
redrawRunes(_firstLoc);
|
||||||
|
redrawRunes(_secondLoc);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package nautilus.game.arcade.game.games.wizards.spells.subclasses;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class TrapRune
|
||||||
|
{
|
||||||
|
// TODO Methods and potentially move code into here
|
||||||
|
|
||||||
|
public Location RuneLocation;
|
||||||
|
public float RuneSize;
|
||||||
|
public Player RuneCaster;
|
||||||
|
public int TicksLived;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user