-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfd9d34
commit eb477f7
Showing
4 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package eu.avalanche7; | ||
|
||
import eu.avalanche7.datastore.DataStoreManager; | ||
import eu.avalanche7.datastore.IDataStore; | ||
import eu.avalanche7.datastore.PlayerData; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.OfflinePlayer; | ||
|
||
|
||
public class PlaceHolderIntegration extends PlaceholderExpansion { | ||
|
||
private final BetterChunkLoader plugin; | ||
|
||
public PlaceHolderIntegration(BetterChunkLoader plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean canRegister() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return "chunkloader"; | ||
} | ||
|
||
@Override | ||
public String getAuthor() { | ||
return plugin.getDescription().getAuthors().toString(); | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return plugin.getDescription().getVersion(); | ||
} | ||
|
||
@Override | ||
public String onRequest(OfflinePlayer player, String identifier) { | ||
if (player == null) { | ||
return null; | ||
} | ||
|
||
IDataStore dataStore = DataStoreManager.getDataStore(); | ||
PlayerData playerData = dataStore.getPlayerData(player.getUniqueId()); | ||
|
||
switch (identifier) { | ||
case "chunks_total": | ||
return String.valueOf(playerData.getAlwaysOnChunksAmount() + playerData.getOnlineOnlyChunksAmount()); | ||
case "chunks_active": | ||
return String.valueOf(dataStore.getChunkLoaders(player.getUniqueId()).size()); | ||
case "chunks_onlineonly_active": | ||
return String.valueOf(dataStore.getOnlineOnlyFreeChunksAmount(player.getUniqueId())); | ||
case "chunks_alwayson_active": | ||
return String.valueOf(dataStore.getAlwaysOnFreeChunksAmount(player.getUniqueId())); | ||
case "chunks_alwaysonly": | ||
return String.valueOf(playerData.getAlwaysOnChunksAmount()); | ||
case "chunks_onlineonly": | ||
return String.valueOf(playerData.getOnlineOnlyChunksAmount()); | ||
default: | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters