Skip to content

Commit

Permalink
Adapt community branch changes (#38)
Browse files Browse the repository at this point in the history
* Build with PGMDev/PGM#722

Signed-off-by: BT (calcastor/mame) <[email protected]>

* Don't import java.util.*

Signed-off-by: BT (calcastor/mame) <[email protected]>

* Add java.util.Map import

* Update README.md

* Update pom.xml

Co-authored-by: BT (calcastor/mame) <[email protected]>
  • Loading branch information
Indicardo and calcastor authored Jun 17, 2022
1 parent 0264cf6 commit 3b51c33
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Ingame

> **WARNING**: Ingame only works with the community branch of [PGM](https://github.com/applenick/PGM/tree/community) and [Events](https://github.com/bolt-rip/events).
Plugin used to manage competitive matches on bolt.rip.

Used alongside [Events](https://github.com/PGMDev/Events) which handles teams and matches.
Used alongside [Events](https://github.com/bolt-rip/Events) which handles teams and matches.

### Permissions

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>tc.oc.pgm</groupId>
<artifactId>core</artifactId>
<version>0.14-SNAPSHOT</version>
<groupId>com.github.applenick</groupId>
<artifactId>PGM</artifactId>
<version>community-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/rip/bolt/ingame/ranked/RankManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -37,6 +40,7 @@
import tc.oc.pgm.api.party.Party;
import tc.oc.pgm.api.player.MatchPlayer;
import tc.oc.pgm.events.PlayerPartyChangeEvent;
import tc.oc.pgm.stats.PlayerStats;
import tc.oc.pgm.util.bukkit.OnlinePlayerMapAdapter;

public class RankManager implements Listener {
Expand Down Expand Up @@ -91,7 +95,8 @@ public void handleMatchUpdate(@Nonnull BoltMatch oldMatch, @Nonnull BoltMatch ne
if (updates.isEmpty()) return;

Match match = updates.get(0).player.getMatch();
Bukkit.getServer().getPluginManager().callEvent(new MatchStatsEvent(match, true, true));
Map<UUID, PlayerStats> stats = new HashMap<>();
Bukkit.getServer().getPluginManager().callEvent(new MatchStatsEvent(match, true, true, stats));

if (AppData.Web.getMatch() != null) {
match.sendMessage(Messages.matchLink(newMatch));
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/rip/bolt/ingame/ranked/SpectatorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
import rip.bolt.ingame.Ingame;
import rip.bolt.ingame.events.BoltMatchStatusChangeEvent;
import tc.oc.pgm.api.PGM;
import tc.oc.pgm.api.integration.Integration;
import tc.oc.pgm.api.player.MatchPlayer;
import tc.oc.pgm.api.player.VanishManager;
import tc.oc.pgm.events.PlayerJoinMatchEvent;

public class SpectatorManager implements Listener {

private static final String SPECTATE_VANISH = "events.spectate.vanish";
private static final String PGM_VANISH = "pgm.vanish";

private final VanishManager vanishManager;
private final PlayerWatcher watcher;

private final HashMap<UUID, PermissionAttachment> permissions = new HashMap<>();

public SpectatorManager(PlayerWatcher playerWatcher) {
this.watcher = playerWatcher;
vanishManager = PGM.get().getVanishManager();
}

@EventHandler(priority = EventPriority.MONITOR)
Expand Down Expand Up @@ -71,20 +68,20 @@ private void vanish(Player player) {
player.getUniqueId(), uuid -> player.addAttachment(Ingame.get(), SPECTATE_VANISH, true));

// Set vanish if not already
if (vanishManager.isVanished(player.getUniqueId())) return;
if (Integration.isVanished(player)) return;

MatchPlayer matchPlayer = PGM.get().getMatchManager().getPlayer(player);
vanishManager.setVanished(matchPlayer, true, true);
Integration.setVanished(matchPlayer, true, true);
}

private void unvanish(Player player) {
PermissionAttachment attachment = permissions.remove(player.getUniqueId());
if (attachment != null) attachment.remove();

// Remove vanish if not already
if (!vanishManager.isVanished(player.getUniqueId())) return;
if (!Integration.isVanished(player)) return;

MatchPlayer matchPlayer = PGM.get().getMatchManager().getPlayer(player);
vanishManager.setVanished(matchPlayer, false, true);
Integration.setVanished(matchPlayer, false, true);
}
}
2 changes: 1 addition & 1 deletion src/main/java/rip/bolt/ingame/ranked/TabManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tc.oc.pgm.tablist.MapTabEntry;
import tc.oc.pgm.tablist.MatchFooterTabEntry;
import tc.oc.pgm.tablist.MatchTabManager;
import tc.oc.pgm.util.tablist.PlayerTabEntry;
import tc.oc.pgm.tablist.PlayerTabEntry;

public class TabManager {

Expand Down

0 comments on commit 3b51c33

Please sign in to comment.