Improve Maven setup for javadoc and source

- Generate a .jar file with the sources if -Dsources is provided
- Generate javadocs if -Djavadoc=/path/to/destination is provided
- Copy final .jar file to directory if -DcopyResult=/path/to/server is provided
- Adding missing javadoc comments
This commit is contained in:
Thijs Wiefferink 2016-06-13 20:36:17 +02:00
parent 36dd978a92
commit 21db2ff440
17 changed files with 141 additions and 30 deletions

View File

@ -97,10 +97,102 @@
</dependency>
</dependencies>
<profiles>
<!-- Copy the jar file to a test server, activate by using -DcopyResult="/path/to/test/server" -->
<profile>
<id>test-locally</id>
<activation>
<property>
<name>copyResult</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<tasks>
<copy file="./target/${project.build.finalName}.jar" tofile="${copyResult}\${project.build.finalName}.jar"/>
</tasks>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Package the source files in a jar, activate by using -Dsources -->
<profile>
<id>package-sources</id>
<activation>
<property>
<name>sources</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Produce javadoc files, activate by using -Djavadoc -->
<profile>
<id>generate-javadoc</id>
<activation>
<property>
<name>javadoc</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<phase>package</phase>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludePackageNames>me.wiefferink.areashop.lib</excludePackageNames>
<destDir>${javadoc}</destDir>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<directory>target</directory>
<finalName>AreaShop</finalName>
<!-- Include all required resources -->
<resources>
<resource>
<targetPath>.</targetPath>
@ -138,23 +230,6 @@
<target>1.7</target>
</configuration>
</plugin>
<!-- Copy resulting file to local server, change to your own path -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<configuration>
<tasks>
<copy file="./target/${project.build.finalName}.jar" tofile="C:\Games\Minecraft\Spigot\plugins\${project.build.finalName}.jar"/>
</tasks>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -347,7 +347,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
/**
* Set the chatprefix to use in the chat (loaded from config normally)
* @param chatprefix The string to use in front of chat messages (supports formatting codes like &1)
* @param chatprefix The string to use in front of chat messages (supports formatting codes)
*/
public void setChatprefix(List<String> chatprefix) {
this.chatprefix = chatprefix;
@ -623,6 +623,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopInterface {
/**
* Reload all files of the plugin and update all regions
* confirmationReceiver The CommandSender that should receive confirmation messages, null for nobody
* @param confirmationReceiver The CommandSender which should be notified when complete
*/
public void reload(final CommandSender confirmationReceiver) {
setReady(false);

View File

@ -60,6 +60,7 @@ public class Utils {
/**
* Create a message with a list of parts
* @param replacements The parts to use
* @param messagePart The message to use for the parts
* @return A Message object containing the parts combined into one message
*/
public static Message combinedMessage(Collection<?> replacements, String messagePart) {
@ -69,6 +70,7 @@ public class Utils {
/**
* Create a message with a list of parts
* @param replacements The parts to use
* @param messagePart The message to use for the parts
* @param combiner The string to use as combiner
* @return A Message object containing the parts combined into one message
*/
@ -109,6 +111,7 @@ public class Utils {
/**
* Create a map from a location, to save it in the config
* @param location The location to transform
* @param setPitchYaw true to save the pitch and yaw, otherwise false
* @return The map with the location values
*/
public static ConfigurationSection locationToConfig(Location location, boolean setPitchYaw) {
@ -126,6 +129,12 @@ public class Utils {
}
return result;
}
/**
* Create a map from a location, to save it in the config (without pitch and yaw)
* @param location The location to transform
* @return The map with the location values
*/
public static ConfigurationSection locationToConfig(Location location) {
return locationToConfig(location, false);
}

View File

@ -36,6 +36,7 @@ public abstract class CommandAreaShop {
* Get a list of string to complete a command with (raw list, not matching ones not filtered out)
* @param toComplete The number of the argument that has to be completed
* @param start The already given start of the command
* @param sender The CommandSender that wants to tab complete
* @return A collection with all the possibilities for argument to complete
*/
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {

View File

@ -18,6 +18,7 @@ public class SoldRegionEvent extends NotifyAreaShopEvent {
* Constructor
* @param region The region that has been sold
* @param oldBuyer The player for which the region has been sold
* @param refundedMoney The amount of money that has been refunded
*/
public SoldRegionEvent(BuyRegion region, UUID oldBuyer, double refundedMoney) {
this.region = region;

View File

@ -18,6 +18,7 @@ public class UnrentedRegionEvent extends NotifyAreaShopEvent {
* Constructor
* @param region The region that has been unrented
* @param oldRenter The player that rented the region before it was unrented
* @param refundedMoney The amount of money that has been refunded
*/
public UnrentedRegionEvent(RentRegion region, UUID oldRenter, double refundedMoney) {
this.region = region;

View File

@ -28,6 +28,7 @@ public class SignDisplayFeature extends Feature implements Listener {
/**
* Update the signs connected to this region
* @param region The region to update the signs for
* @return true if the update was successful, otherwise false
*/
public boolean updateSigns(GeneralRegion region) {

View File

@ -49,6 +49,7 @@ public class WorldGuardRegionFlagsFeature extends Feature implements Listener {
}
/**
* Set the region flags/options to the values of a ConfigurationSection
* @param region The region to update the flags for
* @param flags The flags to apply
* @return true if the flags have been set correctly, otherwise false
*/
@ -170,6 +171,7 @@ public class WorldGuardRegionFlagsFeature extends Feature implements Listener {
* @param region The WorldGuard region to set
* @param flag The flag to set
* @param value The value to set the flag to
* @param <V> They type of flag to set
* @throws InvalidFlagFormat When the value of the flag is wrong
*/
protected static <V> void setFlag(ProtectedRegion region, Flag<V> flag, String value) throws InvalidFlagFormat {

View File

@ -294,6 +294,7 @@ public class FileManager {
* Remove a rent from the list
* @param rent The region to remove
* @param giveMoneyBack use true to give money back to the player if someone is currently renting this region, otherwise false
* @return true if the rent has been removed, false otherwise
*/
public boolean removeRent(RentRegion rent, boolean giveMoneyBack) {
boolean result = false;
@ -360,6 +361,7 @@ public class FileManager {
* Remove a buy from the list
* @param buy The BuyRegion to remove
* @param giveMoneyBack true if money should be given back to the player, otherwise false
* @return true if the buy has been removed, false otherwise
*/
public boolean removeBuy(BuyRegion buy, boolean giveMoneyBack) {
boolean result = false;
@ -472,6 +474,7 @@ public class FileManager {
/**
* Update regions in a task to minimize lag
* @param regions Regions to update
* @param confirmationReceiver The CommandSender that should be notified at completion
*/
public void updateRegions(final List<GeneralRegion> regions, final CommandSender confirmationReceiver) {
final int regionsPerTick = plugin.getConfig().getInt("update.regionsPerTick");
@ -610,7 +613,7 @@ public class FileManager {
/**
* Get the folder the region files are located in
* @return The folder where the <region>.yml files are in
* @return The folder where the region.yml files are in
*/
public String getRegionFolder() {
return regionsPath;
@ -841,6 +844,7 @@ public class FileManager {
/**
* Load the groups.yml file from disk
* @return true if succeeded, otherwise false
*/
public boolean loadGroupsFile() {
boolean result = true;

View File

@ -67,10 +67,13 @@ public class SignLinkerManager implements Listener {
public boolean isInSignLinkMode(Player player) {
return signLinkers.containsKey(player.getUniqueId());
}
/**
* On player interactions
* @param event The PlayerInteractEvent
*/
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
AreaShop.debug("PlayerInteractEvent of " + event.getPlayer().getName() + ", " + signLinkers.size() + " signlinkers");
if(isInSignLinkMode(event.getPlayer())) {
event.setCancelled(true);
Player player = event.getPlayer();
@ -123,10 +126,10 @@ public class SignLinkerManager implements Listener {
/**
* Handle disconnection players
* @param event The PlayerQuitEvent
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLeave(PlayerQuitEvent event) {
AreaShop.debug("PlayerQuitEvent of " + event.getPlayer().getName() + ", " + signLinkers.size() + " signlinkers");
signLinkers.remove(event.getPlayer().getUniqueId());
}

View File

@ -77,6 +77,7 @@ public final class ArrayWrapper<E> {
* The iteration order of the specified object will be used as the array element order.
* @param list The iterable of objects which will be converted to an array.
* @param c The type of the elements of the array.
* @param <T> The type
* @return An array of elements in the specified iterable.
*/
@SuppressWarnings("unchecked")

View File

@ -70,6 +70,8 @@ public class FancyMessageFormat {
/**
* Parses the given FancyMessageFormat message to a JSON array that can be
* used with the tellraw command and the like.
* @param message The mesage to convert to JSON
* @return JSON string that can be send to a player
*/
public static String convertToJSON(final String message) {
return convertToJSON(Collections.singleton(message));
@ -79,6 +81,7 @@ public class FancyMessageFormat {
* Parses the given FancyMessageFormat message to a JSON array that can be
* used with the tellraw command and the like.
* @param inputLines Input message split at line breaks.
* @return JSON string that can be send to a player
*/
public static String convertToJSON(final Iterable<String> inputLines) {
ArrayList<String> lines = cleanInputString(inputLines);
@ -108,6 +111,7 @@ public class FancyMessageFormat {
* The returned message will only contain colors, bold, italic, underlining and 'magic'
* characters. Hovers and other advanced tellraw tags will be skipped.
* @param message Input message split at line breaks.
* @return Plain message that can be send
*/
public static String convertToConsole(final String message) {
return convertToConsole(Collections.singleton(message));
@ -120,6 +124,8 @@ public class FancyMessageFormat {
* <p>
* The returned message will only contain colors, bold, italic, underlining and 'magic'
* characters. Hovers and other advanced tellraw tags will be skipped.
* @param inputLines The raw message lines to process
* @return Plain message that can be send
*/
public static String convertToConsole(final Iterable<String> inputLines) {
if(inputLines == null) {

View File

@ -78,6 +78,7 @@ public class LanguageManager {
/**
* Loads the specified language
* @param key The language to load
* @return Map with the messages loaded from the file
*/
public Map<String, List<String>> loadLanguage(String key) {
Map<String, List<String>> result = new HashMap<>();

View File

@ -91,7 +91,7 @@ public class BuyRegion extends GeneralRegion {
/**
* Get the name of the player that owns this region
* @return The name of the player that owns this region, if unavailable by UUID it will return the old cached name, if that is unavailable it will return <UNKNOWN>
* @return The name of the player that owns this region, if unavailable by UUID it will return the old cached name, if that is unavailable it will return &lt;UNKNOWN&gt;
*/
public String getPlayerName() {
String result = Utils.toName(getBuyer());
@ -436,6 +436,7 @@ public class BuyRegion extends GeneralRegion {
* Sell a buyed region, get part of the money back
* @param giveMoneyBack true if the player should be given money back, otherwise false
* @param executor CommandSender to receive a message when the sell fails, or null
* @return true if the region has been sold, otherwise false
*/
@SuppressWarnings("deprecation")
public boolean sell(boolean giveMoneyBack, CommandSender executor) {

View File

@ -377,7 +377,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
/**
* Get the name of the landlord
* @return The name of the landlord, if unavailable by UUID it will return the old cached name, if that is unavailable it will return <UNKNOWN>
* @return The name of the landlord, if unavailable by UUID it will return the old cached name, if that is unavailable it will return &lt;UNKNOWN&gt;
*/
public String getLandlordName() {
String result = Utils.toName(getLandlord());
@ -951,7 +951,9 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
/**
* Teleport a player to the region
* @param player Player that should be teleported
* @param toSign true to teleport to the first sign of the region, false for teleporting to the region itself
* @param checkPermissions Set to true if teleport permissions should be checked, false otherwise
* @return true if the teleport succeeded, otherwise false
*/
public boolean teleportPlayer(Player player, boolean toSign, boolean checkPermissions) {
int checked = 1;
@ -1646,7 +1648,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
}
/**
* Get the amount of regions a player has matching a certain limits group (config.yml > limitGroups)
* Get the amount of regions a player has matching a certain limits group (config.yml -- limitGroups)
* @param player The player to check the amount for
* @param limitGroup The group to check
* @param regions All the regions a player has bought or rented
@ -1791,6 +1793,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
* @param signName The name of the sign
* @param clicker The player that clicked the sign
* @param clickType The type of clicking
* @return true if the commands ran successfully, false if any of them failed
*/
public boolean runSignCommands(String signName, Player clicker, ClickType clickType) {
// Get the profile set in the config

View File

@ -171,7 +171,7 @@ public class RentRegion extends GeneralRegion {
/**
* Get the name of the player renting this region
* @return Name of the player renting this region, if unavailable by UUID it will return the old cached name, if that is unavailable it will return <UNKNOWN>
* @return Name of the player renting this region, if unavailable by UUID it will return the old cached name, if that is unavailable it will return &lt;UNKNOWN&gt;
*/
public String getPlayerName() {
String result = Utils.toName(getRenter());
@ -229,7 +229,7 @@ public class RentRegion extends GeneralRegion {
}
/**
* Get the duration string, includes number<space>indentifier
* Get the duration string, includes 'number indentifier'
* @return The duration string
*/
public String getDurationString() {
@ -353,7 +353,7 @@ public class RentRegion extends GeneralRegion {
/**
* Send the expiration warnings from the selected profile which is specified in the config
* Sends all warnings since previous call until now+<normal delay>, delay can be found in the config as well
* Sends all warnings since previous call until (now + normal delay), delay can be found in the config as well
*/
public void sendExpirationWarnings() {
// send from warningsDoneUntil to current+delay
@ -589,6 +589,7 @@ public class RentRegion extends GeneralRegion {
* Unrent a region, reset to unrented
* @param giveMoneyBack true if money should be given back to the player, false otherwise
* @param executor The CommandSender that should get the cancelled message if there is any, or null
* @return true if unrenting succeeded, othwerwise false
*/
@SuppressWarnings("deprecation")
public boolean unRent(boolean giveMoneyBack, CommandSender executor) {

View File

@ -6,7 +6,7 @@
<packaging>pom</packaging>
<version>parent</version>
<name>AreaShop Parent</name>
<url>http://dev.bukkit.org/bukkit-plugins/regionbuyandrent/</url>
<url>https://github.com/NLthijs48/AreaShop</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>