Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Fixed issues with suggestPaper counting as advertising #54

Closed
wants to merge 1 commit into from
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
50 changes: 37 additions & 13 deletions src/main/java/io/papermc/lib/PaperLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.papermc.lib.environments.Environment;
import io.papermc.lib.environments.PaperEnvironment;
import io.papermc.lib.environments.SpigotEnvironment;
import io.papermc.lib.features.PaperFeature;
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
import org.bukkit.Chunk;
import org.bukkit.Location;
Expand Down Expand Up @@ -270,10 +271,10 @@ public static boolean isPaper() {
* If you do not mind helping spread Paper, please call this in your plugin onEnable to help spread
* awareness about Paper, and encourage them that your plugin is better when used with Paper!
*
* This passes the default logLevel of Level.INFO
* This passes the default logLevel of Level.INFO and all the features as a default
*
* @param plugin Your plugin object
* @see #suggestPaper(Plugin, Level)
* @see #suggestPaper(Plugin, Level)
*/
public static void suggestPaper(@Nonnull Plugin plugin) {
suggestPaper(plugin, Level.INFO);
Expand All @@ -285,10 +286,40 @@ public static void suggestPaper(@Nonnull Plugin plugin) {
* If you do not mind helping spread Paper, please call this in your plugin onEnable to help spread
* awareness about Paper, and encourage them that your plugin is better when used with Paper!
*
* @param plugin Your plugin object
* This passes the default logLevel of Level.INFO
*
* @param plugin Your plugin object
* @param paperFeatures The features your plugin is using
* @see #suggestPaper(Plugin, Level)
*/
public static void suggestPaper(@Nonnull Plugin plugin, @Nonnull PaperFeature... paperFeatures) {
suggestPaper(plugin, Level.INFO, paperFeatures);
}

/**
* Can be called during plugin initialization to inform the server owner they should switch to Paper
*
* If you do not mind helping spread Paper, please call this in your plugin onEnable to help spread
* awareness about Paper, and encourage them that your plugin is better when used with Paper!
*
* @param plugin Your plugin object
* @param logLevel The logLevel you want to choose
*/
public static void suggestPaper(@Nonnull Plugin plugin, @Nonnull Level logLevel) {
suggestPaper(plugin, logLevel, PaperFeature.values());
}

/**
* Can be called during plugin initialization to inform the server owner they should switch to Paper
*
* If you do not mind helping spread Paper, please call this in your plugin onEnable to help spread
* awareness about Paper, and encourage them that your plugin is better when used with Paper!
*
* @param plugin Your plugin object
* @param logLevel The logLevel you want to choose
* @param paperFeatures The features your plugin is using
*/
public static void suggestPaper(@Nonnull Plugin plugin, @Nonnull Level logLevel, @Nonnull PaperFeature... paperFeatures) {
if (isPaper()) {
return;
}
Expand All @@ -301,17 +332,10 @@ public static void suggestPaper(@Nonnull Plugin plugin, @Nonnull Level logLevel)
if (System.getProperty(benefitsProperty) == null) {
System.setProperty(benefitsProperty, "1");
logger.log(logLevel, " ");
logger.log(logLevel, " Paper offers significant performance improvements,");
logger.log(logLevel, " bug fixes, security enhancements and optional");
logger.log(logLevel, " features for server owners to enhance their server.");
logger.log(logLevel, " ");
logger.log(logLevel, " Paper includes Timings v2, which is significantly");
logger.log(logLevel, " better at diagnosing lag problems over v1.");
logger.log(logLevel, " ");
logger.log(logLevel, " All of your plugins should still work, and the");
logger.log(logLevel, " Paper community will gladly help you fix any issues.");
for (PaperFeature paperFeature : paperFeatures) {
logger.log(logLevel, " * " + paperFeature.getFeature());
}
logger.log(logLevel, " ");
logger.log(logLevel, " Join the Paper Community @ https://papermc.io");
}
logger.log(logLevel, "====================================================");
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/io/papermc/lib/features/PaperFeature.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.papermc.lib.features;

public enum PaperFeature {
ASYNC_CHUNK_LOADING("Asynchronous Chunk Loading"),
ASYNC_TELEPORT("Asynchronous Teleporting"),
BED_SPAWN_LOCATION("Bed Spawn Locations"),
BLOCK_STATE_SNAPSHOT("Block Snapshots");

PaperFeature(String feature) {
this.feature = feature;
}

private final String feature;

public String getFeature() {
return feature;
}
}