Skip to content

Commit

Permalink
🔼 Bstats
Browse files Browse the repository at this point in the history
  • Loading branch information
KaspianDev committed Aug 30, 2022
1 parent e018e20 commit d228bf2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 23 deletions.
34 changes: 18 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id "java"
id "com.github.johnrengelman.shadow" version "7.1.2"
}

group = 'com.github.kaspiandev'
version = '4.4'
group = "com.github.kaspiandev"
version = "4.5"

repositories {
mavenCentral()
maven { url 'https://repo.codemc.io/repository/maven-snapshots/' }
maven { url "https://repo.codemc.io/repository/maven-snapshots/" }
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven {
name = "No."
Expand All @@ -24,12 +24,13 @@ repositories {
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
compileOnly 'dev.dejvokep:boosted-yaml-spigot:1.3'
compileOnly 'org.apache.commons:commons-configuration2:2.8.0'
compileOnly "org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT"
compileOnly "dev.dejvokep:boosted-yaml-spigot:1.3"
compileOnly "org.apache.commons:commons-configuration2:2.8.0"
compileOnly "com.viaversion:viaversion:4.4.1"

implementation 'com.github.retrooper.packetevents:spigot:2.0.0-20220826.083630-42'
implementation "org.bstats:bstats-bukkit:3.0.0"
implementation "com.github.retrooper.packetevents:spigot:2.0.0-20220826.083630-42"
}

tasks {
Expand All @@ -42,8 +43,9 @@ tasks {
minimize()
relocate("io.github.retrooper.packetevents", "com.github.kaspiandev.antipopup.libs.io.github.retrooper.packetevents")
relocate("com.github.retrooper.packetevents", "com.github.kaspiandev.antipopup.libs.com.github.retrooper.packetevents")
relocate("org.bstats", "com.github.kaspiandev.antipopup.libs.org.bstats")
dependencies {
exclude(dependency('com.google.code.gson:gson:2.8.0'))
exclude(dependency("com.google.code.gson:gson:2.8.0"))
}
}
}
Expand All @@ -64,8 +66,8 @@ java {
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
filteringCharset "UTF-8"
filesMatching("plugin.yml") {
expand props
}
}
29 changes: 25 additions & 4 deletions src/main/java/com/github/kaspiandev/antipopup/AntiPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -25,6 +26,7 @@ public final class AntiPopup extends JavaPlugin {

static YamlDocument config;
static Plugin instance;
static Metrics metrics;

@Override
public void onLoad() {
Expand All @@ -37,7 +39,6 @@ public void onLoad() {
@Override
public void onEnable() {
instance = this;

try {
config = YamlDocument.create(new File(getDataFolder(), "config.yml"),
Objects.requireNonNull(getResource("config.yml")),
Expand All @@ -51,16 +52,21 @@ public void onEnable() {
throw new RuntimeException(ex);
}

if (config.getBoolean("bstats", false)) {
metrics = new Metrics(this, 16308);
getLogger().info("Loaded optional metrics.");
}

PacketEvents.getAPI().getEventManager().registerListener(new PacketEventsListener());
PacketEvents.getAPI().init();
getLogger().info("Initiated PacketEvents.");

Objects.requireNonNull(this.getCommand("antipopup")).setExecutor(new CommandRegister());
getLogger().info("Commands registered.");


if (getPluginManager().getPlugin("ViaVersion") != null
&& PacketEvents.getAPI().getServerManager().getVersion().equals(ServerVersion.V_1_19)) {
&& PacketEvents.getAPI().getServerManager().getVersion().equals(ServerVersion.V_1_19)) {
try {
var hookClass = ViaHook.class;
hookClass.getConstructor().newInstance();
Expand Down Expand Up @@ -92,7 +98,22 @@ public void onEnable() {
io.printStackTrace();
}
}
}, 1);
if (config.getBoolean("ask-bstats")) {
try {
getLogger().warning("--------------------[ READ ME PLEASE ]--------------------");
getLogger().warning("This is your first startup with AntiPopup.");
getLogger().warning("I would like to kindly ask you to enable bstats");
getLogger().warning("configuration value to help me improve AntiPopup.");
getLogger().warning("Because I respect your freedom it's disabled by default.");
getLogger().warning("Thanks for using AntiPopup! (you will not see this again)");
getLogger().warning("----------------------------------------------------------");
config.set("ask-bstats", false);
config.save();
} catch (IOException io) {
io.printStackTrace();
}
}
}, 5);
}

@Override
Expand Down
11 changes: 8 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
config-version: 7
config-version: 9

# Should we collect anonymous data about your server?
# false by default.
bstats: false

# Should we prevent messages from being reported?
# Leave as true unless you have a different plugin stripping those.
strip-signature: true

dont-send-header: true

# Do not touch this!
first-run: true
# Do not touch ones below!
first-run: true
ask-bstats: true

0 comments on commit d228bf2

Please sign in to comment.