Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from Zayon-Network/v1.2
Browse files Browse the repository at this point in the history
V1.2
  • Loading branch information
NIkiIncredible authored Mar 18, 2023
2 parents ce878ab + c4b1ccb commit 9da8d69
Show file tree
Hide file tree
Showing 15 changed files with 401 additions and 254 deletions.
76 changes: 8 additions & 68 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>de.nehlen</groupId>
<artifactId>gameapi</artifactId>
<version>1.1-BUILD</version>
<version>1.2</version>
<packaging>jar</packaging>

<name>Gameapi</name>

<description>Game api for minigames</description>
<description>GameAPI for minigames</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -55,34 +55,20 @@

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>cloudnet-releases</id>
<url>https://repo.cloudnetservice.eu/repository/releases/</url>
</repository>
<repository>
<id>exceptionflug</id>
<url>http://mvn.exceptionflug.de/repository/exceptionflug-public/</url>
</repository>
<repository>
<id>hikari</id>
<url>https://mvnrepository.com/artifact/com.zaxxer/HikariCP/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand All @@ -92,61 +78,15 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.0.0</version>
<version>5.0.1</version>
<scope>compile</scope>
</dependency>


<!-- MC COMMONS -->
<dependency>
<groupId>de.exceptionflug</groupId>
<artifactId>mccommons-config-spigot</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.exceptionflug</groupId>
<artifactId>mccommons-inventories-spigot</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.exceptionflug</groupId>
<artifactId>mccommons-holograms</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!-- CLOUD NET -->
<dependency>
<groupId>de.dytanic.cloudnet</groupId>
<artifactId>cloudnet-wrapper-jvm</artifactId>
<version>3.4.0-RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.dytanic.cloudnet</groupId>
<artifactId>cloudnet-bridge</artifactId>
<version>3.4.0-RELEASE</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.dytanic.cloudnet</groupId>
<artifactId>cloudnet-driver</artifactId>
<version>3.4.0-RELEASE</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.dytanic.cloudnet</groupId>
<artifactId>cloudnet-cloudperms</artifactId>
<version>3.4.0-RELEASE</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
13 changes: 5 additions & 8 deletions src/main/java/de/nehlen/gameapi/Gameapi.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.nehlen.gameapi;

import de.exceptionflug.mccommons.config.shared.ConfigFactory;
import de.exceptionflug.mccommons.config.spigot.SpigotConfig;
import de.nehlen.gameapi.YamlConfiguration.SpigotConfigurationWrapper;
import de.nehlen.gameapi.YamlConfiguration.YamlConfig;
import de.nehlen.gameapi.PointsAPI.PointsAPI;
import de.nehlen.gameapi.TeamAPI.TeamAPI;
import de.nehlen.gameapi.listener.PlayerJoinListener;
Expand All @@ -18,10 +18,7 @@ public final class Gameapi extends JavaPlugin {

@Getter private static Gameapi gameapi;
@Getter private ServerID serverID;

//CONFIGS
@Getter private SpigotConfig generalConfig;
@Getter private SpigotConfig databaseConfig;
@Getter private SpigotConfigurationWrapper databaseConfig;

//LISTENER
@Getter private PlayerJoinListener playerJoinListener;
Expand All @@ -36,8 +33,8 @@ public void onEnable() {
gameapi = this;
serverID = new ServerID(ServerID.generateRandomServerID());

this.generalConfig = ConfigFactory.create(new File(getDataFolder(), "general_config.yml"), SpigotConfig.class);
this.databaseConfig = ConfigFactory.create(new File(getDataFolder(), "database_config.yml"), SpigotConfig.class);
this.databaseConfig = new YamlConfig();
this.databaseConfig.load(new File(getDataFolder(), "database_config.yml"));

this.teamAPI = new TeamAPI(this);
this.databaseLib = new DatabaseLib(this);
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/de/nehlen/gameapi/ItemsAPI/Items.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.nehlen.gameapi.ItemsAPI;

import de.nehlen.gameapi.util.UUIDFetcher;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Material;
Expand Down Expand Up @@ -140,20 +139,6 @@ public static ItemStack createEnchantment(Material material, String displayname,

}

/**
* @param Display
* @param Owner
* @return
*/
public static ItemStack createSkull(String Display, String Owner) {
ItemStack item = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta itemMeta = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.PLAYER_HEAD);

itemMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUIDFetcher.getUUID(Owner)));
itemMeta.setDisplayName(Display);
item.setItemMeta(itemMeta);
return item;
}

