public interface MagicAPI
A Plugin should generally check for the "Magic" plugin, and then cast that Plugin to MagicAPI to interact with it.
| Modifier and Type | Method and Description |
|---|---|
boolean |
cast(String spellName,
org.bukkit.configuration.ConfigurationSection parameters,
org.bukkit.command.CommandSender sender,
org.bukkit.entity.Entity entity) |
boolean |
cast(String spellName,
String[] parameters)
Cast a specific Spell, with optional parameters.
|
boolean |
cast(String spellName,
String[] parameters,
org.bukkit.command.CommandSender sender,
org.bukkit.entity.Entity entity)
Cast a specific Spell, with optional parameters, using a specific CommandSender and/or Player.
|
void |
clearCache()
Clear all image and schematic caches
|
boolean |
commit()
Commit and clear all loaded undo queues
|
org.bukkit.inventory.ItemStack |
createBrushItem(String brushKey)
Create an ItemStack that represents a Material Brush.
|
org.bukkit.inventory.ItemStack |
createGenericItem(String magicItemKey)
Create a generic version of an item with no extra data.
|
org.bukkit.inventory.ItemStack |
createItem(String magicItemKey)
Create a new Magic item.
|
org.bukkit.inventory.ItemStack |
createItem(String magicItemKey,
Mage mage) |
org.bukkit.inventory.ItemStack |
createSpellItem(String spellKey)
Create an ItemStack that represents a Spell.
|
Wand |
createUpgrade(String wandKey)
Create an upgrade Wand item from a template.
|
Wand |
createWand(org.bukkit.inventory.ItemStack item)
Turn the given ItemStack into a wand
|
Wand |
createWand(org.bukkit.Material iconMaterial,
short iconData)
Create a new Wand instance out of a given Material type.
|
Wand |
createWand(String wandKey)
Create a new Wand from a template.
|
String |
describeItem(org.bukkit.inventory.ItemStack item)
Return a string description of an item.
|
Collection<Mage> |
getAutomata()
Get a list of all known Automaton records.
|
String |
getBrush(org.bukkit.inventory.ItemStack item)
Get the key of the material brush represented by an item.
|
Collection<String> |
getBrushes()
Get a list of all valid Material Brush names.
|
MageController |
getController()
Get the MageController.
|
String |
getItemKey(org.bukkit.inventory.ItemStack item)
Return the key name of an item, so it can be re-created with
createItem.
|
Logger |
getLogger()
Retrieve the Logger for this API instance.
|
Collection<LostWand> |
getLostWands()
Return a list of all known LostWand records.
|
Mage |
getMage(org.bukkit.command.CommandSender sender)
Deprecated.
|
Mage |
getMage(org.bukkit.entity.Entity entity,
org.bukkit.command.CommandSender sender)
Deprecated.
|
Collection<Mage> |
getMages()
Deprecated.
|
Collection<Mage> |
getMagesWithPendingBatches()
Get all currently loaded Mage instances that have
pending construction batches.
|
Messages |
getMessages()
Return the Messages controller, which manages Magic's
localization store.
|
Collection<UndoList> |
getPendingUndo() |
Collection<String> |
getPlayerNames()
A utility method to get the names of all currently logged-in Players.
|
org.bukkit.plugin.Plugin |
getPlugin()
Retrieve the Bukkit Plugin for Magic
|
Collection<String> |
getSchematicNames()
Get a list of all known schematics.
|
String |
getSpell(org.bukkit.inventory.ItemStack item)
Get the key of the Spell or SpellTemplate represented by an item.
|
org.bukkit.inventory.ItemStack |
getSpellBook(SpellCategory category,
int count)
Returns a written book item describing all of the spells in
a given category.
|
SpellTemplate |
getSpellTemplate(String key)
Retrieve a specific SpellTemplate.
|
Collection<SpellTemplate> |
getSpellTemplates()
Get a list of all currently loaded SpellTemplate records, as defined in spells.defaults.yml
and spells.yml
|
Collection<SpellTemplate> |
getSpellTemplates(boolean showHidden) |
Wand |
getWand(org.bukkit.inventory.ItemStack item)
Load a Wand instance of an ItemStack.
|
Collection<String> |
getWandKeys()
Retrieve the keys for all wand templates.
|
void |
giveExperienceToPlayer(org.bukkit.entity.Player player,
int xp)
Give experience to a player, in a way that is safe for wands.
|
void |
giveItemToPlayer(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack itemStack)
A utility method for giving an item to a player.
|
boolean |
hasItem(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack item)
Check to see if a player has a specific item.
|
boolean |
hasPermission(org.bukkit.command.CommandSender sender,
String pNode)
Check to see if a CommandSender has permission.
|
boolean |
hasPermission(org.bukkit.command.CommandSender sender,
String pNode,
boolean defaultPermission)
Deprecated.
|
boolean |
isBrush(org.bukkit.inventory.ItemStack item)
Check to see if an existing item is a material brush item.
|
boolean |
isSpell(org.bukkit.inventory.ItemStack item)
Check to see if an existing item is a spell item.
|
boolean |
isUpgrade(org.bukkit.inventory.ItemStack item)
Check to see if an existing item is a wand upgrade.
|
boolean |
isWand(org.bukkit.inventory.ItemStack item)
Check to see if an existing item is a Wand.
|
void |
reload()
Reload all Magic configurations.
|
void |
reload(org.bukkit.command.CommandSender sender)
Reload all Magic configurations, report success/fail to sender
|
void |
removeLostWand(String id)
Forget a specific LostWand.
|
void |
save()
Save all Magic data.
|
boolean |
takeItem(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack item)
Check to see if a player has a specific item, and remove it
from the player's inventory.
|
org.bukkit.plugin.Plugin getPlugin()
Logger getLogger()
boolean hasPermission(org.bukkit.command.CommandSender sender,
String pNode)
This extends Bukkit's permission checks to account for special Magic bypass flags and Automata behavior.
sender - The CommandSender, may also be a Player or null.pNode - The permission node to check@Deprecated boolean hasPermission(org.bukkit.command.CommandSender sender, String pNode, boolean defaultPermission)
This is used, for instance, in Magic's list of wands and spells- players have access to all spells by default, unless a -Magic.cast.spellname pnode is added.
sender - The CommandSender, may also be a Player or null.pNode - The permission node to checkdefaultPermission - set to true to enable permission by defaultvoid save()
void reload()
void reload(org.bukkit.command.CommandSender sender)
void clearCache()
boolean commit()
@Deprecated Collection<Mage> getMages()
These may be players or Automata (command blocks)
Collection<Mage> getMagesWithPendingBatches()
These may be players or Automata (command blocks)
Collection<UndoList> getPendingUndo()
@Deprecated Mage getMage(org.bukkit.command.CommandSender sender)
There is one Mage for the Console sender, one Mage for each Player, and one Mage for each named Command Block.
Each Mage is persistent and singular- two command blocks with the same name, if loaded at the same time, will use the same Mage. This may cause conflicts with cooldowns or other persistent Spell data.
sender - the CommandSender (Player, Command block, etc) to turn into a Mage@Deprecated Mage getMage(org.bukkit.entity.Entity entity, org.bukkit.command.CommandSender sender)
Every Entity should use its own Mage for casting spells. Entity Mages are tracked by UUID, and their data is saved and restored as normal.
entity - the Entity to turn into a Magesender - the CommandSender to use, optionalvoid giveItemToPlayer(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack itemStack)
If the item is a Wand, and it goes into the player's hand, it will be activated. Make sure to use this method, or else make sure to deal with activating wands as the player gets them.
player - The Player to give an item toitemStack - The ItemStack to giev the player, may be a Wand.void giveExperienceToPlayer(org.bukkit.entity.Player player,
int xp)
This method may get removed in the future if Wands can be smarter about XP being added externally.
player - The Player to give XPxp - The amount of XP to giveCollection<String> getPlayerNames()
Useful for tab-completion.
Collection<String> getWandKeys()
@Nullable org.bukkit.inventory.ItemStack createItem(String magicItemKey)
magicItemKey - The template key, may be a wand, spell, etc.@Nullable org.bukkit.inventory.ItemStack createGenericItem(String magicItemKey)
magicItemKey - The template key, may be a wand, spell, etc.String getItemKey(org.bukkit.inventory.ItemStack item)
@Nonnull String describeItem(org.bukkit.inventory.ItemStack item)
This will use the display name if set, then Vault if present, then falling back to the Material name.
item - The item stack.boolean hasItem(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack item)
boolean takeItem(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack item)
Wand createWand(String wandKey)
Once created, a Wand is a unique item. It "remembers" which template it was created from, but this is currently not used for anything.
wandKey - The template key, or blank for a default wand.@Nullable Wand createWand(org.bukkit.inventory.ItemStack item)
item - The item to use as the wand's icon.Wand createWand(org.bukkit.Material iconMaterial, short iconData)
This will create a new ItemStack to represent the Wand.
iconMaterial - The type of Material to use as the Wand icon.iconData - Data used for durability or icon variants.Wand createUpgrade(String wandKey)
This can be used to create upgrade items from wand templates that are not originally meant to be upgrades.
wandKey - The template keyWand getWand(org.bukkit.inventory.ItemStack item)
item - The item to load Wand data from.boolean isWand(org.bukkit.inventory.ItemStack item)
item - The ItemStack to inspect.boolean isUpgrade(org.bukkit.inventory.ItemStack item)
item - The ItemStack to inspect.boolean isSpell(org.bukkit.inventory.ItemStack item)
item - The ItemStack to inspect.boolean isBrush(org.bukkit.inventory.ItemStack item)
item - The ItemStack to inspect.@Nullable String getSpell(org.bukkit.inventory.ItemStack item)
item - The item to inspect@Nullable String getBrush(org.bukkit.inventory.ItemStack item)
item - The item to inspectorg.bukkit.inventory.ItemStack createSpellItem(String spellKey)
This item will be absorbed by a Wand on activate, adding that Spell to the Wand, if the Wand finds this item in a Player's inventory.
spellKey - The Spell to create an item for.@Nullable org.bukkit.inventory.ItemStack createBrushItem(String brushKey)
This item will be absorbed by a Wand on activate, adding that brush to the Wand, if the Wand finds this item in a Player's inventory.
brushKey - The Material brush to create an item for.Collection<LostWand> getLostWands()
void removeLostWand(String id)
The ItemStack will not be removed if it still exists, and a new LostWand record may get created if the ItemStack is found again by the Chunk scanner.
id - The id of the LostWand to forget.Collection<Mage> getAutomata()
boolean cast(String spellName, String[] parameters)
The parameters are generally in alternating key/value format, such as
{"radius", "32", "range", "64"}
This Spell will be cast using the COMMAND Mage.
spellName - The key name of the Spell to castparameters - A list of parameters, as if cast from the command-line.boolean cast(String spellName, String[] parameters, org.bukkit.command.CommandSender sender, org.bukkit.entity.Entity entity)
The parameters are generally in alternating key/value format, such as
{"radius", "32", "range", "64"}
The CommandSender and Player may differ, in which case both will be notified of Spell results.
spellName - The key name of the Spell to castparameters - A list of parameters, as if cast from the command-line.sender - The CommandSender that originated this Spellentity - The Entity this Spell is cast on behalf of, may be Player or differ from senderboolean cast(String spellName, org.bukkit.configuration.ConfigurationSection parameters, org.bukkit.command.CommandSender sender, org.bukkit.entity.Entity entity)
Collection<SpellTemplate> getSpellTemplates()
A Spell is created for a Mage from a SpellTemplate.
Collection<SpellTemplate> getSpellTemplates(boolean showHidden)
@Nullable SpellTemplate getSpellTemplate(String key)
key - The key of the SpellTemplate to look up.Collection<String> getBrushes()
This will include all Block Materials, as well as special brushes (copy, clone, erase, replicate, map) and any known schematic brushes.
Collection<String> getSchematicNames()
These will be loaded from Magic's built-in schematic collection, or from an external source (e.g. WorldEdit).
The list may be empty if schematics are disabled.
These are the raw schematic names, and do not have the "schematic:" prefix or ".schematic" extension.
MageController getController()
The controller is used for more advanced plugin interaction, and is used heavily by Spells themselves to interact with the Magic plugin's internal functionality.
org.bukkit.inventory.ItemStack getSpellBook(SpellCategory category, int count)
category - The category to look upcount - How many to give (max 1 stack)Messages getMessages()
Copyright © 2021 elMakers. All rights reserved.