Dateien nach "src/main/java/pb/ajneb97/api" hochladen
This commit is contained in:
136
src/main/java/pb/ajneb97/api/ExpansionPaintballBattle.java
Normal file
136
src/main/java/pb/ajneb97/api/ExpansionPaintballBattle.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package pb.ajneb97.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import pb.ajneb97.PaintballBattle;
|
||||
/**
|
||||
* This class will automatically register as a placeholder expansion
|
||||
* when a jar including this class is added to the directory
|
||||
* {@code /plugins/PlaceholderAPI/expansions} on your server.
|
||||
* <br>
|
||||
* <br>If you create such a class inside your own plugin, you have to
|
||||
* register it manually in your plugins {@code onEbale()} by using
|
||||
* {@code new YourExpansionClass().register();}
|
||||
*/
|
||||
public class ExpansionPaintballBattle extends PlaceholderExpansion {
|
||||
|
||||
// We get an instance of the plugin later.
|
||||
private PaintballBattle plugin;
|
||||
|
||||
public ExpansionPaintballBattle(PaintballBattle plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Because this is an internal class,
|
||||
* you must override this method to let PlaceholderAPI know to not unregister your expansion class when
|
||||
* PlaceholderAPI is reloaded
|
||||
*
|
||||
* @return true to persist through reloads
|
||||
*/
|
||||
@Override
|
||||
public boolean persist(){
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Since this expansion requires api access to the plugin "SomePlugin"
|
||||
* we must check if said plugin is on the server or not.
|
||||
*
|
||||
* @return true or false depending on if the required plugin is installed.
|
||||
*/
|
||||
@Override
|
||||
public boolean canRegister(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the person who created this expansion should go here.
|
||||
*
|
||||
* @return The name of the author as a String.
|
||||
*/
|
||||
@Override
|
||||
public String getAuthor(){
|
||||
return "Ajneb97";
|
||||
}
|
||||
|
||||
/**
|
||||
* The placeholder identifier should go here.
|
||||
* <br>This is what tells PlaceholderAPI to call our onRequest
|
||||
* method to obtain a value if a placeholder starts with our
|
||||
* identifier.
|
||||
* <br>This must be unique and can not contain % or _
|
||||
*
|
||||
* @return The identifier in {@code %<identifier>_<value>%} as String.
|
||||
*/
|
||||
@Override
|
||||
public String getIdentifier(){
|
||||
return "paintball";
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the version of this expansion.
|
||||
* <br>You don't have to use numbers, since it is set as a String.
|
||||
*
|
||||
* @return The version as a String.
|
||||
*/
|
||||
@Override
|
||||
public String getVersion(){
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the method called when a placeholder with our identifier
|
||||
* is found and needs a value.
|
||||
* <br>We specify the value identifier in this method.
|
||||
* <br>Since version 2.9.1 can you use OfflinePlayers in your requests.
|
||||
*
|
||||
* @param player
|
||||
* A {@link org.bukkit.entity.Player Player}.
|
||||
* @param identifier
|
||||
* A String containing the identifier/value.
|
||||
*
|
||||
* @return possibly-null String of the requested identifier.
|
||||
*/
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String identifier){
|
||||
|
||||
if(player == null){
|
||||
return "";
|
||||
}
|
||||
|
||||
if(identifier.equals("wins")){
|
||||
return PaintballAPI.getWins(player)+"";
|
||||
}
|
||||
|
||||
if(identifier.equals("loses")){
|
||||
return PaintballAPI.getLoses(player)+"";
|
||||
}
|
||||
|
||||
if(identifier.equals("ties")){
|
||||
return PaintballAPI.getTies(player)+"";
|
||||
}
|
||||
|
||||
if(identifier.equals("coins")){
|
||||
return PaintballAPI.getCoins(player)+"";
|
||||
}
|
||||
|
||||
if(identifier.equals("kills")){
|
||||
return PaintballAPI.getKills(player)+"";
|
||||
}
|
||||
|
||||
if(identifier.startsWith("arenaplayers_count_")){
|
||||
String arena = identifier.replace("arenaplayers_count_", "");
|
||||
return PaintballAPI.getPlayersArena(arena)+"";
|
||||
}
|
||||
|
||||
if(identifier.startsWith("arena_status_")){
|
||||
String arena = identifier.replace("arena_status_", "");
|
||||
return PaintballAPI.getStatusArena(arena)+"";
|
||||
}
|
||||
|
||||
// We return null if an invalid placeholder (f.e. %someplugin_placeholder3%)
|
||||
// was provided
|
||||
return null;
|
||||
}
|
||||
}
|
23
src/main/java/pb/ajneb97/api/Hat.java
Normal file
23
src/main/java/pb/ajneb97/api/Hat.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package pb.ajneb97.api;
|
||||
|
||||
public class Hat {
|
||||
|
||||
private String name;
|
||||
private boolean selected;
|
||||
public Hat(String name,boolean selected) {
|
||||
this.name = name;
|
||||
this.selected = selected;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
}
|
218
src/main/java/pb/ajneb97/api/PaintballAPI.java
Normal file
218
src/main/java/pb/ajneb97/api/PaintballAPI.java
Normal file
@@ -0,0 +1,218 @@
|
||||
package pb.ajneb97.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import pb.ajneb97.PaintballBattle;
|
||||
import pb.ajneb97.database.JugadorDatos;
|
||||
import pb.ajneb97.database.MySQL;
|
||||
import pb.ajneb97.juego.EstadoPartida;
|
||||
import pb.ajneb97.juego.Partida;
|
||||
|
||||
public class PaintballAPI {
|
||||
|
||||
private static PaintballBattle plugin;
|
||||
|
||||
public PaintballAPI(PaintballBattle plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// public static JugadorDatos getPaintballDatos(Player player) {
|
||||
// if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
// JugadorDatos j = plugin.getJugador(player.getName());
|
||||
// if(j != null) {
|
||||
// return new JugadorPaintballDatos(j.getWins(),j.getLoses(),j.getTies(),j.getKills(),j.getHats(),j.getPerks());
|
||||
// }else {
|
||||
// return new JugadorPaintballDatos(0,0,0,0,new ArrayList<Hat>(),new ArrayList<Perk>());
|
||||
// }
|
||||
// }else {
|
||||
// return MySQL.getStatsTotales(plugin, player.getName(),"Coins");
|
||||
// }
|
||||
// }
|
||||
|
||||
public static int getCoins(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getCoins();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getStatsTotales(plugin, player.getName(),"Coins");
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCoins(Player player,int coins) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
j.aumentarCoins(coins);
|
||||
}
|
||||
}else {
|
||||
MySQL.agregarCoinsJugadorAsync(plugin, player.getName(), coins);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeCoins(Player player,int coins) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
j.disminuirCoins(coins);
|
||||
}
|
||||
}else {
|
||||
MySQL.removerCoinsJugadorAsync(plugin, player.getName(), coins);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getWins(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getWins();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getStatsTotales(plugin, player.getName(),"Win");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getLoses(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getLoses();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getStatsTotales(plugin, player.getName(),"Lose");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getTies(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getTies();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getStatsTotales(plugin, player.getName(),"Tie");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getKills(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getKills();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getStatsTotales(plugin, player.getName(),"Kills");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int getPerkLevel(Player player,String perk) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getNivelPerk(perk);
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}else {
|
||||
return MySQL.getNivelPerk(plugin, player.getName(), perk);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasHat(Player player,String hat) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.tieneHat(hat);
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
return MySQL.jugadorTieneHat(plugin, player.getName(), hat);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasHatSelected(Player player,String hat) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.tieneHatSeleccionado(hat);
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
return MySQL.jugadorTieneHatSeleccionado(plugin, player.getName(), hat);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Perk> getPerks(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null) {
|
||||
return j.getPerks();
|
||||
}else {
|
||||
return new ArrayList<Perk>();
|
||||
}
|
||||
}else {
|
||||
return MySQL.getPerksJugador(plugin, player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Hat> getHats(Player player) {
|
||||
if(!MySQL.isEnabled(plugin.getConfig())) {
|
||||
JugadorDatos j = plugin.getJugador(player.getName());
|
||||
if(j != null && j.getHats() != null) {
|
||||
return j.getHats();
|
||||
}else {
|
||||
return new ArrayList<Hat>();
|
||||
}
|
||||
}else {
|
||||
return MySQL.getHatsJugador(plugin, player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public static int getPlayersArena(String arena) {
|
||||
Partida partida = plugin.getPartida(arena);
|
||||
if(partida != null) {
|
||||
return partida.getCantidadActualJugadores();
|
||||
}else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getStatusArena(String arena) {
|
||||
Partida partida = plugin.getPartida(arena);
|
||||
FileConfiguration messages = plugin.getMessages();
|
||||
if(partida != null) {
|
||||
if(partida.getEstado().equals(EstadoPartida.COMENZANDO)) {
|
||||
return messages.getString("signStatusStarting");
|
||||
}else if(partida.getEstado().equals(EstadoPartida.ESPERANDO)) {
|
||||
return messages.getString("signStatusWaiting");
|
||||
}else if(partida.getEstado().equals(EstadoPartida.JUGANDO)) {
|
||||
return messages.getString("signStatusIngame");
|
||||
}else if(partida.getEstado().equals(EstadoPartida.TERMINANDO)) {
|
||||
return messages.getString("signStatusFinishing");
|
||||
}else {
|
||||
return messages.getString("signStatusDisabled");
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/pb/ajneb97/api/Perk.java
Normal file
25
src/main/java/pb/ajneb97/api/Perk.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package pb.ajneb97.api;
|
||||
|
||||
public class Perk {
|
||||
|
||||
private String name;
|
||||
private int level;
|
||||
public Perk(String name, int level) {
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public int getNivel() {
|
||||
return level;
|
||||
}
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user