From d97896eee741b5dd1ee04e0a50ba0e928efe0e21 Mon Sep 17 00:00:00 2001
From: czQery
Date: Mon, 13 Feb 2023 17:27:49 +0100
Subject: [PATCH] dynmap support
---
README.md | 9 +++--
pom.xml | 13 +++++-
src/main/java/cz/qery/toolkit/Dy.java | 7 ++++
src/main/java/cz/qery/toolkit/Main.java | 7 +++-
src/main/java/cz/qery/toolkit/Vnsh.java | 8 ++++
.../cz/qery/toolkit/commands/Aliases.java | 2 +-
.../java/cz/qery/toolkit/commands/Lunar.java | 1 +
.../java/cz/qery/toolkit/commands/Vanish.java | 8 +++-
.../cz/qery/toolkit/events/DyListener.java | 29 ++++++++++++++
.../java/cz/qery/toolkit/lunar/Waypoint.java | 40 ++++++++++++-------
src/main/resources/plugin.yml | 8 ++--
11 files changed, 105 insertions(+), 27 deletions(-)
create mode 100644 src/main/java/cz/qery/toolkit/Dy.java
create mode 100644 src/main/java/cz/qery/toolkit/events/DyListener.java
diff --git a/README.md b/README.md
index bd4830d..a4247b5 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[![Version](https://img.shields.io/badge/version-v3.7-informational.svg)](https://github.com/czQery/ToolKit/releases)
-[![Releases](https://img.shields.io/badge/download-1.19-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-3.7.jar)
+[![Version](https://img.shields.io/badge/version-v3.8-informational.svg)](https://github.com/czQery/ToolKit/releases)
+[![Releases](https://img.shields.io/badge/download-1.19-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-3.8.jar)
## Commands
@@ -24,6 +24,8 @@
| /gmsp | toolkit.gmsp | toolkit.gmsp.other | Switch player's gamemode to SPECTATOR |
| /spawn | toolkit.spawn | toolkit.spawn.other | Teleports player to spawn |
| /fly | toolkit.fly | toolkit.fly.other | Allows the player to fly |
+| /wc | toolkit.wc | toolkit.wc.other | Clear weather |
+| /ic | toolkit.ic | toolkit.ic.other | Clear inventory |
| Command | Permission | Description |
|----------|----------------|--------------------------------------------|
@@ -37,7 +39,7 @@
- Waypoints
- Disabled mods
-- Automatically kick non lunar players
+- Automatically kick non-lunar players
## Trolls
@@ -101,7 +103,6 @@ lunar:
#lunar waypoints
waypoints:
- Spawn:
- name: Spawn
color: '#ba1e0d'
world: world
x: 0
diff --git a/pom.xml b/pom.xml
index 56f7289..0ca62d8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,10 +1,11 @@
-
+
4.0.0
cz.qery
ToolKit
- 3.8-SNAPSHOT
+ 3.8
jar
ToolKit
@@ -51,6 +52,7 @@
3.0.0
+
org.spigotmc
spigot
1.19.3-R0.1-SNAPSHOT
@@ -61,6 +63,13 @@
BukkitAPI-NetHandler
fab9915
+
+
+ us.dynmap
+ DynmapCoreAPI
+ 3.5-beta-2
+ provided
+
net.kyori
adventure-api
diff --git a/src/main/java/cz/qery/toolkit/Dy.java b/src/main/java/cz/qery/toolkit/Dy.java
new file mode 100644
index 0000000..f471797
--- /dev/null
+++ b/src/main/java/cz/qery/toolkit/Dy.java
@@ -0,0 +1,7 @@
+package cz.qery.toolkit;
+
+import org.dynmap.DynmapCommonAPI;
+
+public class Dy {
+ public static DynmapCommonAPI api;
+}
diff --git a/src/main/java/cz/qery/toolkit/Main.java b/src/main/java/cz/qery/toolkit/Main.java
index 85c9342..91d890a 100644
--- a/src/main/java/cz/qery/toolkit/Main.java
+++ b/src/main/java/cz/qery/toolkit/Main.java
@@ -54,7 +54,7 @@ public void onEnable() {
Objects.requireNonNull(getCommand("spawn")).setExecutor(new Aliases());
Objects.requireNonNull(getCommand("fly")).setExecutor(new Aliases());
Objects.requireNonNull(getCommand("wc")).setExecutor(new Aliases());
- Objects.requireNonNull(getCommand("clear")).setExecutor(new Aliases());
+ Objects.requireNonNull(getCommand("ic")).setExecutor(new Aliases());
new Interact(this);
new Join(this);
@@ -86,6 +86,11 @@ public void onEnable() {
//bStats
new Metrics(this, 11896);
+ //Dynmap
+ if(getServer().getPluginManager().getPlugin("dynmap") != null) {
+ new DyListener();
+ }
+
Waypoint.Load();
Mod.Load();
CommandBlock.Load();
diff --git a/src/main/java/cz/qery/toolkit/Vnsh.java b/src/main/java/cz/qery/toolkit/Vnsh.java
index e5f805d..1fe6ac3 100644
--- a/src/main/java/cz/qery/toolkit/Vnsh.java
+++ b/src/main/java/cz/qery/toolkit/Vnsh.java
@@ -44,6 +44,10 @@ public static void Show(Player p, boolean init) {
} else {
plugin.getServer().broadcastMessage(Tools.chat(plugin.getConfig().getString("join.message")).replace("%player%",p.getName()));
}
+
+ if (Dy.api != null) {
+ Dy.api.setPlayerVisiblity(p.getName(), true);
+ }
}
for (Map.Entry pl : players.entrySet()) {
@@ -74,6 +78,10 @@ public static void Hide(Player p, boolean init) {
} else {
plugin.getServer().broadcastMessage(Tools.chat(plugin.getConfig().getString("leave.message")).replace("%player%",p.getName()));
}
+
+ if (Dy.api != null) {
+ Dy.api.setPlayerVisiblity(p.getName(), false);
+ }
}
p.setSleepingIgnored(true);
p.setAllowFlight(true);
diff --git a/src/main/java/cz/qery/toolkit/commands/Aliases.java b/src/main/java/cz/qery/toolkit/commands/Aliases.java
index b3a3231..db41550 100644
--- a/src/main/java/cz/qery/toolkit/commands/Aliases.java
+++ b/src/main/java/cz/qery/toolkit/commands/Aliases.java
@@ -102,7 +102,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
target.getWorld().setTime(1000);
sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Weather cleared!"));
}
- case "clear" -> {
+ case "ic" -> {
target.getInventory().setContents(new ItemStack[]{});
sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Inventory cleared!"));
}
diff --git a/src/main/java/cz/qery/toolkit/commands/Lunar.java b/src/main/java/cz/qery/toolkit/commands/Lunar.java
index 9de7b78..ca45d4c 100644
--- a/src/main/java/cz/qery/toolkit/commands/Lunar.java
+++ b/src/main/java/cz/qery/toolkit/commands/Lunar.java
@@ -1,5 +1,6 @@
package cz.qery.toolkit.commands;
+import cz.qery.toolkit.Dy;
import cz.qery.toolkit.Main;
import cz.qery.toolkit.Tools;
import cz.qery.toolkit.lunar.Waypoint;
diff --git a/src/main/java/cz/qery/toolkit/commands/Vanish.java b/src/main/java/cz/qery/toolkit/commands/Vanish.java
index 11a1bd7..03dd0d3 100644
--- a/src/main/java/cz/qery/toolkit/commands/Vanish.java
+++ b/src/main/java/cz/qery/toolkit/commands/Vanish.java
@@ -50,8 +50,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
return false;
}
} else {
- sender.sendMessage(Tools.chat(b+"["+n+"VANISH"+b+"]"+t+" Please use "+h+"/vanish "));
- return false;
+ if ((sender instanceof Player)) {
+ target = (Player) sender;
+ } else {
+ sender.sendMessage(Tools.chat(b+"["+n+"VANISH"+b+"]"+t+" Please use "+h+"/vanish "));
+ return false;
+ }
}
diff --git a/src/main/java/cz/qery/toolkit/events/DyListener.java b/src/main/java/cz/qery/toolkit/events/DyListener.java
new file mode 100644
index 0000000..9245727
--- /dev/null
+++ b/src/main/java/cz/qery/toolkit/events/DyListener.java
@@ -0,0 +1,29 @@
+package cz.qery.toolkit.events;
+
+import cz.qery.toolkit.Dy;
+import cz.qery.toolkit.Main;
+import cz.qery.toolkit.Tools;
+import cz.qery.toolkit.lunar.Waypoint;
+import org.bukkit.Bukkit;
+import org.dynmap.DynmapCommonAPI;
+import org.dynmap.DynmapCommonAPIListener;
+
+public class DyListener extends DynmapCommonAPIListener {
+ static Main plugin = Main.getPlugin(Main.class);
+ static String b = plugin.getConfig().getString("color.bracket");
+ static String n = plugin.getConfig().getString("color.name");
+ static String t = plugin.getConfig().getString("color.text");
+ static String h = plugin.getConfig().getString("color.highlight");
+
+ public DyListener() {
+ DynmapCommonAPIListener.register(this);
+ }
+
+ @Override
+ public void apiEnabled(DynmapCommonAPI api) {
+ Dy.api = api;
+ api.getMarkerAPI().createMarkerSet("toolkit.lunar", "Lunar", null, false);
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, Waypoint::Update);
+ Tools.log(b+"["+n+"ToolKit"+b+"] &aDynmapAPI loaded!");
+ }
+}
diff --git a/src/main/java/cz/qery/toolkit/lunar/Waypoint.java b/src/main/java/cz/qery/toolkit/lunar/Waypoint.java
index 1a2057d..5c6246a 100644
--- a/src/main/java/cz/qery/toolkit/lunar/Waypoint.java
+++ b/src/main/java/cz/qery/toolkit/lunar/Waypoint.java
@@ -1,11 +1,13 @@
package cz.qery.toolkit.lunar;
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointRemove;
+import cz.qery.toolkit.Dy;
import cz.qery.toolkit.Main;
import cz.qery.toolkit.Scripts;
import cz.qery.toolkit.Tools;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
+import org.dynmap.markers.Marker;
import java.util.ArrayList;
import java.util.HashMap;
@@ -29,17 +31,16 @@ public static void Load() {
List