Skip to content

Commit

Permalink
Implement new placeholder: %border_type%
Browse files Browse the repository at this point in the history
Requested by #86
  • Loading branch information
BONNe committed Jul 14, 2022
1 parent fe152df commit b86ade9
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/main/java/world/bentobox/border/Border.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.util.Util;
import world.bentobox.border.commands.IslandBorderCommand;
import world.bentobox.border.listeners.BorderShower;
Expand Down Expand Up @@ -55,8 +56,9 @@ public void onEnable() {
});

if (!gameModes.isEmpty()) {
borderShower = createBorder();
registerListener(new PlayerListener(this));
borderShower = this.createBorder();
this.registerListener(new PlayerListener(this));
this.registerPlaceholders();
}
}

Expand Down Expand Up @@ -107,4 +109,24 @@ public boolean inGameWorld(World world) {
public Set<BorderType> getAvailableBorderTypesView() {
return Collections.unmodifiableSet(availableBorderTypes);
}


/**
* Placeholder registration.
*/
private void registerPlaceholders()
{
if (this.getPlugin().getPlaceholdersManager() == null)
{
return;
}

// Border is per player, not per gamemode.
this.getPlugin().getPlaceholdersManager().registerPlaceholder(this,
"type",
user -> BorderType.fromId(user.getMetaData(PerPlayerBorderProxy.BORDER_BORDERTYPE_META_DATA).
orElse(new MetaDataValue(BorderType.VANILLA.getId())).asByte()).
orElse(BorderType.VANILLA).
getCommandLabel());
}
}

0 comments on commit b86ade9

Please sign in to comment.