Fixed indentation in GameModePlaceholderManager

This commit is contained in:
Florian CUNY 2019-04-07 09:33:50 +02:00
parent 01e1147c7f
commit 00546c2cb6

View File

@ -17,23 +17,23 @@ import java.util.Map;
* @since 1.4.0 * @since 1.4.0
*/ */
public class GameModePlaceholderManager { public class GameModePlaceholderManager {
private BentoBox plugin;
public GameModePlaceholderManager(BentoBox plugin) { private BentoBox plugin;
super();
this.plugin = plugin; public GameModePlaceholderManager(BentoBox plugin) {
} super();
this.plugin = plugin;
public void registerGameModePlaceholders(GameModeAddon addon) { }
String prefix = addon.getDescription().getName().toLowerCase();
Map<GameModePlaceholders, String> placeholders = new EnumMap<>(GameModePlaceholders.class); public void registerGameModePlaceholders(GameModeAddon addon) {
Arrays.stream(GameModePlaceholders.values()).forEach(placeholder -> placeholders.put(placeholder, prefix + "-" + placeholder.getPlaceholder())); String prefix = addon.getDescription().getName().toLowerCase();
Map<GameModePlaceholders, String> placeholders = new EnumMap<>(GameModePlaceholders.class);
// Register placeholders only if they have not already been registered by the addon itself Arrays.stream(GameModePlaceholders.values()).forEach(placeholder -> placeholders.put(placeholder, prefix + "-" + placeholder.getPlaceholder()));
placeholders.entrySet().stream().filter(en -> !plugin.getPlaceholdersManager().isPlaceholder(addon, en.getValue()))
.forEach(en -> plugin.getPlaceholdersManager().registerPlaceholder(en.getValue(), new DefaultPlaceholder(addon, en.getKey()))); // Register placeholders only if they have not already been registered by the addon itself
} placeholders.entrySet().stream().filter(en -> !plugin.getPlaceholdersManager().isPlaceholder(addon, en.getValue()))
.forEach(en -> plugin.getPlaceholdersManager().registerPlaceholder(en.getValue(), new DefaultPlaceholder(addon, en.getKey())));
}
} }
/** /**
@ -42,28 +42,28 @@ public class GameModePlaceholderManager {
* @since 1.4.0 * @since 1.4.0
*/ */
class DefaultPlaceholder implements PlaceholderReplacer { class DefaultPlaceholder implements PlaceholderReplacer {
private final GameModeAddon addon; private final GameModeAddon addon;
private final GameModePlaceholders type; private final GameModePlaceholders type;
public DefaultPlaceholder(GameModeAddon addon, GameModePlaceholders type) { public DefaultPlaceholder(GameModeAddon addon, GameModePlaceholders type) {
super(); super();
this.addon = addon; this.addon = addon;
this.type = type; this.type = type;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see world.bentobox.bentobox.api.placeholders.PlaceholderReplacer#onReplace(world.bentobox.bentobox.api.user.User) * @see world.bentobox.bentobox.api.placeholders.PlaceholderReplacer#onReplace(world.bentobox.bentobox.api.user.User)
*/ */
@Override @Override
public String onReplace(User user) { public String onReplace(User user) {
if (user == null) { if (user == null) {
return ""; return "";
} }
Island island = addon.getIslands().getIsland(addon.getOverWorld(), user); Island island = addon.getIslands().getIsland(addon.getOverWorld(), user);
if (island == null) { if (island == null) {
return ""; return "";
} }
return type.getReplacer().onReplace(addon, user, island); return type.getReplacer().onReplace(addon, user, island);
} }
} }