Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.WingedMLGPro.API;
- import org.bukkit.entity.Player;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- /**
- * © This Document and Code is STRICTLY copyrited(©) to Ben.
- * © If anyone takes any part of this code and uses it for
- * © Something public, Share with someone, uses it for API's,
- * © implementing it to their code and taking the rights for
- * © it is NOT allowed unless you get permission from me!
- * © This project SwiftyCredits was created by 35047
- * © at 21/04/15 at 10:04 AM
- */
- public class CreditsAPI {
- public Integer getCredits(Player p){
- ResultSet rs = mySQL.getResult("SELECT Credits FROM SwiftyCredits WHERE UUID='" + p.getUniqueId() + "'");
- try {
- if (rs.next()){
- rs.getInt("Credits");
- }
- return null;
- } catch (SQLException e){
- e.printStackTrace();
- }
- return 0;
- }
- public void setCredits(Player p, int credits){
- if (getCredits(p) == null){
- mySQL.update("INSERT INTO `SwiftyCredits`(`UUID`, `PlayerName`, `Credits`) VALUES ('"+p.getUniqueId()+"','"+p.getName()+"','"+credits+"')");
- }
- else if (getCredits(p) != null){
- mySQL.update("UPDATE `SwiftyCredits` SET `UUID`='"+p.getUniqueId()+"',`PlayerName`='"+p.getName()+"',`Credits`='"+credits+"' WHERE UUID='"+p.getUniqueId()+"'");
- }
- }
- public void addCredits(Player p, int credits){
- if (getCredits(p) == null){
- mySQL.update("INSERT INTO `SwiftyCredits`(`UUID`, `PlayerName`, `Credits`) VALUES ('"+p.getUniqueId()+"','"+p.getName()+"','"+credits+"')");
- }
- else if (getCredits(p) != null){
- int num = getCredits(p) + credits;
- mySQL.update("UPDATE `SwiftyCredits` SET `UUID`='"+p.getUniqueId()+"',`PlayerName`='"+p.getName()+"',`Credits`='"+num+"' WHERE UUID='"+p.getUniqueId()+"'");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement