Version number fixes, fixed documentation, new caption added, and tweaks to API functionality.

This commit is contained in:
MattBDev 2019-09-06 20:40:28 -04:00
parent a7012814ab
commit b3136b4ebe
13 changed files with 80 additions and 67 deletions

View File

@ -132,8 +132,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
// Check for updates // Check for updates
if (PlotSquared.get().getUpdateUtility() != null) { if (PlotSquared.get().getUpdateUtility() != null) {
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
updateUtility updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
.checkForUpdate(this.getPluginVersionString(), ((updateDescription, throwable) -> { ((updateDescription, throwable) -> {
Bukkit.getScheduler().runTask(BukkitMain.this, () -> { Bukkit.getScheduler().runTask(BukkitMain.this, () -> {
getLogger().info("-------- PlotSquared Update Check --------"); getLogger().info("-------- PlotSquared Update Check --------");
if (throwable != null) { if (throwable != null) {
@ -803,4 +803,5 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override public LegacyMappings getLegacyMappings() { @Override public LegacyMappings getLegacyMappings() {
return this.legacyMappings; return this.legacyMappings;
} }
} }

View File

@ -642,7 +642,7 @@ import java.util.regex.Pattern;
&& PlotSquared.get().getUpdateUtility() != null) { && PlotSquared.get().getUpdateUtility() != null) {
final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility();
final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class); final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class);
updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(), updateUtility.checkForUpdate(PlotSquared.get().getVersion().versionString(),
((updateDescription, throwable) -> { ((updateDescription, throwable) -> {
if (throwable != null) { if (throwable != null) {
bukkitMain.getLogger().severe(String bukkitMain.getLogger().severe(String

View File

@ -263,7 +263,7 @@ public abstract class Command {
/** /**
* @param player Caller * @param player Caller
* @param args Arguments * @param args Arguments
* @param confirm Instance, Success, Failure * @param confirm Instance, Success, Failure
* @return CompletableFuture true if the command executed fully, false in * @return CompletableFuture true if the command executed fully, false in
* any other case * any other case

View File

@ -63,12 +63,12 @@ public interface IPlotMain extends ILogger {
*/ */
String getPluginVersionString(); String getPluginVersionString();
String getPluginName(); default String getPluginName() {
return "PlotSquared";
}
/** /**
* Gets the version of Minecraft that is running. * Gets the version of Minecraft that is running.
*
* @return
*/ */
int[] getServerVersion(); int[] getServerVersion();
@ -101,7 +101,7 @@ public interface IPlotMain extends ILogger {
/** /**
* The task manager will run and manage Minecraft tasks. * The task manager will run and manage Minecraft tasks.
* *
* @return * @return the PlotSquared task manager
*/ */
TaskManager getTaskManager(); TaskManager getTaskManager();
@ -138,49 +138,39 @@ public interface IPlotMain extends ILogger {
/** /**
* Gets the economy provider. * Gets the economy provider.
* *
* @return * @return the PlotSquared economy manager
*/ */
EconHandler getEconomyHandler(); EconHandler getEconomyHandler();
/** /**
* Gets the {@link QueueProvider} class. * Gets the {@link QueueProvider} class.
*
* @return
*/ */
QueueProvider initBlockQueue(); QueueProvider initBlockQueue();
/** /**
* Gets the {@link WorldUtil} class. * Gets the {@link WorldUtil} class.
*
* @return
*/ */
WorldUtil initWorldUtil(); WorldUtil initWorldUtil();
/** /**
* Gets the EventUtil class. * Gets the EventUtil class.
*
* @return
*/ */
EventUtil initEventUtil(); EventUtil initEventUtil();
/** /**
* Gets the chunk manager. * Gets the chunk manager.
* *
* @return * @return the PlotSquared chunk manager
*/ */
ChunkManager initChunkManager(); ChunkManager initChunkManager();
/** /**
* Gets the {@link SetupUtils} class. * Gets the {@link SetupUtils} class.
*
* @return
*/ */
SetupUtils initSetupUtils(); SetupUtils initSetupUtils();
/** /**
* Gets {@link HybridUtils} class. * Gets {@link HybridUtils} class.
*
* @return
*/ */
HybridUtils initHybridUtils(); HybridUtils initHybridUtils();
@ -199,32 +189,28 @@ public interface IPlotMain extends ILogger {
/** /**
* Gets the {@link UUIDHandlerImplementation} which will cache and * Gets the {@link UUIDHandlerImplementation} which will cache and
* provide UUIDs. * provide UUIDs.
*
* @return
*/ */
UUIDHandlerImplementation initUUIDHandler(); UUIDHandlerImplementation initUUIDHandler();
/** /**
* Gets the {@link InventoryUtil} class (used for implementation specific * Gets the {@link InventoryUtil} class (used for implementation specific
* inventory guis). * inventory guis).
*
* @return
*/ */
InventoryUtil initInventoryUtil(); InventoryUtil initInventoryUtil();
/** /**
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off. * Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
* *
* @param player * @param player the player to remove
*/ */
void unregister(PlotPlayer player); void unregister(PlotPlayer player);
/** /**
* Gets the generator wrapper for a world (world) and generator (name). * Gets the generator wrapper for a world (world) and generator (name).
* *
* @param world * @param world the world to get the generator from
* @param name * @param name the name of the generator
* @return * @return the generator being used for the provided world
*/ */
GeneratorWrapper<?> getGenerator(String world, String name); GeneratorWrapper<?> getGenerator(String world, String name);
@ -232,7 +218,7 @@ public interface IPlotMain extends ILogger {
/** /**
* Register the chunk processor which will clean out chunks that have too * Register the chunk processor which will clean out chunks that have too
* many blockstates or entities. * many block states or entities.
*/ */
void registerChunkProcessor(); void registerChunkProcessor();

View File

@ -33,8 +33,8 @@ import com.sk89q.worldedit.WorldEdit;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull; import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.io.*; import java.io.*;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -1623,7 +1623,7 @@ import java.util.zip.ZipInputStream;
final Properties properties = new Properties(); final Properties properties = new Properties();
properties.load(bufferedReader); properties.load(bufferedReader);
final boolean enabled = final boolean enabled =
Boolean.valueOf(properties.getOrDefault("enabled", true).toString()); Boolean.parseBoolean(properties.getOrDefault("enabled", true).toString());
if (enabled) { if (enabled) {
this.updateUtility = new UpdateUtility(properties.getProperty("path"), this.updateUtility = new UpdateUtility(properties.getProperty("path"),
properties.getProperty("job"), properties.getProperty("artifact")); properties.getProperty("job"), properties.getProperty("artifact"));

View File

@ -30,6 +30,13 @@ public class PlotVersion {
} }
} }
public String versionString() {
if (hash == 0 && build == 0) {
return "NoVer-SNAPSHOT";
} else {
return "4." + build;
}
}
@Override public String toString() { @Override public String toString() {
if (hash == 0 && build == 0) { if (hash == 0 && build == 0) {
return "PlotSquared-NoVer-SNAPSHOT"; return "PlotSquared-NoVer-SNAPSHOT";

View File

@ -14,9 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.List; import java.util.List;
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot", @CommandDeclaration(command = "inbox", description = "Review the comments for a plot",
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) public class Inbox public class Inbox extends SubCommand {
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()) { if (oldComments == null || oldComments.isEmpty()) {
@ -150,12 +149,13 @@ import java.util.List;
PlotComment comment = value.get(index - 1); PlotComment comment = value.get(index - 1);
inbox.removeComment(plot, comment); inbox.removeComment(plot, comment);
boolean success = plot.removeComment(comment); boolean success = plot.removeComment(comment);
//noinspection StatementWithEmptyBody
if (success) { if (success) {
MainUtil MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_SUCCESS,
.sendMessage(player, Captions.COMMENT_REMOVED, comment.comment); comment.comment);
} else { } else {
//TODO Comment removal failure message MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_FAILURE,
comment.comment);
} }
} }
})) { })) {
@ -172,7 +172,7 @@ import java.util.List;
if (!comments.isEmpty()) { if (!comments.isEmpty()) {
plot.removeComments(comments); plot.removeComments(comments);
} }
MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, "*"); MainUtil.sendMessage(player, Captions.COMMENT_REMOVED_SUCCESS, "*");
return true; return true;
default: default:
try { try {

View File

@ -22,8 +22,8 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
"$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21"); "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev $2& $1dordsor21");
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki"); "$2>> $1&lWiki$2: $1https://github.com/IntellectualSites/PlotSquared/wiki");
MainUtil.sendMessage(player, // MainUtil.sendMessage(player,
"$2>> $1&lNewest Version$2: $1" + getNewestVersionString()); // "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
} }
}); });
return true; return true;

View File

@ -280,13 +280,12 @@ public enum Captions {
"Comment"), "Comment"),
INVALID_INBOX("$2That is not a valid inbox.&-$1Accepted values: %s", "Comment"), NO_PERM_INBOX( INVALID_INBOX("$2That is not a valid inbox.&-$1Accepted values: %s", "Comment"), NO_PERM_INBOX(
"$2You do not have permission for that inbox", "Comment"), "$2You do not have permission for that inbox", "Comment"), NO_PERM_INBOX_MODIFY(
"$2You do not have permission to modify that inbox", "Comment"), NO_PLOT_INBOX(
NO_PERM_INBOX_MODIFY("$2You do not have permission to modify that inbox", "$2You must stand in or supply a plot argument", "Comment"), COMMENT_REMOVED_SUCCESS(
"Comment"), NO_PLOT_INBOX("$2You must stand in or supply a plot argument", "Comment"), "$4Successfully deleted comment/s:n$2 - '$3%s$2'", "Comment"), COMMENT_REMOVED_FAILURE(
"$4Failed to delete comment!", "Comment"), COMMENT_ADDED("$4A comment has been left",
COMMENT_REMOVED("$4Successfully deleted comment/s:n$2 - '$3%s$2'", "Comment"), COMMENT_ADDED( "Comment"),
"$4A comment has been left", "Comment"),
COMMENT_HEADER("$2&m---------&r $1Comments $2&m---------&r", "Comment"), INBOX_EMPTY( COMMENT_HEADER("$2&m---------&r $1Comments $2&m---------&r", "Comment"), INBOX_EMPTY(
"$2No comments", "Comment"), "$2No comments", "Comment"),

View File

@ -399,35 +399,48 @@ public class ClassicPlotManager extends SquarePlotManager {
/** /**
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED). * Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
*
* @return false if part of the merge failed, otherwise true if successful.
*/ */
@Override public boolean finishPlotMerge(List<PlotId> plotIds) { @Override public boolean finishPlotMerge(List<PlotId> plotIds) {
//TODO This method shouldn't always return true
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
plotIds.forEach(id -> setWall(id, block)); boolean success = true;
for (PlotId plotId : plotIds) {
success &= setWall(plotId, block);
}
if (Settings.General.MERGE_REPLACE_WALL) { if (Settings.General.MERGE_REPLACE_WALL) {
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING; final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
plotIds.forEach(id -> setWallFilling(id, wallBlock)); for (PlotId id : plotIds) {
success &= setWallFilling(id, wallBlock);
}
} }
return true; return success;
} }
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) { @Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
//TODO This method shouldn't always return true
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
plotIds.forEach(id -> setWall(id, block)); boolean success = true;
return true; for (PlotId id : plotIds) {
success &= setWall(id, block);
}
return success;
} }
/**
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
*
* @return true if the wall blocks were successfully set
*/
@Override public boolean regenerateAllPlotWalls() { @Override public boolean regenerateAllPlotWalls() {
//TODO This method shouldn't always return true boolean success = true;
for (Plot plot : classicPlotWorld.getPlots()) { for (Plot plot : classicPlotWorld.getPlots()) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK); success &= setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
} else { } else {
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); success &= setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
} }
} }
return true; return success;
} }
@Override public boolean startPlotMerge(List<PlotId> plotIds) { @Override public boolean startPlotMerge(List<PlotId> plotIds) {
@ -448,7 +461,9 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
/** /**
* Remove sign for a plot. * Retrieves the location of where a sign should be for a plot.
* @param plot The plot
* @return The location where a sign should be
*/ */
@Override public Location getSignLoc(Plot plot) { @Override public Location getSignLoc(Plot plot) {
plot = plot.getBasePlot(false); plot = plot.getBasePlot(false);

View File

@ -147,8 +147,7 @@ public class HybridPlotManager extends ClassicPlotManager {
if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) {
createSchemAbs(queue, pos1, pos2); createSchemAbs(queue, pos1, pos2);
} }
queue.enqueue(); return queue.enqueue();
return true;
} }
/** /**
@ -222,7 +221,9 @@ public class HybridPlotManager extends ClassicPlotManager {
} }
/** /**
* Remove sign for a plot. * Retrieves the location of where a sign should be for a plot.
* @param plot The plot
* @return The location where a sign should be
*/ */
@Override public Location getSignLoc(Plot plot) { @Override public Location getSignLoc(Plot plot) {
return hybridPlotWorld.getSignLocation(plot); return hybridPlotWorld.getSignLocation(plot);

View File

@ -39,6 +39,12 @@ public abstract class PlotManager {
public abstract boolean unClaimPlot(Plot plot, Runnable whenDone); public abstract boolean unClaimPlot(Plot plot, Runnable whenDone);
/**
* Retrieves the location of where a sign should be for a plot.
*
* @param plot The plot
* @return The location where a sign should be
*/
public abstract Location getSignLoc(Plot plot); public abstract Location getSignLoc(Plot plot);
/* /*
@ -47,8 +53,7 @@ public abstract class PlotManager {
*/ */
public abstract String[] getPlotComponents(PlotId plotId); public abstract String[] getPlotComponents(PlotId plotId);
public abstract boolean setComponent(PlotId plotId, String component, public abstract boolean setComponent(PlotId plotId, String component, BlockBucket blocks);
BlockBucket blocks);
/* /*
* PLOT MERGING (return false if your generator does not support plot * PLOT MERGING (return false if your generator does not support plot

View File

@ -102,8 +102,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
lastWrappedChunk.setBlock(x & 15, y, z & 15, id); lastWrappedChunk.setBlock(x & 15, y, z & 15, id);
LocalChunk previous = this.blockChunks.put(pair, lastWrappedChunk); LocalChunk previous = this.blockChunks.put(pair, lastWrappedChunk);
if (previous == null) { if (previous == null) {
chunks.add(lastWrappedChunk); return chunks.add(lastWrappedChunk);
return true;
} }
this.blockChunks.put(pair, previous); this.blockChunks.put(pair, previous);
lastWrappedChunk = previous; lastWrappedChunk = previous;