Skip to content

Commit

Permalink
chore(deps): Migrate to distributor 4
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Dec 3, 2024
1 parent 9463ca2 commit 4dd29ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
java = "17"

# utilities
distributor = "4.0.0-rc.3"
distributor = "4.0.1"
cloud = "2.0.0"
slf4md = "1.0.1"

Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/xpdustry/hexed/HexedCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.xpdustry.hexed;

import arc.util.CommandHandler;
import com.xpdustry.distributor.api.DistributorProvider;
import com.xpdustry.distributor.api.Distributor;
import com.xpdustry.distributor.api.command.CommandSender;
import com.xpdustry.distributor.api.command.cloud.MindustryCommandManager;
import com.xpdustry.distributor.api.plugin.MindustryPlugin;
Expand Down Expand Up @@ -63,11 +63,10 @@ public void onHexedStartCommand(
return;
}

final var generator =
DistributorProvider.get().getServiceManager().getProviders(HexedMapGenerator.class).stream()
.map(ServiceProvider::getInstance)
.filter(g -> g.getName().equals(name))
.findFirst();
final var generator = Distributor.get().getServiceManager().getProviders(HexedMapGenerator.class).stream()
.map(ServiceProvider::getInstance)
.filter(g -> g.getName().equals(name))
.findFirst();
if (generator.isEmpty()) {
sender.error("Generator named " + name + " not found.");
return;
Expand Down Expand Up @@ -122,7 +121,7 @@ public void onSpectateCommand(final CommandSender sender) {
return;
}
if (sender.getPlayer().team() != Team.derelict) {
DistributorProvider.get()
Distributor.get()
.getEventBus()
.post(new HexPlayerQuitEvent(
sender.getPlayer(), sender.getPlayer().team(), false));
Expand All @@ -139,7 +138,7 @@ public void onJoinCommand(final CommandSender sender) {
return;
}
if (sender.getPlayer().team() == Team.derelict) {
DistributorProvider.get().getEventBus().post(new HexPlayerJoinEvent(sender.getPlayer(), false));
Distributor.get().getEventBus().post(new HexPlayerJoinEvent(sender.getPlayer(), false));
} else {
sender.error("You are already in the game.");
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/xpdustry/hexed/HexedLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import arc.math.Mathf;
import arc.util.Interval;
import arc.util.Time;
import com.xpdustry.distributor.api.DistributorProvider;
import com.xpdustry.distributor.api.Distributor;
import com.xpdustry.distributor.api.annotation.EventHandler;
import com.xpdustry.distributor.api.collection.MindustryCollections;
import com.xpdustry.distributor.api.plugin.PluginListener;
Expand Down Expand Up @@ -64,7 +64,7 @@ public void onPluginInit() {

@EventHandler
public void onPlayerJoin(final EventType.PlayerJoin event) {
DistributorProvider.get().getEventBus().post(new HexPlayerJoinEvent(event.player, true));
Distributor.get().getEventBus().post(new HexPlayerJoinEvent(event.player, true));
}

@EventHandler
Expand Down Expand Up @@ -99,7 +99,7 @@ public void onPlayerJoin(final HexPlayerJoinEvent event) {

@EventHandler
public void onPlayerLeave(final EventType.PlayerLeave event) {
DistributorProvider.get().getEventBus().post(new HexPlayerQuitEvent(event.player, event.player.team(), false));
Distributor.get().getEventBus().post(new HexPlayerQuitEvent(event.player, event.player.team(), false));
}

@EventHandler
Expand Down Expand Up @@ -141,14 +141,14 @@ public void onPluginUpdate() {
if (oldController != newController && newController != null && newController != Team.derelict) {
final var player = Groups.player.find(p -> p.team() == newController);
if (player != null) {
DistributorProvider.get().getEventBus().post(new HexCaptureEvent(player, hex));
Distributor.get().getEventBus().post(new HexCaptureEvent(player, hex));
}
}

if (oldController != newController && oldController != null && oldController != Team.derelict) {
final var player = Groups.player.find(p -> p.team() == oldController);
if (player != null) {
DistributorProvider.get().getEventBus().post(new HexLostEvent(player, hex));
Distributor.get().getEventBus().post(new HexLostEvent(player, hex));
}
}
}
Expand All @@ -158,7 +158,7 @@ public void onPluginUpdate() {
for (final var player : Groups.player) {
if (player.team() != Team.derelict && player.team().cores().isEmpty()) {
final var oldTeam = player.team();
DistributorProvider.get().getEventBus().post(new HexPlayerQuitEvent(player, oldTeam, true));
Distributor.get().getEventBus().post(new HexPlayerQuitEvent(player, oldTeam, true));
}

if (player.team() == Team.derelict) {
Expand All @@ -183,7 +183,7 @@ public void onPluginUpdate() {
private void killTeam(final Team team) {
this.hexed.getHexedState0().setDying(team, true);
team.data().destroyToDerelict();
DistributorProvider.get()
Distributor.get()
.getPluginScheduler()
.schedule(this.hexed)
.delay(8, MindustryTimeUnit.SECONDS)
Expand All @@ -199,7 +199,7 @@ private void endGame() {
.filter(team -> team != Team.derelict)
.collect(maxList(Comparator.comparingInt(
team -> this.hexed.getHexedState().getControlled(team).size())));
final var bus = DistributorProvider.get().getEventBus();
final var bus = Distributor.get().getEventBus();
bus.post(new GameOverEvent(winners.size() == 1 ? winners.get(0) : Team.derelict));
bus.post(new HexedGameOverEvent(winners));
}
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/xpdustry/hexed/HexedPluginReloaded.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package com.xpdustry.hexed;

import com.xpdustry.distributor.api.DistributorProvider;
import com.xpdustry.distributor.api.Distributor;
import com.xpdustry.distributor.api.annotation.PluginAnnotationProcessor;
import com.xpdustry.distributor.api.plugin.AbstractMindustryPlugin;
import com.xpdustry.distributor.api.plugin.PluginListener;
Expand Down Expand Up @@ -71,9 +71,7 @@ public boolean start(final MapGenerator<HexedMapContext> generator) {

@Override
public void onInit() {
DistributorProvider.get()
.getServiceManager()
.register(this, HexedMapGenerator.class, new AnukeHexedGenerator());
Distributor.get().getServiceManager().register(this, HexedMapGenerator.class, new AnukeHexedGenerator());
this.addListener(new HexedLogic(this));
this.addListener(new HexedRenderer(this));
this.addListener(new HexedCommands(this));
Expand Down

0 comments on commit 4dd29ee

Please sign in to comment.