mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
update plot list
This commit is contained in:
parent
4a960d9f2c
commit
f68eb9c778
@ -29,7 +29,9 @@ import com.google.inject.Inject;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.configuration.caption.Caption;
|
||||||
import com.plotsquared.core.configuration.caption.CaptionHolder;
|
import com.plotsquared.core.configuration.caption.CaptionHolder;
|
||||||
|
import com.plotsquared.core.configuration.caption.StaticCaption;
|
||||||
import com.plotsquared.core.configuration.caption.Templates;
|
import com.plotsquared.core.configuration.caption.Templates;
|
||||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -361,48 +363,46 @@ public class ListCmd extends SubCommand {
|
|||||||
public void displayPlots(final PlotPlayer<?> player, List<Plot> plots, int pageSize, int page, String[] args) {
|
public void displayPlots(final PlotPlayer<?> player, List<Plot> plots, int pageSize, int page, String[] args) {
|
||||||
// Header
|
// Header
|
||||||
plots.removeIf(plot -> !plot.isBasePlot());
|
plots.removeIf(plot -> !plot.isBasePlot());
|
||||||
this.paginate(player, plots, pageSize, page,
|
this.paginate(player, plots, pageSize, page, new RunnableVal3<Integer, Plot, CaptionHolder>() {
|
||||||
new RunnableVal3<Integer, Plot, CaptionHolder>() {
|
|
||||||
@Override public void run(Integer i, Plot plot, CaptionHolder caption) {
|
@Override public void run(Integer i, Plot plot, CaptionHolder caption) {
|
||||||
String color;
|
Caption color;
|
||||||
if (plot.getOwner() == null) {
|
if (plot.getOwner() == null) {
|
||||||
color = "$3";
|
color = TranslatableCaption.of("info.plot_list_no_owner");
|
||||||
} else if (plot.isOwner(player.getUUID())) {
|
} else if (plot.isOwner(player.getUUID())) {
|
||||||
color = "$1";
|
color = TranslatableCaption.of("info.plot_list_owned_by");
|
||||||
} else if (plot.isAdded(player.getUUID())) {
|
} else if (plot.isAdded(player.getUUID())) {
|
||||||
color = "$4";
|
color = TranslatableCaption.of("info.plot_list_added_to");
|
||||||
} else if (plot.isDenied(player.getUUID())) {
|
} else if (plot.isDenied(player.getUUID())) {
|
||||||
color = "$2";
|
color = TranslatableCaption.of("info.plot_list_denied_on");
|
||||||
} else {
|
} else {
|
||||||
color = "$1";
|
color = TranslatableCaption.of("info.plot_list_default");
|
||||||
}
|
}
|
||||||
PlotMessage trusted = new PlotMessage().text(Captions.color(
|
String trusted = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_trusted").getComponent(player),
|
||||||
Captions.PLOT_INFO_TRUSTED.getTranslated()
|
Template.of("trusted", PlayerManager.getPlayerList(plot.getTrusted()))));
|
||||||
.replaceAll("%trusted%", PlayerManager.getPlayerList(plot.getTrusted()))))
|
String members = MINI_MESSAGE.serialize(MINI_MESSAGE.parse(TranslatableCaption.of("info.plot_info_members").getComponent(player),
|
||||||
.color("$1");
|
Template.of("members", PlayerManager.getPlayerList(plot.getMembers()))));
|
||||||
PlotMessage members = new PlotMessage().text(Captions.color(
|
Template command_tp = Template.of("command_tp", "/plot visit " + plot.getArea() + ";" + plot.getId());
|
||||||
Captions.PLOT_INFO_MEMBERS.getTranslated()
|
Template command_info = Template.of("command_info", "/plot info " + plot.getArea() + ";" + plot.getId());
|
||||||
.replaceAll("%members%", PlayerManager.getPlayerList(plot.getMembers()))))
|
Template hover_info = Template.of("hover_info", trusted + "\n" + members);
|
||||||
.color("$1");
|
Template numberTemplate = Template.of("number", String.valueOf(i));
|
||||||
message.text("[").color("$3").text(i + "")
|
Template plotTemplate =
|
||||||
.command("/plot visit " + plot.getArea() + ";" + plot.getId())
|
Template.of("plot", MINI_MESSAGE.serialize(MINI_MESSAGE.parse(color.getComponent(player), Template.of("plot", plot.toString()))));
|
||||||
.tooltip("/plot visit " + plot.getArea() + ";" + plot.getId()).color("$1")
|
|
||||||
.text("]").color("$3").text(" " + plot.toString()).tooltip(trusted, members)
|
|
||||||
.command("/plot info " + plot.getArea() + ";" + plot.getId()).color(color)
|
|
||||||
.text(" - ").color("$2");
|
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
|
String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player);
|
||||||
|
String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline()
|
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
|
||||||
.getNames(plot.getOwners()).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
|
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||||
for (final UUIDMapping uuidMapping : names) {
|
for (final UUIDMapping uuidMapping : names) {
|
||||||
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
|
PlotPlayer<?> pp = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuidMapping.getUuid());
|
||||||
|
Template prefixTemplate = Template.of("prefix", prefix);
|
||||||
|
Template playerTemplate = Template.of("prefix", uuidMapping.getUsername());
|
||||||
if (pp != null) {
|
if (pp != null) {
|
||||||
message = message.text(prefix).color("$4").text(uuidMapping.getUsername()).color("$1")
|
builder.append(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate)));
|
||||||
.tooltip(new PlotMessage("Online").color("$4"));
|
|
||||||
} else {
|
} else {
|
||||||
message = message.text(prefix).color("$4").text(uuidMapping.getUsername()).color("$1")
|
builder.append(MINI_MESSAGE.serialize(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate)));
|
||||||
.tooltip(new PlotMessage("Offline").color("$3"));
|
|
||||||
}
|
}
|
||||||
prefix = ", ";
|
prefix = ", ";
|
||||||
}
|
}
|
||||||
@ -416,11 +416,14 @@ public class ListCmd extends SubCommand {
|
|||||||
playerBuilder.append(", ");
|
playerBuilder.append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(TranslatableCaption.of("errors.invalid_player"),
|
player.sendMessage(TranslatableCaption.of("errors.invalid_player"), Templates.of("value", playerBuilder.toString()));
|
||||||
Templates.of("value", playerBuilder.toString()));
|
|
||||||
} catch (TimeoutException e) {
|
} catch (TimeoutException e) {
|
||||||
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
|
||||||
}
|
}
|
||||||
|
Template players = Template.of("players", builder.toString());
|
||||||
|
caption.set(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||||
|
.parse(TranslatableCaption.of("info.plot_list_item").getComponent(player), command_tp, command_info, hover_info, numberTemplate,
|
||||||
|
plotTemplate, players))));
|
||||||
}
|
}
|
||||||
}, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged"));
|
}, "/plot list " + args[0], TranslatableCaption.of("list.plot_list_header_paged"));
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,6 @@ public class Merge extends SubCommand {
|
|||||||
|
|
||||||
public static final String[] values = new String[] {"north", "east", "south", "west"};
|
public static final String[] values = new String[] {"north", "east", "south", "west"};
|
||||||
public static final String[] aliases = new String[] {"n", "e", "s", "w"};
|
public static final String[] aliases = new String[] {"n", "e", "s", "w"};
|
||||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
|
||||||
|
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
private final EconHandler econHandler;
|
private final EconHandler econHandler;
|
||||||
|
@ -376,6 +376,14 @@
|
|||||||
"info.plot_no_description": "<prefix><gray>No description set.</gray>",
|
"info.plot_no_description": "<prefix><gray>No description set.</gray>",
|
||||||
"info.plot_caps_header": "<dark_gray><strikethrough>--------- <reset><gold>CAPS </gold><dark_gray><strikethrough>---------<reset>",
|
"info.plot_caps_header": "<dark_gray><strikethrough>--------- <reset><gold>CAPS </gold><dark_gray><strikethrough>---------<reset>",
|
||||||
"info.plot_caps_format": "<prefix><gray>- Cap Type: </gray><gold><cap> </gold><gray>| Status: </gray><gold><current></gold><gray>/</gray><gold><limit> </gold><gray>(</gray><gold><percentage>%</gold><gray>)</gray>",
|
"info.plot_caps_format": "<prefix><gray>- Cap Type: </gray><gold><cap> </gold><gray>| Status: </gray><gold><current></gold><gray>/</gray><gold><limit> </gold><gray>(</gray><gold><percentage>%</gold><gray>)</gray>",
|
||||||
|
"info.plot_list_item": "<click:run_command:<command_tp>><hover:show_text:<command_tp>><dark_grey>[</dark_grey><gold><number></gold><dark_grey>]</dark_grey></hover></click><click:run_command:<command_info>><hover:show_text:<hover_info>><gold> <plot></gold></hover></click><grey> - </grey><players>",
|
||||||
|
"info.plot_list_no_owner": "<dark_grey><plot></dark_grey>",
|
||||||
|
"info.plot_list_owned_by": "<gold><plot></gold>",
|
||||||
|
"info.plot_list_added_to": "<cyan><plot></cyan>",
|
||||||
|
"info.plot_list_denied_on": "<grey><plot></grey>",
|
||||||
|
"info.plot_list_default": "<gold><plot></gold>",
|
||||||
|
"info.plot_list_player_online": "<cyan><prefix></cyan><hover:show_text:<cyan>Online</cyan>><gold><player></gold></hover>",
|
||||||
|
"info.plot_list_player_offline": "<cyan><prefix></cyan><hover:show_text:<dark_grey>Offline</dark_grey>><gold><player></gold></hover>",
|
||||||
"info.area_info_format": "<header>\n<reset><gold>NAME: </gold><grey><name></grey>\n<gold>Type: </gold><grey><type></grey>\n<gold>Terrain: </gold><grey><terrain></grey>\n<gold>Usage: </gold><grey><usage>%</grey>\n<gold>Claimed: </gold><grey><claimed></grey>\n<gold>Clusters: </gold><grey><clusters></grey>\n<gold>Region: </gold><grey><region></grey>\n<gold>Generator: </gold><grey><generator></grey>\n<footer>",
|
"info.area_info_format": "<header>\n<reset><gold>NAME: </gold><grey><name></grey>\n<gold>Type: </gold><grey><type></grey>\n<gold>Terrain: </gold><grey><terrain></grey>\n<gold>Usage: </gold><grey><usage>%</grey>\n<gold>Claimed: </gold><grey><claimed></grey>\n<gold>Clusters: </gold><grey><clusters></grey>\n<gold>Region: </gold><grey><region></grey>\n<gold>Generator: </gold><grey><generator></grey>\n<footer>",
|
||||||
"info.area_list_tooltip": "<gold>Claimed=</gold><grey><claimed></grey>\n<gold>Usage=</gold><grey><usage></grey>\n<gold>Clusters=</gold><grey><clusters></grey>\n<gold>Region=</gold><grey><region></grey>\n<gold>Generator=</gold><grey><generator></grey>\n",
|
"info.area_list_tooltip": "<gold>Claimed=</gold><grey><claimed></grey>\n<gold>Usage=</gold><grey><usage></grey>\n<gold>Clusters=</gold><grey><clusters></grey>\n<gold>Region=</gold><grey><region></grey>\n<gold>Generator=</gold><grey><generator></grey>\n",
|
||||||
"info.area_list_item": "<click:run_command:<command_tp>><hover:show_text:<command_tp>><dark_grey>[</dark_grey><gold><number></gold><dark_grey>]</dark_grey></hover></click><click:run_command:<command_info>><hover:show_text:<hover_info>><gold> <area_name></gold></hover></click><grey> - </grey><dark_grey><area_type>:<area_terrain></dark_grey>",
|
"info.area_list_item": "<click:run_command:<command_tp>><hover:show_text:<command_tp>><dark_grey>[</dark_grey><gold><number></gold><dark_grey>]</dark_grey></hover></click><click:run_command:<command_info>><hover:show_text:<hover_info>><gold> <area_name></gold></hover></click><grey> - </grey><dark_grey><area_type>:<area_terrain></dark_grey>",
|
||||||
|
Loading…
Reference in New Issue
Block a user