mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 12:25:46 +01:00
Fixup inbox javadocs
This commit is contained in:
parent
812442fbbc
commit
11af33f2d5
@ -57,7 +57,7 @@ import java.util.stream.Collectors;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||
public void displayComments(PlotPlayer<?> player, List<PlotComment> oldComments, int page) {
|
||||
if (oldComments == null || oldComments.isEmpty()) {
|
||||
player.sendMessage(TranslatableCaption.of("comment.inbox_empty"));
|
||||
return;
|
||||
@ -102,7 +102,7 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
Template number = Template.of("number", String.valueOf(x));
|
||||
Template world = Template.of("world", comment.world);
|
||||
Template plot_id = Template.of("plot_id", comment.id.getX() + "" + comment.id.getY());
|
||||
Template plot_id = Template.of("plot_id", comment.id.getX() + ";" + comment.id.getY());
|
||||
Template commenter = Template.of("commenter", comment.senderName);
|
||||
Template commentTemplate = Template.of("comment", commentColored);
|
||||
builder.append(MINI_MESSAGE
|
||||
@ -133,7 +133,7 @@ public class Inbox extends SubCommand {
|
||||
sendUsage(player);
|
||||
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||
if (inbox.canRead(plot, player)) {
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
if (!inbox.getComments(plot, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
if (value != null) {
|
||||
@ -179,7 +179,7 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
final MetaDataKey<Long> metaDataKey = MetaDataKey.of(
|
||||
String.format("inbox:%s", inbox.toString()),
|
||||
new TypeLiteral<Long>() {
|
||||
new TypeLiteral<>() {
|
||||
}
|
||||
);
|
||||
try (final MetaDataAccess<Long> metaDataAccess = player.accessTemporaryMetaData(metaDataKey)) {
|
||||
@ -217,7 +217,7 @@ public class Inbox extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
if (!inbox.getComments(plot, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
if (index > value.size()) {
|
||||
@ -238,8 +238,6 @@ public class Inbox extends SubCommand {
|
||||
} else {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("comment.comment_removed_failure"));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
})) {
|
||||
@ -254,12 +252,12 @@ public class Inbox extends SubCommand {
|
||||
inbox.clearInbox(plot);
|
||||
List<PlotComment> comments = plot.getPlotCommentContainer().getComments(inbox.toString());
|
||||
if (!comments.isEmpty()) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("comment.comment_removed_success"),
|
||||
Template.of("value", String.valueOf(comments))
|
||||
);
|
||||
plot.getPlotCommentContainer().removeComments(comments);
|
||||
}
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("comment.comment_removed_success"),
|
||||
Template.of("value", "*")
|
||||
);
|
||||
return true;
|
||||
default:
|
||||
try {
|
||||
@ -276,7 +274,7 @@ public class Inbox extends SubCommand {
|
||||
player.sendMessage(TranslatableCaption.of("comment.no_perm_inbox"));
|
||||
return false;
|
||||
}
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
if (!inbox.getComments(plot, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
displayComments(player, value, page);
|
||||
|
@ -38,7 +38,12 @@ public abstract class CommentInbox {
|
||||
@Override
|
||||
public abstract String toString();
|
||||
|
||||
public boolean canRead(Plot plot, PlotPlayer player) {
|
||||
/**
|
||||
* @param plot the plot's inbox to read
|
||||
* @param player the player trying to read the comment
|
||||
* @return the inbox, otherwise {@code false} false
|
||||
*/
|
||||
public boolean canRead(Plot plot, PlotPlayer<?> player) {
|
||||
if (Permissions.hasPermission(player, "plots.inbox.read." + toString(), true)) {
|
||||
return plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read." + toString() + ".other", true);
|
||||
@ -46,7 +51,12 @@ public abstract class CommentInbox {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canWrite(Plot plot, PlotPlayer player) {
|
||||
/**
|
||||
* @param plot the plot's inbox to write to
|
||||
* @param player the player trying to write the comment
|
||||
* @return true if the player can write a comment on the plot
|
||||
*/
|
||||
public boolean canWrite(Plot plot, PlotPlayer<?> player) {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString(), true);
|
||||
}
|
||||
@ -55,7 +65,13 @@ public abstract class CommentInbox {
|
||||
.hasPermission(player, "plots.inbox.write." + toString() + ".other", true));
|
||||
}
|
||||
|
||||
public boolean canModify(Plot plot, PlotPlayer player) {
|
||||
/**
|
||||
* @param plot the plot's inbox to write to
|
||||
* @param player the player trying to modify the inbox
|
||||
* @return true if the player can write a comment on the plot
|
||||
*/
|
||||
@SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
|
||||
public boolean canModify(Plot plot, PlotPlayer<?> player) {
|
||||
if (Permissions.hasPermission(player, "plots.inbox.modify." + toString(), true)) {
|
||||
return plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify." + toString() + ".other", true);
|
||||
@ -74,12 +90,24 @@ public abstract class CommentInbox {
|
||||
*/
|
||||
public abstract boolean getComments(Plot plot, RunnableVal<List<PlotComment>> whenDone);
|
||||
|
||||
/**
|
||||
* @param plot plot
|
||||
* @param comment the comment to add
|
||||
* @return success or not
|
||||
*/
|
||||
public abstract boolean addComment(Plot plot, PlotComment comment);
|
||||
|
||||
/**
|
||||
* @param plot plot
|
||||
* @param comment the comment to remove
|
||||
*/
|
||||
public void removeComment(Plot plot, PlotComment comment) {
|
||||
DBFunc.removeComment(plot, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plot plot
|
||||
*/
|
||||
public void clearInbox(Plot plot) {
|
||||
DBFunc.clearInbox(plot, toString());
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class CommentManager {
|
||||
|
||||
public static final HashMap<String, CommentInbox> inboxes = new HashMap<>();
|
||||
|
||||
public static void sendTitle(final PlotPlayer player, final Plot plot) {
|
||||
public static void sendTitle(final PlotPlayer<?> player, final Plot plot) {
|
||||
if (!Settings.Enabled_Components.COMMENT_NOTIFIER || !plot.isOwner(player.getUUID())) {
|
||||
return;
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class CommentManager {
|
||||
final AtomicInteger count = new AtomicInteger(0);
|
||||
final AtomicInteger size = new AtomicInteger(boxes.size());
|
||||
for (final CommentInbox inbox : inboxes.values()) {
|
||||
inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
inbox.getComments(plot, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
int total;
|
||||
@ -87,14 +87,22 @@ public class CommentManager {
|
||||
}, TaskTime.seconds(1L));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player The player the inbox belongs to
|
||||
* @param inbox the inbox
|
||||
* @return the time in milliseconds when the player was last seen online
|
||||
*/
|
||||
public static long getTimestamp(PlotPlayer<?> player, String inbox) {
|
||||
final MetaDataKey<Long> inboxKey = MetaDataKey.of(String.format("inbox:%s", inbox), new TypeLiteral<Long>() {
|
||||
final MetaDataKey<Long> inboxKey = MetaDataKey.of(String.format("inbox:%s", inbox), new TypeLiteral<>() {
|
||||
});
|
||||
try (final MetaDataAccess<Long> inboxAccess = player.accessTemporaryMetaData(inboxKey)) {
|
||||
return inboxAccess.get().orElse(player.getLastPlayed());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inbox the inbox to add
|
||||
*/
|
||||
public static void addInbox(CommentInbox inbox) {
|
||||
inboxes.put(inbox.toString().toLowerCase(), inbox);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class InboxOwner extends CommentInbox {
|
||||
TaskManager.runTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<List<PlotComment>>() {
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
whenDone.value = value;
|
||||
|
@ -42,7 +42,7 @@ public class InboxPublic extends CommentInbox {
|
||||
TaskManager.runTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<List<PlotComment>>() {
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
whenDone.value = value;
|
||||
|
@ -36,7 +36,7 @@ public class InboxReport extends CommentInbox {
|
||||
|
||||
@Override
|
||||
public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<List<PlotComment>>() {
|
||||
DBFunc.getComments(plot, toString(), new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
whenDone.value = value;
|
||||
|
@ -359,8 +359,8 @@
|
||||
"working.claimed": "<prefix><dark_aqua>You successfully claimed the plot <plot>.</dark_aqua>",
|
||||
"working.progress": "<prefix><gray>Current progress: </gray><gold><progress></gold><gray>%</gray>",
|
||||
"working.component_complete": "<prefix><gold>Component generation has finished for plot <plot>.</gold>",
|
||||
"list.comment_list_header_paged": "<gray>(Page </gray><gold><cur></gold><gray>/</gray><gold><max></gold><gray>) </gray><gold>List of <amount> comments</gold>",
|
||||
"list.comment_list_comment": "<dark_gray>[</dark_gray><gray>#<number></gray><dark_gray>[</dark_gray><gray><world>;<plot_id></gray><dark_gray>][</dark_gray><gold><commenter></gold><dark_gray>]</dark_gray><comment>\n",
|
||||
"list.comment_list_header_paged": "<gray>(Page </gray><gold><cur></gold><gray>/</gray><gold><max></gold><gray>) </gray><gold>List of <amount> comment(s):</gold>",
|
||||
"list.comment_list_comment": "<dark_gray>[</dark_gray><gray>#<number></gray><dark_gray>] [</dark_gray><gray><world>;<plot_id></gray><dark_gray>] [</dark_gray><gold><commenter></gold><dark_gray>]: </dark_gray><comment>\n",
|
||||
"list.comment_list_by_lister": "<green><comment></green>",
|
||||
"list.comment_list_by_other": "<gray><comment></gray>",
|
||||
"list.clickable": "<gray> (interactive)</gray>",
|
||||
|
Loading…
Reference in New Issue
Block a user