/**
* @param Display
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/de/nehlen/gameapi/PhaseApi/AbstractGamePhase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.nehlen.gameapi.PhaseApi;

import de.nehlen.gameapi.Gameapi;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;

public abstract class AbstractGamePhase implements GamePhase {

@Getter @Setter
protected int counter = 0;
protected int scheduler = 0;

public AbstractGamePhase(int counter) {
this.counter = counter;
}

public void startPhase() {
scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(Gameapi.getGameapi(), () -> {}, 20L, 20L);
};
public void endPhase(){
Bukkit.getScheduler().cancelTask(scheduler);
};
}
29 changes: 9 additions & 20 deletions src/main/java/de/nehlen/gameapi/PhaseApi/GamePhase.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
package de.nehlen.gameapi.PhaseApi;

import de.nehlen.gameapi.Gameapi;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;

public class GamePhase {
@Getter @Setter
public int counter = 0;
public int scheduler = 0;
public interface GamePhase {
int counter = 0;
int scheduler = 0;

public GamePhase(int counter) {
this.counter=counter;
}
void setCounter(int counter);

public void startPhase() {
scheduler = Bukkit.getScheduler().scheduleSyncRepeatingTask(Gameapi.getGameapi(), new Runnable() {
@Override
public void run() {
//PUT CONTENT HERE
}
}, 20L, 20L);
};
public void endPhase(){
Bukkit.getScheduler().cancelTask(scheduler);
};
int getCounter();

void startPhase();

void endPhase();
}
47 changes: 47 additions & 0 deletions src/main/java/de/nehlen/gameapi/PhaseApi/GamePhaseManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.nehlen.gameapi.PhaseApi;

import de.nehlen.gameapi.PhaseApi.exceptions.GamePhaseLastException;
import de.nehlen.gameapi.PhaseApi.exceptions.GamePhaseNotRegisteredException;

import java.util.HashMap;
import java.util.Map;

public class GamePhaseManager {

private Map<String, GamePhase> gamePhases = new HashMap<>();

public void registerPhase(String name, GamePhase gamePhase) {
gamePhases.put(name, gamePhase);
}

public void startPhase(String name, int count) {
GamePhase gamePhase = gamePhases.get(name);
if (gamePhase != null) {
gamePhase.setCounter(count);
gamePhase.startPhase();
} else {
throw new GamePhaseNotRegisteredException("Game Phase with name " + name + " is not registered.");
}
}

public void endPhase(String name) {
GamePhase gamePhase = gamePhases.get(name);
if (gamePhase != null) {
gamePhase.endPhase();
} else {
throw new GamePhaseNotRegisteredException("Game Phase with name " + name + " is not registered.");
}
}

public void continueToNextPhase() {
if(gamePhases.size() <= 1) {
throw new GamePhaseLastException("No Game Phase to continue to.");
}
Map.Entry<String, GamePhase> currentGamePhase = gamePhases.entrySet().iterator().next();
currentGamePhase.getValue().endPhase();
gamePhases.remove(currentGamePhase.getKey());

Map.Entry<String, GamePhase> newCurrentPhase = gamePhases.entrySet().iterator().next();
newCurrentPhase.getValue().startPhase();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.nehlen.gameapi.PhaseApi.exceptions;

public class GamePhaseLastException extends RuntimeException {

public GamePhaseLastException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.nehlen.gameapi.PhaseApi.exceptions;

public class GamePhaseNotRegisteredException extends RuntimeException {
public GamePhaseNotRegisteredException(String message) {
super(message);
}
}
5 changes: 3 additions & 2 deletions src/main/java/de/nehlen/gameapi/TeamAPI/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;

/*
Expand All @@ -23,7 +24,7 @@ public class Team {
private ArrayList<Player> registeredPlayers;
private Integer maxTeamSize;
private ChatColor teamColor;
private Integer uuid;
private UUID uuid;
private HashMap<String, Object> memory;

@Getter @Setter
Expand Down Expand Up @@ -140,7 +141,7 @@ public ChatColor getTeamColor() {
return this.teamColor;
}

public Integer getUuid() {
public UUID getUuid() {
return this.uuid;
}

Expand Down
Loading

0 comments on commit 9da8d69

Please sign in to comment.