Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions src/main/java/com/onarandombox/MultiverseCore/MVWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
Expand Down Expand Up @@ -516,22 +515,46 @@ public World getCBWorld() {
*/
@Override
public String getColoredWorldString() {
if (props.getAlias().length() == 0) {
if (!hasCustomAlias()) {
props.setAlias(this.getName());
}

if ((props.getColor() == null) || (props.getColor().getColor() == null)) {
if (!hasCustomColor()) {
this.props.setColor(EnglishChatColor.WHITE);
}

StringBuilder nameBuilder = new StringBuilder().append(props.getColor().getColor());
if (props.getStyle().getColor() != null)
if (hasCustomStyle()) {
nameBuilder.append(props.getStyle().getColor());
nameBuilder.append(props.getAlias()).append(ChatColor.WHITE).toString();
}
nameBuilder.append(props.getAlias()).append(ChatColor.WHITE);

return nameBuilder.toString();
}

/**
* {@inheritDoc}
*/
@Override
public boolean hasCustomWorldString() {
return hasCustomAlias() || hasCustomColor() || hasCustomStyle();
}

private boolean hasCustomAlias() {
return !(props.getAlias() == null
|| props.getAlias().isEmpty()
|| name.equals(props.getAlias()));
}

private boolean hasCustomColor() {
return props.getColor() != null
&& props.getColor().getColor() != ChatColor.WHITE;
}

private boolean hasCustomStyle() {
return props.getStyle().getColor() != null;
}

/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,13 @@ public interface MultiverseWorld {
*/
String getAlias();

/**
* Check whether this world has an custom world string set.
*
* @return true if there is either custom color, style or alias set, false otherwise.
*/
boolean hasCustomWorldString();

/**
* Sets the alias of the world.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,38 @@ private List<String> getFancyWorldList(Player p) {
} else if (env == Environment.THE_END) {
color = ChatColor.AQUA;
}

StringBuilder builder = new StringBuilder();
builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
builder.append(" - ").append(color).append(world.getEnvironment());
if (world.isHidden()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
// Prefix hidden worlds with an "[H]"
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
}
} else {
worldList.add(builder.toString());

if (world.isHidden() && (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true))) {
// Prefix hidden worlds with an "[H]"
builder.append(ChatColor.GRAY)
.append("[H] ")
.append(ChatColor.WHITE);
}

builder.append(world.getName());

if (world.hasCustomWorldString()) {
builder.append(" (")
.append(world.getColoredWorldString())
.append(')');
}

builder.append(ChatColor.GRAY)
.append(" - ")
.append(color)
.append(world.getEnvironment());

worldList.add(builder.toString());
}

for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
}
}

return worldList;
}

Expand Down