API - SugarCaney/CrystalQuest GitHub Wiki


← Language Files | Table of Contents | Changelog →


To help you out hooking an (custom) other plugin into CrystalQuest, I made a little API to make it easier to communicate with the CrystalQuest-plugin. Before you start hacking into it, make sure you have the latest CrystalQuest plugin in your build path and have depend: [CrystalQuest] set in your plugin.yml. If you don't, nothing will work!

All information given down below is also mostly integrated in the Java-code itself, so you would see all comments while coding. For example the Arena-class has way to many methods to declare down here, but the names and comments are quite self-explaining. So I don't thing you would have that much problems with it (f.e. getPlayers(), addPlayers(), resetArena() etc.)

Contents

CrystalQuestAPI

The CrystalQuestAPI-class is used to communicate with the CrystalQuest plugin and needed to communicate with probably most importantly: the ArenaManager managing all Arenas. Luckily this class is as static as hell so you can just use CrystalQuestAPI.<whatever>().

getItemHandler()

Get the class managing all the Items in the game (more info here).

Returns:

  • (ItemHandler) The class managing all items.

getArenaManager()

Get the class managing all the Arenas (more info here).

Returns:

  • (ArenaManager) The class managing all Arenas.

getEconomy()

Gets the class managing all what has to do with the shop-system. Get the balances of the players, open menus and do what you want :).

Returns:

  • (Economy)

isInProtecterArea(Location loc)

Checks if the location is within a protected arena.

Parameters:

  • (Location) The location to check for.

Returns:

  • (boolean) True when it is within such area, false if it isn't.

ArenaManager

The ArenaManager is a class which manages all Arena's in the CrystalQuest-plugin. To get access to this class, you need to get the ArenaManager-instance from the plugin via the CrystalQuestAPI using the getArenaManager()-method. For example: ArenaManager am = CrystalQuestAPI.getArenaManager();

This class handles various things, but you would mainly use the getArena(), getTeam(), getArenas() and isInGame() methods.

getArena(Object object)

Parameters:

  • (String) The name of the Arena. OR
  • (int) The ID of the Arena. OR
  • (Player) The Player you want to know the Arena from.

Returns:

  • (Arena) The instance of the arena. OR
  • null if no such arena could be found.

getTeam(Player p)

Parameters:

  • (Player) The Player you want to know the Team-ID of.

Returns:

  • (int) The Team ID of the Player's Team. (0-5) OR
  • (int) -1 if he/she is not in a team.

getArenas()

Returns:

  • (List<Arena>) A list of all Arena's avaiable on the system.

isInGame(Player p)

Check if a certain Player is in-game (contains: Joined lobby, playing the game and being in the end-game phase).

Parameters:

  • (Player) The Player to check for.

Returns:

  • (boolean) true if he/she is in-game, false if he/she isn't.

ItemHandler

The ItemManager-class handles all the Power-ups you get in-game. If you want to get a random item or if you want to add a new item to the game, use this class. Make sure that when you actually add a new Item, you give the item a display name. Otherwise it can't be picked up.

getAllItems()

Get a list containing all Items avaiable in-game. All items in this list can be spawned in-game. You can add your own items to the list just by using api.getItemManager().getAllItems().add(yourItem).

Returns:

  • (List<ItemStack>) A list containing all the items.

getItemByName(String name)

Get the item-stack represented by the given name. The name is case-sensitives and does not require ChatColors.

Parameters:

  • (String) The name of the item you'd like to get.

Returns:

  • (ItemStack) The item with the given name.

getRandomItem()

Get a random item from the items-list.

Returns:

  • (ItemStack) A random item from the items-list.

getInstructionManual(String specialMessage2lines)

Gets a book in which the instructions about the plugin is listed. You can use this if you have for example a custom hotbar addon.

Parameters:

  • (String) A custom message shown at the end of about 2 lines.

Return:

  • (ItemStack) The written book with the information.

ArenaStartEvent

Cancellable This event is called when the arena changes from pre-game to in-game.

getArena()

Returns:

  • (Arena) The arena which started.

ArenaTickEvent

This event is called when the counter counts 1 second down.

getArena()

Returns:

  • (Arena) The arena which is counting down

getOldCount()

Returns:

  • (int) The clock before the tick

getNewCount()

Returns:

  • (int) The clock after the tick

isInGameTick()

Returns:

  • (boolean) True if it's in-game, False if it's pre-game

PlayerEarnCrystalsEvent

Cancellable This event is called when a player earns crystals ingame by either killing players or by winning the game (currency).

hideMessage()

Hides the message that shows the amount of crystals you earned.

showMessage()

Gets whether the crystalmessage has to be shown. Returns:

  • (boolean) true if the message will be shown, false if not.

getAmount()

Returns:

  • (int) The amount of crystals earned by the player.

setAmount(int amount)

Parameters:

  • (int) Set the amount of crystals the player will earn.

getPlayer()

Returns:

  • (Player) Get the player who earned the crystals.

getArena()

Returns:

  • (Arena) Get the arena in which the event occured.

PlayerJoinArenaEvent

Cancellable This event is called prior to the actual join.

getPlayer()

Returns:

  • (Player) The Player who joined the arena.

getArena()

Returns:

  • (Arena) The Arena the Player joined.

isSpectator()

Returns:

  • (boolean) True if the player joined as a spectator.

setCancelled(boolean cancelled)

Parameters:

  • (boolean) true if you want to not let the event happen

PlayerLeaveArenaEvent

This event is called when a Player leaves an Arena.

getPlayer()

Returns:

  • (Player) The Player who left the arena.

getArena()

Returns:

  • (Arena) The Arena the Player left.

TeamWinGameEvent

This event is called when a Team wins a game.

getPlayers()

Returns:

  • (List<Player>) A list containing all players in the winning team.

getArena()

Returns:

  • (Arena) The Arena the Team won in.

getTeam()

Returns:

  • (int) The Team-ID of the winning Team.

getTeamName()

Returns:

  • (String) The name of the winning Team.

getTeams()

Returns:

  • (Team[]) The teams who were in the game.

getTeamCount()

Returns:

  • (int) The amount of teams that have played the game.

⚠️ **GitHub.com Fallback** ⚠️