Update GridLines
This commit is contained in:
parent
ce88aa999d
commit
e670ccf1a1
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "com.alttd.gridlines"
|
||||
version = "1.0-SNAPSHOT"
|
||||
version = "2.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
|
|
@ -15,6 +15,6 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
|
||||
compileOnly("maven.modrinth:pl3xmap:1.19.2-306")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("maven.modrinth:pl3xmap:1.20.1-464")
|
||||
}
|
||||
|
|
@ -1,15 +1,32 @@
|
|||
package com.alttd.gridlines;
|
||||
|
||||
import com.alttd.gridlines.configuration.Config;
|
||||
import com.alttd.gridlines.layer.GridLinesLayer;
|
||||
import com.alttd.gridlines.listener.WorldListener;
|
||||
import net.pl3x.map.Pl3xMap;
|
||||
import net.pl3x.map.addon.Addon;
|
||||
import net.pl3x.map.core.Pl3xMap;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class GridLines extends Addon {
|
||||
public class GridLines extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Config.reload();
|
||||
Pl3xMap.api().getEventRegistry().register(new WorldListener(this));
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Pl3xMap")) {
|
||||
getLogger().severe("Pl3xMap not found!");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
new Config().reload();
|
||||
getServer().getPluginManager().registerEvents(new WorldListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Pl3xMap.api().getWorldRegistry().forEach(world -> {
|
||||
try {
|
||||
world.getLayerRegistry().unregister(GridLinesLayer.KEY);
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package com.alttd.gridlines.configuration;
|
||||
|
||||
import net.pl3x.map.addon.AddonRegistry;
|
||||
import net.pl3x.map.configuration.AbstractConfig;
|
||||
import com.alttd.gridlines.GridLines;
|
||||
import net.pl3x.map.core.configuration.AbstractConfig;
|
||||
|
||||
public class Config extends AbstractConfig {
|
||||
|
||||
public Config() {
|
||||
reload();
|
||||
}
|
||||
|
||||
@Key("settings.layer.label")
|
||||
@Comment("Label for map layer")
|
||||
public static String LAYER_LABEL = "Gridlines";
|
||||
|
|
@ -23,7 +27,7 @@ public class Config extends AbstractConfig {
|
|||
|
||||
private static final Config CONFIG = new Config();
|
||||
|
||||
public static void reload() {
|
||||
CONFIG.reload(AddonRegistry.ADDONS_CONFIG_DIR.resolve("GridLines.yml"), Config.class);
|
||||
public void reload() {
|
||||
reload(GridLines.getPlugin(GridLines.class).getDataFolder().toPath(), Config.class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package com.alttd.gridlines.layer;
|
||||
|
||||
import com.alttd.gridlines.GridLines;
|
||||
import com.alttd.gridlines.configuration.Config;
|
||||
import net.pl3x.map.Key;
|
||||
import net.pl3x.map.markers.Point;
|
||||
import net.pl3x.map.markers.layer.SimpleLayer;
|
||||
import net.pl3x.map.markers.marker.Marker;
|
||||
import net.pl3x.map.markers.marker.Polyline;
|
||||
import net.pl3x.map.markers.option.Fill;
|
||||
import net.pl3x.map.markers.option.Options;
|
||||
import net.pl3x.map.markers.option.Stroke;
|
||||
import net.pl3x.map.world.World;
|
||||
|
||||
import net.pl3x.map.core.markers.Point;
|
||||
import net.pl3x.map.core.markers.layer.WorldLayer;
|
||||
import net.pl3x.map.core.markers.marker.Marker;
|
||||
import net.pl3x.map.core.markers.marker.Polyline;
|
||||
import net.pl3x.map.core.markers.option.Fill;
|
||||
import net.pl3x.map.core.markers.option.Options;
|
||||
import net.pl3x.map.core.markers.option.Stroke;
|
||||
import net.pl3x.map.core.world.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -18,16 +17,14 @@ import org.jetbrains.annotations.NotNull;
|
|||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class GridLinesLayer extends SimpleLayer {
|
||||
public class GridLinesLayer extends WorldLayer {
|
||||
|
||||
public static final Key KEY = Key.of("gridlines");
|
||||
public static final String KEY = "gridlines";
|
||||
private final Collection<Marker<?>> MARKERS = new HashSet<>();
|
||||
private final GridLines addon;
|
||||
private final World mapWorld;
|
||||
|
||||
public GridLinesLayer(GridLines addon, @NotNull World world) {
|
||||
super(KEY, () -> Config.LAYER_LABEL);
|
||||
this.addon = addon;
|
||||
public GridLinesLayer(@NotNull World world) {
|
||||
super(KEY, world, () -> Config.LAYER_LABEL);
|
||||
this.mapWorld = world;
|
||||
setShowControls(Config.LAYER_SHOW_CONTROLS);
|
||||
setDefaultHidden(Config.LAYER_DEFAULT_HIDDEN);
|
||||
|
|
@ -53,20 +50,20 @@ public class GridLinesLayer extends SimpleLayer {
|
|||
String key = "gridline";
|
||||
for(int i = -64; i < radius; i += 128) {
|
||||
t = i * -1;
|
||||
MARKERS.add(Marker.multiPolyline(Key.of(key + "-" + i),
|
||||
Polyline.of(Key.of(key + i + "-1"),
|
||||
MARKERS.add(Marker.multiPolyline(key + "-" + i,
|
||||
Polyline.of(key + i + "-1",
|
||||
Point.of(radius, i),
|
||||
Point.of(radius2, i)
|
||||
),
|
||||
Polyline.of(Key.of(key + i + "-2"),
|
||||
Polyline.of(key + i + "-2",
|
||||
Point.of(i, radius),
|
||||
Point.of(i, radius2)
|
||||
),
|
||||
Polyline.of(Key.of(key + i + "-3"),
|
||||
Polyline.of(key + i + "-3",
|
||||
Point.of(radius, t),
|
||||
Point.of(radius2, t)
|
||||
),
|
||||
Polyline.of(Key.of(key + i + "-4"),
|
||||
Polyline.of(key + i + "-4",
|
||||
Point.of(t, radius),
|
||||
Point.of(t, radius2)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,34 +1,29 @@
|
|||
package com.alttd.gridlines.listener;
|
||||
|
||||
import com.alttd.gridlines.GridLines;
|
||||
import com.alttd.gridlines.layer.GridLinesLayer;
|
||||
import net.pl3x.map.Pl3xMap;
|
||||
import net.pl3x.map.event.EventHandler;
|
||||
import net.pl3x.map.event.EventListener;
|
||||
import net.pl3x.map.event.server.ServerLoadedEvent;
|
||||
import net.pl3x.map.event.world.WorldLoadedEvent;
|
||||
import net.pl3x.map.event.world.WorldUnloadedEvent;
|
||||
import net.pl3x.map.core.Pl3xMap;
|
||||
import net.pl3x.map.core.event.EventListener;
|
||||
import net.pl3x.map.core.event.server.ServerLoadedEvent;
|
||||
import net.pl3x.map.core.event.world.WorldLoadedEvent;
|
||||
import net.pl3x.map.core.event.world.WorldUnloadedEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class WorldListener implements EventListener {
|
||||
private final GridLines addon;
|
||||
|
||||
public WorldListener(GridLines addon) {
|
||||
this.addon = addon;
|
||||
}
|
||||
public class WorldListener implements Listener, EventListener {
|
||||
|
||||
@EventHandler
|
||||
public void onServerLoaded(ServerLoadedEvent event) {
|
||||
Pl3xMap.api().getWorldRegistry().entries().forEach((key, world) ->
|
||||
world.getLayerRegistry().register(new GridLinesLayer(addon, world))
|
||||
Pl3xMap.api().getWorldRegistry().forEach(world ->
|
||||
world.getLayerRegistry().register(new GridLinesLayer(world))
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@net.pl3x.map.core.event.EventHandler
|
||||
public void onWorldLoaded(WorldLoadedEvent event) {
|
||||
event.getWorld().getLayerRegistry().register(new GridLinesLayer(addon, event.getWorld()));
|
||||
event.getWorld().getLayerRegistry().register(new GridLinesLayer(event.getWorld()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@net.pl3x.map.core.event.EventHandler
|
||||
public void onWorldUnloaded(WorldUnloadedEvent event) {
|
||||
event.getWorld().getLayerRegistry().unregister(GridLinesLayer.KEY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +0,0 @@
|
|||
name: "GridLines"
|
||||
main: "com.alttd.gridlines.GridLines"
|
||||
version: "1.0-SNAPSHOT"
|
||||
author: "destro174"
|
||||
8
src/main/resources/plugin.yml
Normal file
8
src/main/resources/plugin.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
name: "GridLines"
|
||||
main: "com.alttd.gridlines.GridLines"
|
||||
version: "2.0-SNAPSHOT"
|
||||
author: "destro174"
|
||||
api-version: "1.20"
|
||||
load: "POSTWORLD"
|
||||
softdepend:
|
||||
- Pl3xMap
|
||||
Loading…
Reference in New Issue
Block a user