Skip to content

Commit a218b48

Browse files
Update to Minecraft 1.21.8 (#22)
* Update several dependencies to their latest version * Update constant usage * Remove enforced usage of adventure * Update aonyx bom * Update SetupData access in the command part * Update implementation to the new structure from Guira * Update setup data access * Update MapProvider import * Migrate click handling * Update builder integration * Update SetupData handling * Update component import * Update method usage * Update provider import * Update key import * Update data component import * Update data component import * Add dialogs for the setup * Add listener to handle dialog inputs * Add new tag * Init new registry * Fix compile issues * Implement dialog trigger into the slots implementations and inventory * Update used event and listeners * Improve dialogs * Add new method * Register new listener * Improve code structure * Update author handling in the builder and map class * Update method call * Improve dialog part * Update method call in the commands * Improve click handling * Update method call * Improve dialog related listeners * Add new listener * Remove obsolete parts of the setup command * Add a new dialog for the push input * Add event call to open the dialog * Update dialog handling * Remove right click constant * Remove debug message * Remove tag after dialog close * Comment out test case * Fix test execution --------- Co-authored-by: theEvilReaper <[email protected]>
1 parent 47b92a7 commit a218b48

File tree

61 files changed

+1096
-468
lines changed

Some content is hidden

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

61 files changed

+1096
-468
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ dependencies {
1313
implementation(project(":common"))
1414
implementation(platform(libs.mycelium.bom))
1515
implementation(platform(libs.aonyx.bom))
16-
implementation(enforcedPlatform("net.kyori:adventure-bom:4.20.0"))
1716
implementation(libs.adventure)
1817
implementation(libs.pvp)
1918
implementation(libs.minestom)

common/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ java {
1414
dependencies {
1515
implementation(platform(libs.mycelium.bom))
1616
implementation(platform(libs.aonyx.bom))
17-
implementation(enforcedPlatform("net.kyori:adventure-bom:4.20.0"))
1817
compileOnly(libs.adventure)
1918
compileOnly(libs.minestom)
2019
compileOnly(libs.aves)

common/src/main/java/net/theevilreaper/bounce/common/ListenerHandling.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import net.minestom.server.event.player.PlayerBlockInteractEvent;
88
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
99
import net.minestom.server.event.player.PlayerSwapItemEvent;
10-
import net.theevilreaper.aves.inventory.util.InventoryConstants;
10+
import net.minestom.server.event.trait.CancellableEvent;
1111
import org.jetbrains.annotations.NotNull;
1212

13+
import java.util.function.Consumer;
14+
1315
/**
1416
* The interface provides a default method to register some listeners to cancel specific events.
1517
*
@@ -19,16 +21,18 @@
1921
*/
2022
public interface ListenerHandling {
2123

24+
Consumer<CancellableEvent> CANCELLABLE_EVENT = event -> event.setCancelled(true);
25+
2226
/**
2327
* Registers some {@link Event} listener to cancel specific default events.
2428
*
2529
* @param eventNode the event node to register the listeners
2630
*/
2731
default void registerCancelListener(@NotNull EventNode<Event> eventNode) {
28-
eventNode.addListener(PlayerBlockBreakEvent.class, InventoryConstants.CANCELLABLE_EVENT::accept);
29-
eventNode.addListener(PlayerBlockPlaceEvent.class, InventoryConstants.CANCELLABLE_EVENT::accept);
30-
eventNode.addListener(ItemDropEvent.class, InventoryConstants.CANCELLABLE_EVENT::accept);
31-
eventNode.addListener(PlayerSwapItemEvent.class, InventoryConstants.CANCELLABLE_EVENT::accept);
32-
eventNode.addListener(PlayerBlockInteractEvent.class, InventoryConstants.CANCELLABLE_EVENT::accept);
32+
eventNode.addListener(PlayerBlockBreakEvent.class, CANCELLABLE_EVENT::accept);
33+
eventNode.addListener(PlayerBlockPlaceEvent.class, CANCELLABLE_EVENT::accept);
34+
eventNode.addListener(ItemDropEvent.class, CANCELLABLE_EVENT::accept);
35+
eventNode.addListener(PlayerSwapItemEvent.class, CANCELLABLE_EVENT::accept);
36+
eventNode.addListener(PlayerBlockInteractEvent.class, CANCELLABLE_EVENT::accept);
3337
}
3438
}

common/src/main/java/net/theevilreaper/bounce/common/map/GameMap.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ public final class GameMap extends BaseMap {
2828
* @param gameSpawn the spawn position during the game
2929
* @param pushData the {@link PushData} which includes information about push values
3030
*/
31-
public GameMap(@NotNull String name, @NotNull Pos spawn, @NotNull Pos gameSpawn, @NotNull PushData pushData) {
32-
super(name, spawn, "Team");
31+
public GameMap(@NotNull String name, @NotNull Pos spawn, @NotNull Pos gameSpawn, @NotNull PushData pushData, @NotNull String... builders) {
32+
super(name, spawn, builders);
3333
this.gameSpawn = gameSpawn;
3434
this.pushData = pushData;
35+
3536
}
3637

3738
/**

settings.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ dependencyResolutionManagement {
2828
versionCatalogs {
2929
create("libs") {
3030
version("shadow", "8.3.8")
31-
version("bom", "1.2.4")
32-
version("aonyx", "0.3.1")
33-
version("pvp", "dfb8f0c342")
31+
version("bom", "1.4.2")
32+
version("aonyx", "0.5.1")
33+
version("pvp", "56a831b41c")
3434

3535
library("mycelium.bom", "net.onelitefeather", "mycelium-bom").versionRef("bom")
3636
library("aonyx.bom", "net.onelitefeather", "aonyx-bom").versionRef("aonyx")
3737

3838
library("pvp", "com.github.TogAr2", "MinestomPvP").versionRef("pvp")
39-
library("minestom", "net.minestom", "minestom-snapshots").withoutVersion()
39+
library("minestom", "net.minestom", "minestom").withoutVersion()
4040
library("adventure", "net.kyori", "adventure-text-minimessage").withoutVersion()
4141
library("cyano", "net.onelitefeather", "cyano").withoutVersion()
4242
library("guira", "net.onelitefeather", "guira").withoutVersion()

setup/src/main/java/net/theevilreaper/bounce/setup/BounceSetup.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,36 @@
55
import net.minestom.server.event.EventNode;
66
import net.minestom.server.event.GlobalEventHandler;
77
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
8-
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
9-
import net.minestom.server.event.player.PlayerDisconnectEvent;
10-
import net.minestom.server.event.player.PlayerSpawnEvent;
11-
import net.minestom.server.event.player.PlayerUseItemEvent;
8+
import net.minestom.server.event.player.*;
129
import net.minestom.server.instance.Instance;
1310
import net.onelitefeather.guira.SetupDataService;
1411
import net.onelitefeather.guira.event.SetupFinishEvent;
1512
import net.theevilreaper.aves.file.FileHandler;
1613
import net.theevilreaper.aves.file.GsonFileHandler;
17-
import net.theevilreaper.aves.map.MapProvider;
14+
import net.theevilreaper.aves.map.provider.MapProvider;
1815
import net.theevilreaper.aves.util.functional.PlayerConsumer;
1916
import net.theevilreaper.bounce.common.ListenerHandling;
2017
import net.theevilreaper.bounce.common.util.GsonUtil;
2118
import net.theevilreaper.bounce.setup.command.GameModeCommand;
2219
import net.theevilreaper.bounce.setup.command.SetupCommand;
23-
import net.theevilreaper.bounce.setup.data.BounceData;
20+
import net.theevilreaper.bounce.setup.dialog.DialogRegistry;
21+
import net.theevilreaper.bounce.setup.dialog.SetupDialogRegistry;
22+
import net.theevilreaper.bounce.setup.dialog.event.PlayerDialogRequestEvent;
2423
import net.theevilreaper.bounce.setup.event.AbstractStateNotifyEvent;
2524
import net.theevilreaper.bounce.setup.event.map.MapSetupSelectEvent;
2625
import net.theevilreaper.bounce.setup.event.ground.PlayerGroundBlockSelectEvent;
2726
import net.theevilreaper.bounce.setup.event.SetupInventorySwitchEvent;
27+
import net.theevilreaper.bounce.setup.event.map.PlayerDeletePromptEvent;
2828
import net.theevilreaper.bounce.setup.event.push.PlayerPushBlockSelectEvent;
2929
import net.theevilreaper.bounce.setup.event.push.PlayerPushIndexChangeEvent;
3030
import net.theevilreaper.bounce.setup.inventory.InventoryService;
3131
import net.theevilreaper.bounce.setup.listener.PlayerConfigurationListener;
3232
import net.theevilreaper.bounce.setup.listener.PlayerDisconnectListener;
3333
import net.theevilreaper.bounce.setup.listener.PlayerItemListener;
3434
import net.theevilreaper.bounce.setup.listener.PlayerSpawnListener;
35+
import net.theevilreaper.bounce.setup.listener.dialog.PlayerCustomClickEventListener;
36+
import net.theevilreaper.bounce.setup.listener.dialog.PlayerDeletePromptListener;
37+
import net.theevilreaper.bounce.setup.listener.dialog.PlayerDialogRequestListener;
3538
import net.theevilreaper.bounce.setup.listener.entity.EntityAddToInstanceListener;
3639
import net.theevilreaper.bounce.setup.listener.ground.PlayerBlockSelectListener;
3740
import net.theevilreaper.bounce.setup.listener.inventory.SetupInventorySwitchListener;
@@ -53,10 +56,11 @@
5356
public final class BounceSetup implements ListenerHandling {
5457

5558
private final MapProvider mapProvider;
56-
private final SetupDataService<BounceData> setupDataService;
59+
private final SetupDataService setupDataService;
5760
private final InventoryService inventoryService;
5861
private final SetupItems setupItems;
5962
private final FileHandler fileHandler;
63+
private final DialogRegistry dialogRegistry;
6064

6165
public BounceSetup() {
6266
Path path = Path.of("");
@@ -65,6 +69,7 @@ public BounceSetup() {
6569
this.inventoryService = new InventoryService(this.mapProvider::getEntries);
6670
this.setupItems = new SetupItems();
6771
this.fileHandler = new GsonFileHandler(GsonUtil.GSON);
72+
this.dialogRegistry = new SetupDialogRegistry();
6873
MinecraftServer.getSchedulerManager().buildShutdownTask(this::onShutdown);
6974
}
7075

@@ -97,19 +102,16 @@ private void registerListener(@NotNull EventNode<Event> node) {
97102
setupItems.setOverViewItem(player);
98103
};
99104

100-
node.addListener(
101-
(Class<SetupFinishEvent<BounceData>>) (Class<?>) SetupFinishEvent.class,
102-
new SetupFinishListener(instanceSwitcher)
103-
);
104-
105+
node.addListener(SetupFinishEvent.class, new SetupFinishListener(instanceSwitcher));
105106
node.addListener(PlayerGroundBlockSelectEvent.class, new PlayerBlockSelectListener(this.setupDataService::get));
106107
node.addListener(SetupInventorySwitchEvent.class, new SetupInventorySwitchListener(this.inventoryService, this.setupDataService::get));
107108
node.addListener(GameMapBuilderStateNotifyEvent.class, new GameMapBuilderStateNotifyListener());
108109
node.addListener(AbstractStateNotifyEvent.PushDataStateNotifyEvent.class, new PushValueStateNotifierListener());
109-
110110
node.addListener(PlayerPushBlockSelectEvent.class, new PlayerPushBlockSelectListener(this.setupDataService::get));
111111
node.addListener(PlayerPushIndexChangeEvent.class, new PlayerPushIndexChangeListener(this.setupDataService::get));
112-
112+
node.addListener(PlayerDeletePromptEvent.class, new PlayerDeletePromptListener(dialogRegistry));
113+
node.addListener(PlayerCustomClickEvent.class, new PlayerCustomClickEventListener(this.dialogRegistry, this.setupDataService::get));
114+
node.addListener(PlayerDialogRequestEvent.class, new PlayerDialogRequestListener(this.dialogRegistry));
113115
node.addListener(AddEntityToInstanceEvent.class, new EntityAddToInstanceListener(instanceSupplier, setupItems));
114116

115117
}

setup/src/main/java/net/theevilreaper/bounce/setup/builder/GameMapBuilder.java

Lines changed: 18 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,29 @@
22

33
import net.minestom.server.coordinate.Pos;
44
import net.minestom.server.instance.block.Block;
5+
import net.theevilreaper.aves.map.BaseMapBuilder;
56
import net.theevilreaper.bounce.common.map.GameMap;
67
import net.theevilreaper.bounce.common.push.PushData;
78
import net.theevilreaper.bounce.common.push.PushEntry;
89
import org.jetbrains.annotations.NotNull;
910

10-
import java.util.ArrayList;
11-
import java.util.List;
11+
public final class GameMapBuilder extends BaseMapBuilder {
1212

13-
public final class GameMapBuilder {
14-
15-
private final List<String> authors;
1613
private final PushData.Builder pushDataBuilder;
17-
private String name;
18-
private Pos spawn;
1914
private Pos gameSpawn;
2015

2116
public GameMapBuilder() {
17+
super();
2218
this.pushDataBuilder = PushData.builder();
2319
this.pushDataBuilder
2420
.add(PushEntry.groundEntry(Block.GLASS, 1))
2521
.add(PushEntry.pushEntry(Block.GOLD_BLOCK, 1))
2622
.add(PushEntry.pushEntry(Block.DIAMOND_BLOCK, 1))
2723
.add(PushEntry.pushEntry(Block.EMERALD_BLOCK, 1));
28-
this.authors = new ArrayList<>();
2924
}
3025

3126
public GameMapBuilder(@NotNull GameMap gameMap) {
32-
this.name = gameMap.getName();
33-
if (gameMap.getBuilders() != null) {
34-
this.authors = new ArrayList<>(List.of(gameMap.getBuilders()));
35-
} else {
36-
this.authors = new ArrayList<>();
37-
}
38-
this.spawn = gameMap.getSpawn();
27+
super(gameMap);
3928
this.gameSpawn = gameMap.getGameSpawn();
4029

4130
if (gameMap.getPushData() == null) {
@@ -51,72 +40,43 @@ public GameMapBuilder(@NotNull GameMap gameMap) {
5140
}
5241

5342
/**
54-
* Sets the name of the map.
43+
* Sets the ground block for the map.
5544
*
56-
* @param name the name of the map
45+
* @param groundBlock the block to set as the ground block
5746
* @return this builder instance for chaining
5847
*/
59-
public @NotNull GameMapBuilder setName(String name) {
60-
this.name = name;
48+
public @NotNull GameMapBuilder groundBlock(Block groundBlock) {
49+
PushEntry pushEntry = this.pushDataBuilder.getPushValues().getFirst();
50+
pushEntry.setBlock(groundBlock);
6151
return this;
6252
}
6353

6454
/**
65-
* Adds authors to the map.
55+
* Sets the spawn position for the map.
6656
*
67-
* @param authors the authors to add
57+
* @param gameSpawn the spawn position
6858
* @return this builder instance for chaining
6959
*/
70-
public @NotNull GameMapBuilder addAuthors(String... authors) {
71-
this.authors.addAll(List.of(authors));
60+
public @NotNull GameMapBuilder gameSpawn(Pos gameSpawn) {
61+
this.gameSpawn = gameSpawn;
7262
return this;
7363
}
7464

7565
/**
76-
* Sets the ground block for the map.
77-
*
78-
* @param groundBlock the block to set as the ground block
79-
* @return this builder instance for chaining
66+
* Clears all builders from the data structure.
8067
*/
81-
public @NotNull GameMapBuilder setGroundBlock(Block groundBlock) {
82-
PushEntry pushEntry = this.pushDataBuilder.getPushValues().getFirst();
83-
pushEntry.setBlock(groundBlock);
84-
return this;
85-
}
86-
87-
public @NotNull GameMapBuilder addAuthor(String author) {
88-
if (!this.authors.contains(author)) {
89-
this.authors.add(author);
90-
}
91-
return this;
92-
}
93-
94-
public @NotNull GameMapBuilder setSpawn(Pos spawn) {
95-
this.spawn = spawn;
96-
return this;
97-
}
98-
99-
public @NotNull GameMapBuilder setGameSpawn(Pos gameSpawn) {
100-
this.gameSpawn = gameSpawn;
101-
return this;
68+
public void clearBuilders() {
69+
this.builders.clear();
10270
}
10371

10472
/**
10573
* Builds a new {@link GameMap} instance with the current properties.
10674
*
10775
* @return a new GameMap instance
10876
*/
77+
@Override
10978
public @NotNull GameMap build() {
110-
return new GameMap(this.name, this.spawn, this.gameSpawn, pushDataBuilder.build());
111-
}
112-
113-
/**
114-
* Returns the name of the map.
115-
*
116-
* @return the name of the map
117-
*/
118-
public String getName() {
119-
return name;
79+
return new GameMap(this.name, this.spawn, this.gameSpawn, pushDataBuilder.build(), this.builders.toArray(String[]::new));
12080
}
12181

12282
/**
@@ -128,24 +88,6 @@ public Pos getGameSpawn() {
12888
return gameSpawn;
12989
}
13090

131-
/**
132-
* Returns the spawn position of the map.
133-
*
134-
* @return the spawn position
135-
*/
136-
public Pos getSpawn() {
137-
return spawn;
138-
}
139-
140-
/**
141-
* Returns the list of authors for the map.
142-
*
143-
* @return the list of authors
144-
*/
145-
public @NotNull List<String> getAuthors() {
146-
return authors;
147-
}
148-
14991
/**
15092
* Returns the {@link PushData.Builder} instance used to build push data.
15193
*

setup/src/main/java/net/theevilreaper/bounce/setup/command/SetupCommand.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@
33
import net.minestom.server.command.builder.Command;
44
import net.minestom.server.command.builder.condition.Conditions;
55
import net.onelitefeather.guira.SetupDataService;
6-
import net.theevilreaper.bounce.setup.command.part.SetupBuildersCommand;
7-
import net.theevilreaper.bounce.setup.command.part.SetupNameCommand;
86
import net.theevilreaper.bounce.setup.command.part.SetupPositionCommand;
9-
import net.theevilreaper.bounce.setup.data.BounceData;
107
import org.jetbrains.annotations.NotNull;
118

9+
/**
10+
* The {@link SetupCommand} is the root command for the setup process in the game.
11+
*
12+
* @author theEvilReaper
13+
* @version 1.0.0
14+
* @since 1.0.0
15+
*/
1216
public class SetupCommand extends Command {
1317

14-
public SetupCommand(@NotNull SetupDataService<BounceData> dataService) {
18+
/**
19+
* Creates the command to allow players to initialize different parts of the game.
20+
*
21+
* @param dataService the service to get the setup data
22+
*/
23+
public SetupCommand(@NotNull SetupDataService dataService) {
1524
super("setup");
1625
this.setCondition(Conditions::playerOnly);
17-
this.addSubcommand(new SetupNameCommand(dataService::get));
18-
this.addSubcommand(new SetupBuildersCommand(dataService::get));
1926
this.addSubcommand(new SetupPositionCommand(dataService::get));
2027
}
2128
}

0 commit comments

Comments
 (0)