Skip to content

Commit d6521b5

Browse files
metrics and reload command
1 parent 9d58a50 commit d6521b5

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

.idea/workspace.xml

Lines changed: 34 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id 'java'
3-
id 'io.github.goooler.shadow' version '8.1.8'
43
id 'xyz.jpenilla.run-velocity' version '2.3.1'
54
id 'xyz.jpenilla.run-paper' version '2.3.1'
65
}
@@ -23,7 +22,6 @@ repositories {
2322
dependencies {
2423
compileOnly group: 'com.velocitypowered', name: 'velocity-api', version: "${project.velocity_api_version}"
2524
annotationProcessor group: 'com.velocitypowered', name: 'velocity-api', version: "${project.velocity_api_version}"
26-
implementation group: 'org.bstats', name: 'bstats-velocity', version: '3.1.0'
2725
}
2826

2927
java {
@@ -44,27 +42,12 @@ processResources {
4442
}
4543
}
4644

47-
// https://imperceptiblethoughts.com/shadow/
48-
shadowJar {
49-
configurations = [project.configurations.shadow]
50-
archiveFileName = "${project.name}-${project.version}-velocity.jar"
51-
destinationDirectory = layout.buildDirectory.dir('dist')
52-
53-
relocate 'org.bstats', 'org.zeroBzeroT.shaded.bstats'
54-
55-
// delete unshaded jar
56-
doLast {
57-
file(jar.archiveFile).delete()
58-
}
59-
}
60-
build.finalizedBy(shadowJar)
61-
6245
// test setup
6346
runPaper.disablePluginJarDetection()
6447
tasks {
6548
runVelocity {
6649
runDirectory = layout.projectDirectory.dir('run').dir('proxy')
67-
dependsOn('shadowJar')
50+
dependsOn('build')
6851
velocityVersion("${project.velocity_api_version}")
6952
downloadPlugins {
7053
url("https://github.com/ViaVersion/ViaBackwards/releases/download/5.3.2/ViaBackwards-5.3.2.jar")
@@ -78,7 +61,7 @@ tasks {
7861
systemProperty('com.mojang.eula.agree', 'true')
7962
systemProperty('Paper.skipServerPropertiesComments', 'true')
8063
runDirectory = layout.projectDirectory.dir('run').dir('main')
81-
dependsOn('shadowJar')
64+
dependsOn('build')
8265
}
8366

8467
tasks.register('runServerQueue', runServer.getClass() as Class<Task>) {
@@ -90,6 +73,6 @@ tasks {
9073
url("https://github.com/zeroBzeroT/QueuePlugin/releases/download/v3.0.0/QueuePlugin-3.0.0+1.21-paper.jar")
9174
url("https://github.com/dmulloy2/ProtocolLib/releases/download/5.3.0/ProtocolLib.jar")
9275
}
93-
dependsOn('shadowJar')
76+
dependsOn('build')
9477
}
9578
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
plugin_version=2.0.1
1+
plugin_version=2.0.2
22
velocity_api_version=3.4.0-SNAPSHOT
33
minecraft_version=1.20.4

src/main/java/org/zeroBzeroT/serverPingPlayerList/Main.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class Main {
2121
private final ProxyServer server;
2222
private final Logger logger;
2323
private final Path dataDirectory;
24-
//private final Factory factory;
2524

2625
private Config config;
2726
private ServerListListener serverListListener;
@@ -31,11 +30,11 @@ public class Main {
3130
private volatile ServerPing mainPing;
3231

3332
@Inject
34-
public Main(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory /*, Factory factory*/) {
33+
public Main(ProxyServer server, Logger logger, Metrics.Factory metricsFactory, @DataDirectory final Path dataDirectory) {
3534
this.server = server;
3635
this.logger = logger;
3736
this.dataDirectory = dataDirectory;
38-
//this.factory = factory;
37+
this.metricsFactory = metricsFactory;
3938
}
4039

4140
@Subscribe
@@ -59,7 +58,7 @@ public void onProxyInitialize(ProxyInitializeEvent event) {
5958

6059
// Load Plugin Metrics
6160
if (config.getBoolean("bStats")) {
62-
Metrics metrics = metricsFactory.make(this, 16229);
61+
metricsFactory.make(this, 16229);
6362
logger.info("bStats metrics enabled.");
6463
}
6564
}

src/main/java/org/zeroBzeroT/serverPingPlayerList/ReloadCommand.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.velocitypowered.api.command.CommandSource;
44
import com.velocitypowered.api.command.SimpleCommand;
5+
import com.velocitypowered.api.proxy.ConsoleCommandSource;
56
import net.kyori.adventure.text.Component;
67
import net.kyori.adventure.text.format.NamedTextColor;
78
import org.slf4j.Logger;
@@ -19,6 +20,12 @@ public ReloadCommand(Main plugin, Logger logger) {
1920
public void execute(Invocation invocation) {
2021
CommandSource sender = invocation.source();
2122

23+
// Check if the command is run from the console
24+
if (!(sender instanceof ConsoleCommandSource)) {
25+
sender.sendMessage(Component.text("This command can only be run from the console.", NamedTextColor.RED));
26+
return;
27+
}
28+
2229
sender.sendMessage(Component.text("Reloading config...", NamedTextColor.AQUA));
2330
try {
2431
plugin.reloadConfig();

0 commit comments

Comments
 (0)