File tree 3 files changed +29
-0
lines changed
main/java/world/bentobox/bentobox
test/java/world/bentobox/bentobox/listeners
3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,24 @@ public void onPlayerJoin(final PlayerJoinEvent event) {
105
105
106
106
// Add a player to the bStats cache.
107
107
plugin .getMetrics ().ifPresent (bStats -> bStats .addPlayer (playerUUID ));
108
+
109
+ // Create onIsland placeholders
110
+ plugin .getAddonsManager ().getGameModeAddons ().forEach (addon -> {
111
+ plugin .getPlaceholdersManager ()
112
+ .registerPlaceholder (addon , "onisland_" + user .getName (), asker -> {
113
+ if (asker == null ) {
114
+ return "" ;
115
+ }
116
+ // Get the user who this applies to
117
+ User named = User .getInstance (user .getUniqueId ());
118
+ if (named .isOnline ()) {
119
+ return plugin .getIslands ().getIslands (addon .getOverWorld (), asker ).stream ()
120
+ .filter (island -> island .onIsland (named .getLocation ())).findFirst ().map (i -> "true" )
121
+ .orElse ("false" );
122
+ }
123
+ return "false" ;
124
+ });
125
+ });
108
126
}
109
127
110
128
private void firstTime (User user ) {
@@ -237,6 +255,9 @@ public void onPlayerQuit(final PlayerQuitEvent event) {
237
255
});
238
256
// Remove any coop associations from the player logging out
239
257
plugin .getIslands ().clearRank (RanksManager .COOP_RANK , event .getPlayer ().getUniqueId ());
258
+ // Remove any onisland placeholder
259
+ plugin .getAddonsManager ().getGameModeAddons ().forEach (addon -> plugin .getPlaceholdersManager ()
260
+ .unregisterPlaceholder (addon , "onisland_" + event .getPlayer ().getName ()));
240
261
User .removePlayer (event .getPlayer ());
241
262
}
242
263
}
Original file line number Diff line number Diff line change 19
19
20
20
/**
21
21
* Common Game Mode Placeholders
22
+ * All of these are prefixed with the game mode's name, e.g., bskykblock_
22
23
*/
23
24
public enum GameModePlaceholder {
24
25
Original file line number Diff line number Diff line change 52
52
import world .bentobox .bentobox .api .user .User ;
53
53
import world .bentobox .bentobox .database .objects .Island ;
54
54
import world .bentobox .bentobox .database .objects .Players ;
55
+ import world .bentobox .bentobox .managers .AddonsManager ;
55
56
import world .bentobox .bentobox .managers .IslandWorldManager ;
56
57
import world .bentobox .bentobox .managers .IslandsManager ;
57
58
import world .bentobox .bentobox .managers .LocalesManager ;
@@ -107,6 +108,9 @@ public class JoinLeaveListenerTest {
107
108
@ Mock
108
109
private @ NonNull Location location ;
109
110
111
+ @ Mock
112
+ private AddonsManager am ;
113
+
110
114
/**
111
115
*/
112
116
@ Before
@@ -218,6 +222,9 @@ public void setUp() throws Exception {
218
222
when (phm .replacePlaceholders (any (), anyString ()))
219
223
.thenAnswer ((Answer <String >) invocation -> invocation .getArgument (1 , String .class ));
220
224
225
+ // Addons manager
226
+ when (plugin .getAddonsManager ()).thenReturn (am );
227
+
221
228
jll = new JoinLeaveListener (plugin );
222
229
}
223
230
You can’t perform that action at this time.
0 commit comments