Implemented %plan_player_favorite_server% placeholder

Requested on Discord in priority-support.
This commit is contained in:
Rsl1122 2020-01-24 10:45:26 +02:00
parent 73343f8d20
commit d731919b26

View File

@ -18,15 +18,18 @@ package com.djrapitops.plan.addons.placeholderapi.placeholders;
import com.djrapitops.plan.delivery.domain.container.PlayerContainer; import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys; import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
import com.djrapitops.plan.delivery.domain.mutators.PerServerMutator;
import com.djrapitops.plan.delivery.domain.mutators.PingMutator; import com.djrapitops.plan.delivery.domain.mutators.PingMutator;
import com.djrapitops.plan.delivery.domain.mutators.PlayerVersusMutator; import com.djrapitops.plan.delivery.domain.mutators.PlayerVersusMutator;
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator; import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
import com.djrapitops.plan.delivery.formatting.Formatter; import com.djrapitops.plan.delivery.formatting.Formatter;
import com.djrapitops.plan.delivery.formatting.Formatters; import com.djrapitops.plan.delivery.formatting.Formatters;
import com.djrapitops.plan.gathering.cache.SessionCache; import com.djrapitops.plan.gathering.cache.SessionCache;
import com.djrapitops.plan.identification.Server;
import com.djrapitops.plan.identification.ServerInfo; import com.djrapitops.plan.identification.ServerInfo;
import com.djrapitops.plan.storage.database.DBSystem; import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries; import com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries;
import com.djrapitops.plan.storage.database.queries.objects.ServerQueries;
import com.djrapitops.plan.utilities.Predicates; import com.djrapitops.plan.utilities.Predicates;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -154,6 +157,12 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
.filterPlayedOnServer(serverUUID()) .filterPlayedOnServer(serverUUID())
.toPlaytime()); .toPlaytime());
case "player_favorite_server":
return PerServerMutator.forContainer(player).favoriteServer()
.flatMap(serverUUID -> dbSystem.getDatabase().query(ServerQueries.fetchServerMatchingIdentifier(serverUUID)))
.map(Server::getName)
.orElse("-");
default: default:
return null; return null;
} }