API-Old2
You want to use PlayerPoints in your plugin? Then this things will help you:
Firstly download PlayerPoints and add it in your plugin library
Import this:
import org.black_ixx.playerPoints.*;
Paste this at OnEnable:
if(!playerPointsEnable()){ return; }
Then paste this anywhere of your mainclass: (This will check, if you have PlayerPoints)
private boolean playerPointsEnable() { Plugin playerPointsPlugin = this.getServer().getPluginManager().getPlugin("PlayerPoints"); if (playerPointsPlugin == null) { System.out.print("PlayerPoints not found, disabling " + this); getServer().getPluginManager().disablePlugin(this); return false; } System.out.print("[PointShop] PlayerPoints found."); return true; }
This are the important things, now if you want to get the points of a player just use this: pname = playername
Bukkit.getPluginManager().getPlugin("PlayerPoints").getConfig().getInt("Points."+pname);
And now if you want to change the points of an player just use this (this is very simple):
Example if you want to subtract the itemPrice from a player:
getServer().dispatchCommand(getServer().getConsoleSender(), "points give "+pName+" -"+itemPrice);
Example if you want to add points:
getServer().dispatchCommand(getServer().getConsoleSender(), "points give "+pName+" "+points);
shouldn't there be a more direct way of doing this?
Ex:
PointsPlayer p = new PointsPlayer(player);
p.getPoints(); (int) p.givePoints(amount);