mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Fix plot owner placeholder. Fixes PS-62.
This commit is contained in:
parent
f2191cb731
commit
e05d817482
@ -26,17 +26,16 @@
|
||||
package com.plotsquared.bukkit.placeholder;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Placeholders extends PlaceholderExpansion {
|
||||
@ -117,23 +116,16 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
return plot.getAlias();
|
||||
}
|
||||
case "currentplot_owner": {
|
||||
final Set<UUID> o = plot.getOwners();
|
||||
if (o == null || o.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
final UUID uid = (UUID) o.toArray()[0];
|
||||
if (uid == null) {
|
||||
final UUID plotOwner = plot.getOwnerAbs();
|
||||
if (plotOwner == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline()
|
||||
.getSingle(uid, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
try {
|
||||
return MainUtil.getName(plotOwner, false);
|
||||
} catch (final Exception ignored) {}
|
||||
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
name = Bukkit.getOfflinePlayer(uid).getName();
|
||||
final String name = Bukkit.getOfflinePlayer(plotOwner).getName();
|
||||
return name != null ? name : "unknown";
|
||||
}
|
||||
case "currentplot_members": {
|
||||
|
@ -372,10 +372,21 @@ public class MainUtil {
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner
|
||||
* @param owner Owner UUID
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(UUID owner) {
|
||||
@NotNull public static String getName(@Nullable UUID owner) {
|
||||
return getName(owner, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner Owner UUID
|
||||
* @param blocking Whether or not the operation can be blocking
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(@Nullable final UUID owner, final boolean blocking) {
|
||||
if (owner == null) {
|
||||
return Captions.NONE.getTranslated();
|
||||
}
|
||||
@ -385,7 +396,17 @@ public class MainUtil {
|
||||
if (owner.equals(DBFunc.SERVER)) {
|
||||
return Captions.SERVER.getTranslated();
|
||||
}
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
final String name;
|
||||
if (blocking) {
|
||||
name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
} else {
|
||||
final UUIDMapping uuidMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
|
||||
if (uuidMapping != null) {
|
||||
name = uuidMapping.getUsername();
|
||||
} else {
|
||||
name = null;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
return Captions.UNKNOWN.getTranslated();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user