Skip to content

Commit 8260162

Browse files
committed
feat: dev alerts
1 parent 3285636 commit 8260162

File tree

4 files changed

+64
-17
lines changed

4 files changed

+64
-17
lines changed

pom.xml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<project xmlns="http://maven.apache.org/POM/4.0.0">
23
<modelVersion>4.0.0</modelVersion>
34
<groupId>xyz.webmc</groupId>
45
<artifactId>wlib</artifactId>
56
<version>1.1.0-SNAPSHOT</version>
7+
<distributionManagement>
8+
<repository>
9+
<id>github</id>
10+
<url>https://maven.pkg.github.com/WebMCDevelopment/wlib/</url>
11+
</repository>
12+
</distributionManagement>
613
<properties>
714
<plugin.name>WLIB</plugin.name>
815
<plugin.vers>${project.version}</plugin.vers>
@@ -12,20 +19,20 @@
1219
</properties>
1320
<dependencies>
1421
<dependency>
15-
<groupId>org.bukkit</groupId>
16-
<artifactId>bukkit</artifactId>
17-
<version>1.8-R0.1-SNAPSHOT</version>
18-
<scope>provided</scope>
22+
<groupId>com.tcoded</groupId>
23+
<artifactId>FoliaLib</artifactId>
24+
<version>0.5.1</version>
1925
</dependency>
2026
<dependency>
2127
<groupId>dev.colbster937</groupId>
2228
<artifactId>mirror</artifactId>
2329
<version>1.0.0-SNAPSHOT</version>
2430
</dependency>
2531
<dependency>
26-
<groupId>com.tcoded</groupId>
27-
<artifactId>FoliaLib</artifactId>
28-
<version>0.5.1</version>
32+
<groupId>org.bukkit</groupId>
33+
<artifactId>bukkit</artifactId>
34+
<version>1.8-R0.1-SNAPSHOT</version>
35+
<scope>provided</scope>
2936
</dependency>
3037
</dependencies>
3138
<repositories>
@@ -46,8 +53,8 @@
4653
<finalName>${project.artifactId}-${project.version}</finalName>
4754
<resources>
4855
<resource>
49-
<directory>src/main/resources</directory>
5056
<filtering>true</filtering>
57+
<directory>src/main/resources</directory>
5158
</resource>
5259
</resources>
5360
<plugins>
@@ -57,10 +64,10 @@
5764
<version>3.6.2</version>
5865
<executions>
5966
<execution>
60-
<phase>package</phase>
6167
<goals>
6268
<goal>shade</goal>
6369
</goals>
70+
<phase>package</phase>
6471
<configuration>
6572
<shadedArtifactAttached>false</shadedArtifactAttached>
6673
<createDependencyReducedPom>true</createDependencyReducedPom>
@@ -78,12 +85,24 @@
7885
</execution>
7986
</executions>
8087
</plugin>
88+
<plugin>
89+
<groupId>net.revelc.code</groupId>
90+
<artifactId>impsort-maven-plugin</artifactId>
91+
<version>1.13.0</version>
92+
<executions>
93+
<execution>
94+
<id>sort-imports</id>
95+
<goals>
96+
<goal>sort</goal>
97+
</goals>
98+
</execution>
99+
</executions>
100+
<configuration>
101+
<removeUnused>true</removeUnused>
102+
<staticAfter>true</staticAfter>
103+
<groups>xyz.webmc.,java.,javax.</groups>
104+
</configuration>
105+
</plugin>
81106
</plugins>
82107
</build>
83-
<distributionManagement>
84-
<repository>
85-
<id>github</id>
86-
<url>https://maven.pkg.github.com/WebMCDevelopment/wlib/</url>
87-
</repository>
88-
</distributionManagement>
89-
</project>
108+
</project>

src/main/java/xyz/webmc/wlib/WLIBBukkitPlugin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ public final void onEnable() {
1515
PluginUtil.init(this);
1616
SchedulerUtil.init(this);
1717
}
18+
19+
@Override
20+
public final void onDisable() {
21+
SchedulerUtil.cancelAllTasks();
22+
}
1823
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package xyz.webmc.wlib.util;
2+
3+
import java.lang.StackWalker.Option;
4+
5+
import org.bukkit.Bukkit;
6+
import org.bukkit.ChatColor;
7+
import org.bukkit.entity.Player;
8+
9+
public final class AlertUtil {
10+
private static final StackWalker sw = StackWalker.getInstance(Option.RETAIN_CLASS_REFERENCE);
11+
12+
public static final void devAlert(final String... msg) {
13+
final Class<?> clazz = sw.walk(s -> s.skip(2).findFirst().get().getDeclaringClass());
14+
final String str = ChatColor.DARK_GREEN + "[" + ChatColor.GREEN + "DEV" + ChatColor.DARK_GREEN + "] ["
15+
+ ChatColor.GREEN + clazz.getSimpleName() + ChatColor.DARK_GREEN + "] " + ChatColor.RESET
16+
+ String.join(" ", msg);
17+
for (final Player p : Bukkit.getOnlinePlayers()) {
18+
if (p.hasPermission("wlib.dev-alert")) {
19+
p.sendMessage(str);
20+
}
21+
}
22+
}
23+
}

src/main/java/xyz/webmc/wlib/util/SchedulerUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ public static final WrappedTask runAtEntityLater(final Entity ent, final Runnabl
8686
public static final WrappedTask runAtEntityTimer(final Entity ent, final Runnable task, final long delayTicks, final long periodTicks) {
8787
return sch.runAtEntityTimer(ent, task, delayTicks, periodTicks);
8888
}
89-
}
89+
}

0 commit comments

Comments
 (0)