Skip to content

Commit d97896e

Browse files
committed
dynmap support
1 parent 9e4cf97 commit d97896e

File tree

11 files changed

+105
-27
lines changed

11 files changed

+105
-27
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<img src="https://github.com/czQery/ToolKit/blob/master/banner.png?raw=true" alt="Logo">
33
</p>
44

5-
[![Version](https://img.shields.io/badge/version-v3.7-informational.svg)](https://github.com/czQery/ToolKit/releases)
6-
[![Releases](https://img.shields.io/badge/download-1.19-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-3.7.jar)
5+
[![Version](https://img.shields.io/badge/version-v3.8-informational.svg)](https://github.com/czQery/ToolKit/releases)
6+
[![Releases](https://img.shields.io/badge/download-1.19-brightgreen.svg)](https://github.com/czQery/ToolKit/releases/latest/download/ToolKit-3.8.jar)
77

88
## Commands
99

@@ -24,6 +24,8 @@
2424
| /gmsp | toolkit.gmsp | toolkit.gmsp.other | Switch player's gamemode to SPECTATOR |
2525
| /spawn | toolkit.spawn | toolkit.spawn.other | Teleports player to spawn |
2626
| /fly | toolkit.fly | toolkit.fly.other | Allows the player to fly |
27+
| /wc | toolkit.wc | toolkit.wc.other | Clear weather |
28+
| /ic | toolkit.ic | toolkit.ic.other | Clear inventory |
2729

2830
| Command | Permission | Description |
2931
|----------|----------------|--------------------------------------------|
@@ -37,7 +39,7 @@
3739

3840
- Waypoints
3941
- Disabled mods
40-
- Automatically kick non lunar players
42+
- Automatically kick non-lunar players
4143

4244
## Trolls
4345

@@ -101,7 +103,6 @@ lunar:
101103
#lunar waypoints
102104
waypoints:
103105
- Spawn:
104-
name: Spawn
105106
color: '#ba1e0d'
106107
world: world
107108
x: 0

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>cz.qery</groupId>
67
<artifactId>ToolKit</artifactId>
7-
<version>3.8-SNAPSHOT</version>
8+
<version>3.8</version>
89
<packaging>jar</packaging>
910

1011
<name>ToolKit</name>
@@ -51,6 +52,7 @@
5152
<version>3.0.0</version>
5253
</dependency>
5354
<dependency>
55+
<!--Local m2-->
5456
<groupId>org.spigotmc</groupId>
5557
<artifactId>spigot</artifactId>
5658
<version>1.19.3-R0.1-SNAPSHOT</version>
@@ -61,6 +63,13 @@
6163
<artifactId>BukkitAPI-NetHandler</artifactId>
6264
<version>fab9915</version>
6365
</dependency>
66+
<dependency>
67+
<!--Local m2-->
68+
<groupId>us.dynmap</groupId>
69+
<artifactId>DynmapCoreAPI</artifactId>
70+
<version>3.5-beta-2</version>
71+
<scope>provided</scope>
72+
</dependency>
6473
<dependency>
6574
<groupId>net.kyori</groupId>
6675
<artifactId>adventure-api</artifactId>

src/main/java/cz/qery/toolkit/Dy.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package cz.qery.toolkit;
2+
3+
import org.dynmap.DynmapCommonAPI;
4+
5+
public class Dy {
6+
public static DynmapCommonAPI api;
7+
}

src/main/java/cz/qery/toolkit/Main.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void onEnable() {
5454
Objects.requireNonNull(getCommand("spawn")).setExecutor(new Aliases());
5555
Objects.requireNonNull(getCommand("fly")).setExecutor(new Aliases());
5656
Objects.requireNonNull(getCommand("wc")).setExecutor(new Aliases());
57-
Objects.requireNonNull(getCommand("clear")).setExecutor(new Aliases());
57+
Objects.requireNonNull(getCommand("ic")).setExecutor(new Aliases());
5858

5959
new Interact(this);
6060
new Join(this);
@@ -86,6 +86,11 @@ public void onEnable() {
8686
//bStats
8787
new Metrics(this, 11896);
8888

89+
//Dynmap
90+
if(getServer().getPluginManager().getPlugin("dynmap") != null) {
91+
new DyListener();
92+
}
93+
8994
Waypoint.Load();
9095
Mod.Load();
9196
CommandBlock.Load();

src/main/java/cz/qery/toolkit/Vnsh.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public static void Show(Player p, boolean init) {
4444
} else {
4545
plugin.getServer().broadcastMessage(Tools.chat(plugin.getConfig().getString("join.message")).replace("%player%",p.getName()));
4646
}
47+
48+
if (Dy.api != null) {
49+
Dy.api.setPlayerVisiblity(p.getName(), true);
50+
}
4751
}
4852

4953
for (Map.Entry<UUID, String> pl : players.entrySet()) {
@@ -74,6 +78,10 @@ public static void Hide(Player p, boolean init) {
7478
} else {
7579
plugin.getServer().broadcastMessage(Tools.chat(plugin.getConfig().getString("leave.message")).replace("%player%",p.getName()));
7680
}
81+
82+
if (Dy.api != null) {
83+
Dy.api.setPlayerVisiblity(p.getName(), false);
84+
}
7785
}
7886
p.setSleepingIgnored(true);
7987
p.setAllowFlight(true);

src/main/java/cz/qery/toolkit/commands/Aliases.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
102102
target.getWorld().setTime(1000);
103103
sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Weather cleared!"));
104104
}
105-
case "clear" -> {
105+
case "ic" -> {
106106
target.getInventory().setContents(new ItemStack[]{});
107107
sender.sendMessage(Tools.chat(b + "[" + n + "SERVER" + b + "]" + t + " Inventory cleared!"));
108108
}

src/main/java/cz/qery/toolkit/commands/Lunar.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cz.qery.toolkit.commands;
22

3+
import cz.qery.toolkit.Dy;
34
import cz.qery.toolkit.Main;
45
import cz.qery.toolkit.Tools;
56
import cz.qery.toolkit.lunar.Waypoint;

src/main/java/cz/qery/toolkit/commands/Vanish.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,12 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
5050
return false;
5151
}
5252
} else {
53-
sender.sendMessage(Tools.chat(b+"["+n+"VANISH"+b+"]"+t+" Please use "+h+"/vanish <player/list>"));
54-
return false;
53+
if ((sender instanceof Player)) {
54+
target = (Player) sender;
55+
} else {
56+
sender.sendMessage(Tools.chat(b+"["+n+"VANISH"+b+"]"+t+" Please use "+h+"/vanish <player/list>"));
57+
return false;
58+
}
5559
}
5660

5761

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package cz.qery.toolkit.events;
2+
3+
import cz.qery.toolkit.Dy;
4+
import cz.qery.toolkit.Main;
5+
import cz.qery.toolkit.Tools;
6+
import cz.qery.toolkit.lunar.Waypoint;
7+
import org.bukkit.Bukkit;
8+
import org.dynmap.DynmapCommonAPI;
9+
import org.dynmap.DynmapCommonAPIListener;
10+
11+
public class DyListener extends DynmapCommonAPIListener {
12+
static Main plugin = Main.getPlugin(Main.class);
13+
static String b = plugin.getConfig().getString("color.bracket");
14+
static String n = plugin.getConfig().getString("color.name");
15+
static String t = plugin.getConfig().getString("color.text");
16+
static String h = plugin.getConfig().getString("color.highlight");
17+
18+
public DyListener() {
19+
DynmapCommonAPIListener.register(this);
20+
}
21+
22+
@Override
23+
public void apiEnabled(DynmapCommonAPI api) {
24+
Dy.api = api;
25+
api.getMarkerAPI().createMarkerSet("toolkit.lunar", "Lunar", null, false);
26+
Bukkit.getScheduler().runTaskAsynchronously(plugin, Waypoint::Update);
27+
Tools.log(b+"["+n+"ToolKit"+b+"] &aDynmapAPI loaded!");
28+
}
29+
}

src/main/java/cz/qery/toolkit/lunar/Waypoint.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package cz.qery.toolkit.lunar;
22

33
import com.lunarclient.bukkitapi.nethandler.shared.LCPacketWaypointRemove;
4+
import cz.qery.toolkit.Dy;
45
import cz.qery.toolkit.Main;
56
import cz.qery.toolkit.Scripts;
67
import cz.qery.toolkit.Tools;
78
import org.bukkit.Bukkit;
89
import org.bukkit.entity.Player;
10+
import org.dynmap.markers.Marker;
911

1012
import java.util.ArrayList;
1113
import java.util.HashMap;
@@ -29,17 +31,16 @@ public static void Load() {
2931

3032
List<Map<?, ?>> maps = plugin.getConfig().getMapList("lunar.waypoints");
3133
for (Map<?, ?> map : maps) {
32-
for (Object entry : map.values()) {
33-
34-
if (!(entry instanceof HashMap)) {
35-
continue;
34+
map.forEach((k,v) -> {
35+
if (!(v instanceof HashMap)) {
36+
return;
3637
}
3738

38-
HashMap<String, Object> point = (HashMap<String, Object>)entry;
39+
HashMap<String, Object> point = (HashMap<String, Object>)v;
3940

40-
Waypoint waypoint = new Waypoint(point.get("name").toString(), (int) point.get("x"), (int) point.get("y"), (int) point.get("z"), point.get("world").toString(), point.get("color").toString());
41+
Waypoint waypoint = new Waypoint(k.toString(), (int) point.get("x"), (int) point.get("y"), (int) point.get("z"), point.get("world").toString(), point.get("color").toString());
4142
waypoints.add(waypoint);
42-
}
43+
});
4344
}
4445
}
4546

@@ -48,14 +49,17 @@ public static void Update() {
4849
for (Waypoint wp : waypoints) {
4950
HashMap<String, HashMap<String, Object>> waypoint_temp = new HashMap<String, HashMap<String, Object>>();
5051
HashMap<String, Object> waypoint_temp2 = new HashMap<String, Object>();
51-
waypoint_temp2.put("name", wp.name());
52-
waypoint_temp2.put("color", wp.color());
53-
waypoint_temp2.put("world", wp.world());
54-
waypoint_temp2.put("x", wp.x());
55-
waypoint_temp2.put("y", wp.y());
56-
waypoint_temp2.put("z", wp.z());
57-
waypoint_temp.put(wp.name(), waypoint_temp2);
52+
waypoint_temp2.put("color", wp.color);
53+
waypoint_temp2.put("world", wp.world);
54+
waypoint_temp2.put("x", wp.x);
55+
waypoint_temp2.put("y", wp.y);
56+
waypoint_temp2.put("z", wp.z);
57+
waypoint_temp.put(wp.name, waypoint_temp2);
5858
l.add(waypoint_temp);
59+
60+
if (Dy.api != null && Dy.api.getMarkerAPI().getMarkerSet("toolkit.lunar").findMarkerByLabel(wp.name) == null) {
61+
Dy.api.getMarkerAPI().getMarkerSet("toolkit.lunar").createMarker(wp.name, "<span style=\"color: "+wp.color+";\">⬤ </span><span>"+wp.name+"</span>", true, wp.world, wp.x, wp.y, wp.z, Dy.api.getMarkerAPI().getMarkerIcon("pin"), false);
62+
}
5963
}
6064
plugin.getConfig().set("lunar.waypoints", null);
6165
plugin.getConfig().set("lunar.waypoints", l);
@@ -76,6 +80,14 @@ public static void SendOne(Player p) {
7680
}
7781

7882
public static void Remove(String name, String world) {
83+
if (Dy.api != null) {
84+
Marker dyMarker = Dy.api.getMarkerAPI().getMarkerSet("toolkit.lunar").findMarkerByLabel(name);
85+
86+
if (dyMarker != null) {
87+
dyMarker.deleteMarker();
88+
}
89+
}
90+
7991
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
8092
for (Player pp : players) {
8193
Tools.sendLunarPacket(pp, new LCPacketWaypointRemove(name, world));

src/main/resources/plugin.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ authors: [ czQery ]
66
description: Set of useful tools
77
website: github.com/czQery/ToolKit
88

9+
softdepend: [ dynmap ]
10+
911
commands:
1012
crash:
1113
description: Lag/Crash players game
@@ -44,7 +46,7 @@ commands:
4446
description: Allows the player to fly
4547
wc:
4648
description: Clear weather
47-
clear:
49+
ic:
4850
description: Clear inventory
4951

5052
permissions:
@@ -109,7 +111,7 @@ permissions:
109111
description: Wc command
110112
toolkit.wc.other:
111113
description: Wc command
112-
toolkit.clear:
114+
toolkit.ic:
113115
description: Clear command
114-
toolkit.clear.other:
116+
toolkit.ic.other:
115117
description: CLear command

0 commit comments

Comments
 (0)