Developers

Developers

Purposes

You can use this help page to make your own Special ability plugin or stats command that tells you your kit and more!

How to hook your plugin in Eclipse to your project

1. Go on Eclipse and right click on your project.

2. Go to Properties - - -> Java build path

3. Click on the Libraries tab.

4. Click "Add External JARs..." and locate the KingKits jar file, then click OK.

Adding the plugin to your dependency

1. Open up plugin.yml in a good text editor such as Notepad + + (Highly recommended)

2. Under "author:" put "depends: [KingKits]". If you already have "depends: [<plugin>]" make it "depends: [<plugin>, KingKits]"

3. Save the YML file.

Using the methods

All the methods are simple as the method names basically explains what it does. First of all, you need to make sure you have added KingKits to your Libraries. Then just type PvPKits. and if you're using Eclipse it would tell you all the methods and you can just use them, but if you're using Notepad+ + or something, then just look below for the method names.

Methods and descriptions

Note: To use these methods, you must have PvPKits.<method>

Logger getPluginLogger()

- Returns KingKit's plugin logger.

boolean hasKit(String player) 

- Returns "true" if a player does have a kit, but if they don't have a kit, it returns "false". "String player" is the player's name.

boolean hasKit(String player, boolean ignoreOPs) 

- Returns "true" if a player does have a kit, but if they don't have a kit, it returns "false". "String player" is the player's name and "boolean ignoreOPs" is whether or not the method should ignore OPs.

String getKit(String player)

- Returns the player's kit. "String player" is the player name. Returns null if the player doesn't have a kit.

List<String> getPlayersUsingKit(String kitName)

- Returns a list of every player that is using a kit. "String kitName" is the kit. Returns an empty list if the kit doesn't exist or no players are using that kit.

Map<String, String> getPlayersAndKits()

- Returns a Map of every player using every kit. The first String in Map<?, ?> is the player's name and the second String is the kit. Returns an empty map if no one is using a kit.

boolean kitExists(String kitName)

- Returns if a kit exists. "String kitName" is the kit.

Note: Case sensitive! (Planning on making it not case sensitive)

void removePlayer(String player)

- Remove a player from any kit in the Map<String, String>. "String player" is the player's name.

Note: Doesn't clear the player's inventory.

void setPlayerKit(Logger pluginLogger, String player, String kit)

- Sets a player's kit. "Logger pluginLogger" is your plugin's logger (Use <plugin>.getLogger()), "String player" is the player's name and "String kit" is the kit.

Note: Clears the player's inventory.

int getScore(String player)

- Gets the score of a player. Returns -1 if the player doesn't exist in the configuration.

Map<String, Object> getScores()

- Gets the scores of every player as a map.

Note: The Map is actually Map<String, Integer> and so the results when using <Map>.get(int) would return an integer only.

void setScore(String player, int value)

- Sets the score of a player.

void create(String kitName, List<ItemStack> itemsInKit, List<PotionEffect> potionEffects, ItemStack guiItem, double costOfKit)

- Creates a kit with a kit name, a list of the items and a list of the potion effects, the GUI item for the GUI mode and the cost of the kit.

More & Suggestions

More methods may come later on if they are needed You can post suggestions below in the comments!

Example

In this example I will make it so that player's get healed if they walk on a new sand block.
Note: I never code like this and I hope you guys don't. It's a terrible thing to do if you use too many objects such as I said "String pName = player.getName()" which was pointless. I only used objects to shorten each line of code because Bukkit makes it look ugly and in different lines if it is too long.

@EventHandler
public void healKit(PlayerMoveEvent event) {
	Location from = event.getFrom();
	Location to = event.getTo();
	int fromX = (int) from.getX();
	int fromZ = (int) from.getZ();
	int toX = (int) to.getX();
	int toZ = (int) to.getZ();
	if (fromX != toX || fromZ != toZ) {
		Location loc = event.getPlayer().getLocation();
		int pX = (int) loc.getX();
		int pY = (int) loc.getY() - 1;
		int pZ = (int) loc.getZ();
		World w = loc.getWorld();
		if (world.getBlockAt(pX, pY, pZ).getType() == Material.SAND) {
			Player player = event.getPlayer();
			String pName = player.getName();
			if (PvPKits.hasKit(pName)) {
				String kit = PvPKits.getKit(pName);
				if (kit.equalsIgnoreCase("Healer")) {
					player.setHealth(20);
				}
			}
		}
	}
}

Comments

Posts Quoted:
Reply
Clear All Quotes