Skip to content

Commit 43b37ee

Browse files
committed
refactor: updates to API
1 parent d3ac493 commit 43b37ee

File tree

96 files changed

+813
-854
lines changed

Some content is hidden

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

96 files changed

+813
-854
lines changed

api/src/main/java/org/screamingsandals/bedwars/api/BedwarsAPI.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.screamingsandals.bedwars.api.utils.ColorChanger;
3030
import org.screamingsandals.bedwars.api.utils.EventUtils;
3131
import org.screamingsandals.bedwars.api.variants.VariantManager;
32-
import org.screamingsandals.lib.api.Wrapper;
3332

3433
import java.util.List;
3534

@@ -39,7 +38,7 @@
3938
* @author ScreamingSandals
4039
*/
4140
@ApiStatus.NonExtendable
42-
public interface BedwarsAPI extends Wrapper {
41+
public interface BedwarsAPI {
4342
/**
4443
* <p>Retrieves the game manager instance.</p>
4544
*

api/src/main/java/org/screamingsandals/bedwars/api/Region.java

+22-54
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
package org.screamingsandals.bedwars.api;
2121

2222
import org.jetbrains.annotations.ApiStatus;
23-
import org.screamingsandals.lib.api.Wrapper;
23+
import org.screamingsandals.lib.api.types.server.BlockHolder;
24+
import org.screamingsandals.lib.api.types.server.BlockPlacementHolder;
25+
import org.screamingsandals.lib.api.types.server.BlockSnapshotHolder;
26+
import org.screamingsandals.lib.api.types.server.ChunkHolder;
27+
import org.screamingsandals.lib.api.types.server.LocationHolder;
2428

2529
/**
2630
* <p>Abstract region API.</p>
@@ -36,122 +40,86 @@ public interface Region {
3640
* @return was the supplied location modified?
3741
* @since 0.3.0
3842
*/
39-
boolean isLocationModifiedDuringGame(Object loc);
40-
41-
/**
42-
* <p>Determines if the supplied location was modified during a BedWars game.</p>
43-
*
44-
* @param loc the location
45-
* @return was the supplied location modified?
46-
* @deprecated in favor of {@link Region#isLocationModifiedDuringGame(Object)}
47-
*/
48-
@Deprecated
49-
default boolean isBlockAddedDuringGame(Object loc) {
50-
return isLocationModifiedDuringGame(loc);
51-
}
43+
boolean isLocationModifiedDuringGame(LocationHolder loc);
5244

5345
/**
5446
* <p>Marks a location for rollback.</p>
5547
* <p>This should be used for restoring a broken block that was a part of the original world.</p>
5648
*
5749
* @param loc the location
58-
* @param blockState old block state (BlockStateHolder or the platform impl)
50+
* @param blockSnapshot old block state
5951
* @since 0.3.0
6052
*/
61-
void markForRollback(Object loc, Object blockState);
62-
63-
/**
64-
* <p>Marks a location for rollback.</p>
65-
* <p>This should be used for restoring a broken block that was a part of the original world.</p>
66-
*
67-
* @param loc the location
68-
* @param blockState old block state (BlockStateHolder or the platform impl)
69-
* @deprecated in favor of {@link Region#markForRollback(Object, Object)}
70-
*/
71-
@Deprecated
72-
default void putOriginalBlock(Object loc, Object blockState) {
73-
markForRollback(loc, blockState);
74-
}
53+
void markForRollback(LocationHolder loc, BlockSnapshotHolder blockSnapshot);
7554

7655
/**
7756
* <p>Schedules a location for removal (set to AIR) while rolling back.</p>
7857
*
7958
* @param loc the location
8059
*/
81-
void addBuiltDuringGame(Object loc);
60+
void addBuiltDuringGame(LocationHolder loc);
8261

8362
/**
8463
* <p>Schedules a location for removal (set to AIR) while rolling back.</p>
8564
*
8665
* @param loc the location
8766
* @since 0.3.0
8867
*/
89-
void removeBuiltDuringGame(Object loc);
90-
91-
/**
92-
* <p>Schedules a location for removal (set to AIR) while rolling back.</p>
93-
*
94-
* @param loc the location
95-
* @deprecated in favor of {@link Region#removeBuiltDuringGame(Object)}
96-
*/
97-
@Deprecated
98-
default void removeBlockBuiltDuringGame(Object loc) {
99-
removeBuiltDuringGame(loc);
100-
}
68+
void removeBuiltDuringGame(LocationHolder loc);
10169

10270
/**
10371
* <p>Checks if a material is a liquid.</p>
10472
*
105-
* @param material the material (BlockTypeHolder or the platform impl)
73+
* @param blockHolder the material
10674
* @return is the material a liquid?
10775
*/
108-
boolean isLiquid(Object material);
76+
boolean isLiquid(BlockHolder blockHolder);
10977

11078
/**
11179
* <p>Checks if a block state matches a bed block.</p>
11280
*
113-
* @param blockState the block state (BlockStateHolder or the platform impl)
81+
* @param blockSnapshot the block state
11482
* @return does the block state match a bed block?
11583
*/
116-
boolean isBedBlock(Object blockState);
84+
boolean isBedBlock(BlockSnapshotHolder blockSnapshot);
11785

11886
/**
11987
* <p>Checks if a block state matches a bed head block.</p>
12088
*
121-
* @param blockState the block state (BlockStateHolder or the platform impl)
89+
* @param blockSnapshot the block state (BlockStateHolder or the platform impl)
12290
* @return does the block state match a bed head block?
12391
*/
124-
boolean isBedHead(Object blockState);
92+
boolean isBedHead(BlockSnapshotHolder blockSnapshot);
12593

12694
/**
12795
* <p>Gets the bed's neighbor block (the second part of the bed) from the bed head block.</p>
12896
*
12997
* @param blockHead the bed head block
13098
* @return the bed neighbor block
13199
*/
132-
Wrapper getBedNeighbor(Object blockHead);
100+
BlockPlacementHolder getBedNeighbor(BlockPlacementHolder blockHead);
133101

134102
/**
135103
* <p>Determines if anything was modified in the supplied chunk.</p>
136104
*
137105
* @param chunk the chunk
138106
* @return was anything in the chunk modified?
139107
*/
140-
boolean isChunkUsed(Object chunk);
108+
boolean isChunkUsed(ChunkHolder chunk);
141109

142110
/**
143111
* <p>Checks if a block state matches a door block.</p>
144112
*
145-
* @param blockState the block state (BlockStateHolder or the platform impl)
113+
* @param blockSnapshot the block state
146114
* @return does the block state match a door block?
147115
*/
148-
boolean isDoorBlock(Object blockState);
116+
boolean isDoorBlock(BlockSnapshotHolder blockSnapshot);
149117

150118
/**
151119
* <p>Checks if a block state matches a bottom door block.</p>
152120
*
153-
* @param blockState the block state (BlockStateHolder or the platform impl)
121+
* @param blockSnapshot the block state
154122
* @return does the block state match a bottom door block?
155123
*/
156-
boolean isDoorBottomBlock(Object blockState);
124+
boolean isDoorBottomBlock(BlockSnapshotHolder blockSnapshot);
157125
}

api/src/main/java/org/screamingsandals/bedwars/api/Team.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
import org.jetbrains.annotations.ApiStatus;
2323
import org.jetbrains.annotations.UnknownNullability;
24-
import org.screamingsandals.bedwars.api.game.Game;
24+
import org.screamingsandals.bedwars.api.game.LocalGame;
2525
import org.screamingsandals.bedwars.api.game.target.Target;
2626
import org.screamingsandals.bedwars.api.player.BWPlayer;
27-
import org.screamingsandals.lib.api.Wrapper;
27+
import org.screamingsandals.lib.api.types.server.ContainerHolder;
28+
import org.screamingsandals.lib.api.types.server.LocationHolder;
2829

2930
import java.util.List;
3031

@@ -40,7 +41,7 @@ public interface Team {
4041
*
4142
* @return the game
4243
*/
43-
Game getGame();
44+
LocalGame getGame();
4445

4546
/**
4647
* <p>Gets the team's name.</p>
@@ -61,14 +62,14 @@ public interface Team {
6162
*
6263
* @return the spawn locations
6364
*/
64-
List<? extends Wrapper> getTeamSpawns();
65+
List<? extends LocationHolder> getTeamSpawns();
6566

6667
/**
6768
* <p>Gets one of the team's spawn locations.</p>
6869
*
6970
* @return the spawn location
7071
*/
71-
Wrapper getRandomSpawn();
72+
LocationHolder getRandomSpawn();
7273

7374
/**
7475
* Gets the team's target (e.g. block, countdown).
@@ -92,31 +93,31 @@ public interface Team {
9293
*
9394
* @return the team chest inventory
9495
*/
95-
Wrapper getTeamChestInventory();
96+
ContainerHolder getTeamChestInventory();
9697

9798
/**
9899
* <p>Adds a new team chest at the specified location.</p>
99100
* <p>If a team chest is already present at the specified location, this method will fail silently (do nothing).</p>
100101
*
101102
* @param location the team chest location or block
102103
*/
103-
void addTeamChest(Object location);
104+
void addTeamChest(LocationHolder location);
104105

105106
/**
106107
* <p>Removes a team chest at the specified location.</p>
107108
* <p>If a team chest is not present at the specified location, this method will fail silently (do nothing).</p>
108109
*
109110
* @param location the team chest location or block
110111
*/
111-
void removeTeamChest(Object location);
112+
void removeTeamChest(LocationHolder location);
112113

113114
/**
114115
* <p>Determines if a team chest is present at the specified location.</p>
115116
*
116117
* @param location the team chest location
117118
* @return is a team chest present at the specified location?
118119
*/
119-
boolean isTeamChestRegistered(Object location);
120+
boolean isTeamChestRegistered(LocationHolder location);
120121

121122
/**
122123
* <p>Gets the amount of chests bound to this team.</p>

api/src/main/java/org/screamingsandals/bedwars/api/boss/BossBar.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.jetbrains.annotations.NotNull;
2424
import org.jetbrains.annotations.Nullable;
2525
import org.screamingsandals.lib.api.Wrapper;
26+
import org.screamingsandals.lib.api.types.ComponentHolder;
2627

2728
/**
2829
* @author ScreamingSandals
@@ -32,12 +33,12 @@ public interface BossBar extends StatusBar {
3233
/**
3334
* @return current message
3435
*/
35-
Wrapper getMessage();
36+
ComponentHolder getMessage();
3637

3738
/**
3839
* @param message
3940
*/
40-
void setMessage(@Nullable Object message);
41+
void setMessage(@Nullable ComponentHolder message);
4142

4243
/**
4344
* @return color

api/src/main/java/org/screamingsandals/bedwars/api/config/GameConfigurationContainer.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
package org.screamingsandals.bedwars.api.config;
2121

2222
import org.screamingsandals.bedwars.api.ArenaTime;
23-
24-
import java.util.List;
23+
import org.screamingsandals.lib.api.types.server.ItemStackHolder;
2524

2625
/**
2726
* @author ScreamingSandals
@@ -93,9 +92,9 @@ public interface GameConfigurationContainer extends ConfigurationContainer {
9392
ConfigurationListKey<String> SIDEBAR_LOBBY_CONTENT = ConfigurationListKey.of(String.class, "sidebar", "lobby", "content");
9493

9594
ConfigurationKey<Boolean> GAME_START_ITEMS_ENABLED = ConfigurationKey.of(Boolean.class, "game-start-items", "enabled");
96-
ConfigurationListKey<Object> GAME_START_ITEMS_ITEMS = ConfigurationListKey.of(Object.class, "game-start-items", "items"); // Object in API, registered as Item
95+
ConfigurationListKey<Object> GAME_START_ITEMS_ITEMS = ConfigurationListKey.of(Object.class, "game-start-items", "items"); // Object in API, registered as Item, TODO switch to ItemStackHolder
9796
ConfigurationKey<Boolean> PLAYER_RESPAWN_ITEMS_ENABLED = ConfigurationKey.of(Boolean.class, "player-respawn-items", "enabled");
98-
ConfigurationListKey<Object> PLAYER_RESPAWN_ITEMS_ITEMS = ConfigurationListKey.of(Object.class, "player-respawn-items", "items"); // Object in API, registered as Item
97+
ConfigurationListKey<Object> PLAYER_RESPAWN_ITEMS_ITEMS = ConfigurationListKey.of(Object.class, "player-respawn-items", "items"); // Object in API, registered as Item, TODO switch to ItemStackHolder
9998

10099
ConfigurationKey<Boolean> TARGET_BLOCK_RESPAWN_ANCHOR_FILL_ON_START = ConfigurationKey.of(Boolean.class, "target-block", "respawn-anchor", "fill-on-start");
101100
ConfigurationKey<Boolean> TARGET_BLOCK_RESPAWN_ANCHOR_ENABLE_DECREASE = ConfigurationKey.of(Boolean.class, "target-block", "respawn-anchor", "enable-decrease");

api/src/main/java/org/screamingsandals/bedwars/api/entities/EntitiesManager.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@
2020
package org.screamingsandals.bedwars.api.entities;
2121

2222
import org.jetbrains.annotations.ApiStatus;
23-
import org.screamingsandals.bedwars.api.game.Game;
23+
import org.screamingsandals.bedwars.api.game.LocalGame;
24+
import org.screamingsandals.lib.api.types.server.EntityHolder;
2425

2526
import java.util.List;
2627
import java.util.Optional;
2728

2829
@ApiStatus.NonExtendable
2930
public interface EntitiesManager {
3031

31-
List<? extends GameEntity> getEntities(Game game);
32+
List<? extends GameEntity> getEntities(LocalGame game);
3233

33-
default boolean isEntityInGame(Object entity) {
34+
default boolean isEntityInGame(EntityHolder entity) {
3435
return getGameOfEntity(entity).isPresent();
3536
}
3637

37-
Optional<? extends Game> getGameOfEntity(Object entity);
38+
Optional<? extends LocalGame> getGameOfEntity(EntityHolder entity);
3839

39-
GameEntity addEntityToGame(Object entity, Game game);
40+
GameEntity addEntityToGame(EntityHolder entity, LocalGame game);
4041

41-
void removeEntityFromGame(Object entity);
42+
void removeEntityFromGame(EntityHolder entity);
4243

4344
void removeEntityFromGame(GameEntity entityObject);
4445
}

api/src/main/java/org/screamingsandals/bedwars/api/entities/GameEntity.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
package org.screamingsandals.bedwars.api.entities;
2121

2222
import org.jetbrains.annotations.ApiStatus;
23-
import org.screamingsandals.bedwars.api.game.Game;
24-
import org.screamingsandals.lib.api.Wrapper;
23+
import org.screamingsandals.bedwars.api.game.LocalGame;
24+
import org.screamingsandals.lib.api.types.server.EntityHolder;
2525

2626
@ApiStatus.NonExtendable
2727
public interface GameEntity {
28-
Game getGame();
28+
LocalGame getGame();
2929

30-
Wrapper getEntity();
30+
EntityHolder getEntity();
3131
}

api/src/main/java/org/screamingsandals/bedwars/api/events/ApplyPropertyToBoughtItemEvent.java

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
import org.jetbrains.annotations.ApiStatus;
2323
import org.screamingsandals.bedwars.api.BedwarsAPI;
24-
import org.screamingsandals.bedwars.api.game.Game;
25-
import org.screamingsandals.bedwars.api.player.BWPlayer;
26-
import org.screamingsandals.lib.api.Wrapper;
2724

2825
import java.util.function.Consumer;
2926

api/src/main/java/org/screamingsandals/bedwars/api/events/ApplyPropertyToDisplayedItemEvent.java

-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
import org.jetbrains.annotations.ApiStatus;
2323
import org.screamingsandals.bedwars.api.BedwarsAPI;
24-
import org.screamingsandals.bedwars.api.game.Game;
25-
import org.screamingsandals.bedwars.api.player.BWPlayer;
26-
import org.screamingsandals.lib.api.Wrapper;
2724

2825
import java.util.function.Consumer;
2926

api/src/main/java/org/screamingsandals/bedwars/api/events/ApplyPropertyToItemEvent.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,27 @@
2121

2222
import org.jetbrains.annotations.ApiStatus;
2323
import org.screamingsandals.bedwars.api.BedwarsAPI;
24-
import org.screamingsandals.bedwars.api.game.Game;
24+
import org.screamingsandals.bedwars.api.game.LocalGame;
2525
import org.screamingsandals.bedwars.api.player.BWPlayer;
26-
import org.screamingsandals.bedwars.api.utils.EventUtils;
27-
import org.screamingsandals.lib.api.Wrapper;
26+
import org.screamingsandals.lib.api.types.server.ItemStackHolder;
2827

2928
import java.util.Map;
3029
import java.util.function.Consumer;
3130

3231
@ApiStatus.NonExtendable
3332
public interface ApplyPropertyToItemEvent {
34-
Game getGame();
33+
LocalGame getGame();
3534

3635
BWPlayer getPlayer();
3736

38-
Wrapper getStack();
37+
ItemStackHolder getStack();
3938

4039
String getPropertyName();
4140

4241
// TODO - Special wrapper for ConfigurationNodes
4342
Map<String, Object> getProperties();
4443

45-
/**
46-
*
47-
* @param stack wrapper or platform item
48-
*/
49-
void setStack(Object stack);
44+
void setStack(ItemStackHolder stack);
5045

5146
static void handle(Object plugin, Consumer<ApplyPropertyToItemEvent> consumer) {
5247
BedwarsAPI.getInstance().getEventUtils().handle(plugin, ApplyPropertyToItemEvent.class, consumer);

0 commit comments

Comments
 (0)