Skip to content

Commit 2bc9cb2

Browse files
authored
Major API Revamp (Plugily-Projects#47)
Fixed global events * Removal of deprecated method (unused) Took 2 minutes * API Major update (Part 1) * API Major update (Part 2) * API Major update (Part 3) Exposed methods for TB
1 parent ec80ea6 commit 2bc9cb2

File tree

122 files changed

+1861
-1073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1861
-1073
lines changed
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,26 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
/**
20-
* All arena in-game related events.
21-
*/
19+
plugins {
20+
id("plugily.projects.java-conventions")
21+
id("com.github.johnrengelman.shadow") version "8.1.1"
22+
java
23+
}
24+
25+
dependencies {
26+
implementation("me.tigerhix.lib:scoreboard:1.4.3") { isTransitive = false }
27+
compileOnly(project(":MiniGamesBox-Database", "shadow"))
28+
compileOnly("com.github.cryptomorin:XSeries:9.10.0") { isTransitive = false }
29+
}
30+
31+
tasks{
32+
build {
33+
dependsOn(shadowJar)
34+
}
35+
36+
shadowJar {
37+
archiveClassifier.set("")
38+
}
39+
}
2240

23-
package plugily.projects.minigamesbox.classic.api.event.game;
41+
description = "MiniGamesBox-API"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package plugily.projects.minigamesbox.api;
2+
3+
import org.bukkit.configuration.file.FileConfiguration;
4+
import plugily.projects.minigamesbox.api.arena.IPluginArenaRegistry;
5+
import plugily.projects.minigamesbox.api.handlers.language.ILanguageManager;
6+
import plugily.projects.minigamesbox.api.kit.IKitRegistry;
7+
import plugily.projects.minigamesbox.api.preferences.IConfigPreferences;
8+
import plugily.projects.minigamesbox.api.user.IUserManager;
9+
import plugily.projects.minigamesbox.api.utils.misc.IDebugger;
10+
11+
/**
12+
* @author Lagggpixel
13+
* @since April 24, 2024
14+
*/
15+
public interface IPluginMain {
16+
17+
FileConfiguration getConfig();
18+
19+
String getName();
20+
21+
IDebugger getDebugger();
22+
23+
IConfigPreferences getConfigPreferences();
24+
25+
IUserManager getUserManager();
26+
27+
String getPluginNamePrefix();
28+
29+
String getPluginNamePrefixLong();
30+
31+
String getCommandAdminPrefix();
32+
33+
String getCommandAdminPrefixLong();
34+
35+
IPluginArenaRegistry getArenaRegistry();
36+
37+
IKitRegistry getKitRegistry();
38+
39+
ILanguageManager getLanguageManager();
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package plugily.projects.minigamesbox.api.arena;
2+
3+
/**
4+
* @author Lagggpixel
5+
* @since April 24, 2024
6+
*/
7+
public enum IArenaState {
8+
9+
WAITING_FOR_PLAYERS("Waiting"),
10+
STARTING("Starting"),
11+
FULL_GAME("Full-Game"),
12+
IN_GAME("In-Game"),
13+
ENDING("Ending"),
14+
RESTARTING("Restarting");
15+
16+
private final String formattedName;
17+
18+
IArenaState(String formattedName) {
19+
this.formattedName = formattedName;
20+
}
21+
22+
public String getFormattedName() {
23+
return formattedName;
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
package plugily.projects.minigamesbox.api.arena;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.entity.Player;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
import plugily.projects.minigamesbox.api.IPluginMain;
8+
import plugily.projects.minigamesbox.api.arena.managers.IBossbarManager;
9+
import plugily.projects.minigamesbox.api.arena.managers.IPluginMapRestorerManager;
10+
import plugily.projects.minigamesbox.api.arena.managers.IPluginScoreboardManager;
11+
import plugily.projects.minigamesbox.api.events.game.PlugilyGameStateChangeEvent;
12+
13+
import java.util.List;
14+
import java.util.Set;
15+
16+
/**
17+
* @author Lagggpixel
18+
* @since April 24, 2024
19+
*/
20+
public interface IPluginArena {
21+
22+
/**
23+
* Returns whether option value is true or false
24+
*
25+
* @param name option to get value from
26+
* @return true or false based on user configuration
27+
*/
28+
Integer getArenaOption(String name);
29+
30+
boolean isReady();
31+
32+
void setReady(boolean ready);
33+
34+
void setForceStart(boolean forceStart);
35+
36+
/**
37+
* Returns boss bar of the game.
38+
* Please use doBarAction if possible
39+
*
40+
* @return game boss bar manager
41+
* @see IBossbarManager
42+
*/
43+
IBossbarManager getBossbarManager();
44+
45+
/**
46+
* Get arena identifier used to get arenas by string.
47+
*
48+
* @return arena name
49+
* @see IPluginArenaRegistry#getArena(String)
50+
*/
51+
String getId();
52+
53+
int getMinimumPlayers();
54+
55+
/**
56+
* Get arena map name.
57+
*
58+
* @return arena map name, <b>it's not arena id</b>
59+
* @see #getId()
60+
*/
61+
String getMapName();
62+
63+
/**
64+
* Set arena map name.
65+
*
66+
* @param mapName new map name, [b]it's not arena id[/b]
67+
*/
68+
void setMapName(String mapName);
69+
70+
/**
71+
* Get timer of arena.
72+
*
73+
* @return timer of lobby time / time to next wave
74+
*/
75+
int getTimer();
76+
77+
/**
78+
* Modify game timer.
79+
*
80+
* @param timer timer of lobby / time to next wave
81+
*/
82+
void setTimer(int timer);
83+
84+
/**
85+
* Modify game timer.
86+
*
87+
* @param timer timer of lobby / time to next wave
88+
* @param forceArenaTimer should the timer be forced
89+
*/
90+
void setTimer(int timer, boolean forceArenaTimer);
91+
92+
int getMaximumPlayers();
93+
94+
IPluginMapRestorerManager getMapRestorerManager();
95+
96+
/**
97+
* Gets the current arena state
98+
* @return The current arena state
99+
*/
100+
@NotNull IArenaState getArenaState();
101+
102+
/**
103+
* Set game state of arena.
104+
* Calls VillageGameStateChangeEvent
105+
*
106+
* @param ArenaState new game state of arena
107+
* @param forceArenaState should it force the arenaState?
108+
* @see IArenaState
109+
* @see PlugilyGameStateChangeEvent
110+
*/
111+
void setArenaState(@NotNull IArenaState ArenaState, boolean forceArenaState);
112+
113+
/**
114+
* Set game state of arena.
115+
* Calls VillageGameStateChangeEvent
116+
*
117+
* @param ArenaState new game state of arena
118+
* @see IArenaState
119+
* @see PlugilyGameStateChangeEvent
120+
*/
121+
void setArenaState(@NotNull IArenaState ArenaState);
122+
123+
124+
/**
125+
* Gets all the players in the arena
126+
* @return a set containing all the players
127+
*/
128+
@NotNull Set<Player> getPlayers();
129+
130+
/**
131+
* Get spectator location of arena.
132+
*
133+
* @return end location of arena
134+
*/
135+
@Nullable Location getSpectatorLocation();
136+
137+
/**
138+
* Set spectator location of arena.
139+
*
140+
* @param spectatorLoc new end location of arena
141+
*/
142+
void setSpectatorLocation(Location spectatorLoc);
143+
144+
Location getLobbyLocation();
145+
146+
void setLobbyLocation(Location loc);
147+
148+
Location getStartLocation();
149+
150+
void setStartLocation(Location location);
151+
152+
void teleportToEndLocation(Player player);
153+
154+
Location getEndLocation();
155+
156+
Location getLocation(GameLocation gameLocation);
157+
158+
IPluginScoreboardManager getScoreboardManager();
159+
160+
@NotNull List<Player> getPlayersLeft();
161+
162+
/**
163+
* Returns the plugin main class
164+
* @return plugin main
165+
*/
166+
IPluginMain getPlugin();
167+
168+
enum IBarAction {
169+
ADD, REMOVE;
170+
}
171+
172+
enum GameLocation {
173+
START, LOBBY, END, SPECTATOR
174+
}
175+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package plugily.projects.minigamesbox.api.arena;
2+
3+
import org.bukkit.World;
4+
import org.bukkit.entity.Player;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
import java.util.List;
9+
10+
/**
11+
* @author Lagggpixel
12+
* @since April 24, 2024
13+
*/
14+
public interface IPluginArenaRegistry {
15+
/**
16+
* Checks if player is in any arena
17+
*
18+
* @param player player to check
19+
* @return true when player is in arena, false if otherwise
20+
*/
21+
boolean isInArena(@NotNull Player player);
22+
23+
/**
24+
* Returns arena where the player is
25+
*
26+
* @param player target player
27+
* @return Arena or null if not playing
28+
* @see #isInArena(Player) to check if player is playing
29+
*/
30+
@Nullable IPluginArena getArena(Player player);
31+
32+
/**
33+
* Returns arena based by ID
34+
*
35+
* @param id name of arena
36+
* @return Arena or null if not found
37+
*/
38+
@Nullable IPluginArena getArena(String id);
39+
40+
int getArenaPlayersOnline();
41+
42+
void registerArena(IPluginArena arena);
43+
44+
void unregisterArena(IPluginArena arena);
45+
46+
void registerArenas();
47+
48+
void registerArena(String key);
49+
50+
@NotNull List<IPluginArena> getArenas();
51+
52+
List<World> getArenaIngameWorlds();
53+
54+
List<World> getArenaWorlds();
55+
56+
void shuffleBungeeArena();
57+
58+
int getBungeeArena();
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package plugily.projects.minigamesbox.api.arena.managers;
2+
3+
import org.bukkit.entity.Player;
4+
import plugily.projects.minigamesbox.api.arena.IPluginArena;
5+
6+
/**
7+
* @author Lagggpixel
8+
* @since April 24, 2024
9+
*/
10+
public interface IBossbarManager {
11+
void bossBarUpdate();
12+
13+
/**
14+
* Executes boss bar action for arena
15+
*
16+
* @param action add or remove a player from boss bar
17+
* @param player player
18+
*/
19+
void doBarAction(IPluginArena.IBarAction action, Player player);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package plugily.projects.minigamesbox.api.arena.managers;
2+
3+
/**
4+
* @author Lagggpixel
5+
* @since April 24, 2024
6+
*/
7+
public interface IPluginMapRestorerManager {
8+
void fullyRestoreArena();
9+
}

0 commit comments

Comments
 (0)