Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Custom metrics and jd plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Majekdor committed Jul 3, 2021
1 parent bc330e0 commit 1c1ff1e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
22 changes: 17 additions & 5 deletions src/main/java/dev/majek/nicks/Nicks.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import dev.majek.nicks.api.NicksApi;
import dev.majek.nicks.command.*;
import dev.majek.nicks.event.ChatFormatter;
import dev.majek.nicks.command.CommandNick;
import dev.majek.nicks.command.CommandNickColor;
import dev.majek.nicks.command.CommandNickOther;
import dev.majek.nicks.command.CommandNicksReload;
import dev.majek.nicks.command.CommandNoNick;
import dev.majek.nicks.config.ConfigUpdater;
import dev.majek.nicks.config.JsonConfig;
import dev.majek.nicks.config.NicksConfig;
import dev.majek.nicks.event.ChatFormatter;
import dev.majek.nicks.event.PlayerJoin;
import dev.majek.nicks.util.NicksUtils;
import java.io.File;
Expand All @@ -46,6 +50,7 @@
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
Expand All @@ -67,6 +72,7 @@ public final class Nicks extends JavaPlugin {
private static NicksConfig config;
private final JsonConfig storage;
private final Map<UUID, Component> nickMap;
private final Metrics metrics;

/**
* Initialize plugin.
Expand All @@ -84,6 +90,8 @@ public Nicks() {
e.printStackTrace();
}
nickMap = new HashMap<>();
// Track plugin metrics through bStats
metrics = new Metrics(this, 11860);
}

/**
Expand All @@ -107,12 +115,16 @@ public void onEnable() {
}
log("Successfully loaded nicknames from Json storage.");

// Track metrics
new Metrics(this, 11860);

// Register plugin commands
registerCommands();

// Custom chart to see what percentage of servers are supporting legacy
metrics.addCustomChart(new SimplePie("supporting_legacy",
() -> String.valueOf(Nicks.config().LEGACY_COLORS)));
// Custom chart to see what percentage of servers are using the built in chat formatter
metrics.addCustomChart(new SimplePie("using-chat-formatter",
() -> String.valueOf(Nicks.config().CHAT_FORMATTER)));

// Register events
registerEvents(new PlayerJoin(), new ChatFormatter());
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/dev/majek/nicks/config/NicksMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public interface NicksMessages {
Args0 PLUGIN_RELOADED = () -> MiniMessage.get().parse(Nicks.core().getConfig()
.getString("messages.pluginReloaded", "<green>Plugin reloaded."));

/**
* A message that has no arguments that need to be replaced.
*/
interface Args0 {
Component build();

Expand All @@ -90,6 +93,9 @@ default void send(Audience audience) {
}
}

/**
* A message that has one argument that needs to be replaced.
*/
interface Args1<A0> {
Component build(A0 arg0);

Expand All @@ -98,6 +104,9 @@ default void send(Audience audience, A0 arg0) {
}
}

/**
* A message that has two arguments that need to be replaced.
*/
interface Args2<A0, A1> {
Component build(A0 arg0, A1 arg1);

Expand Down
16 changes: 0 additions & 16 deletions src/test/java/Test.java

This file was deleted.

0 comments on commit 1c1ff1e

Please sign in to comment.