Adds Dynmap integration
Some checks failed
EpicKnarvik97/Stargate/pipeline/head There was a failure building this commit
Some checks failed
EpicKnarvik97/Stargate/pipeline/head There was a failure building this commit
This adds Dynmap integration for displaying Stargates in Dynmap API version is changed back to 1.18 as 1.19 is still kind of new Version is now 0.9.4.1
This commit is contained in:
parent
92c3eadf8f
commit
643a48392b
11
pom.xml
11
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>Stargate</artifactId>
|
||||
<version>0.9.4.0</version>
|
||||
<version>0.9.4.1</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@ -28,6 +28,10 @@
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dynmap</id>
|
||||
<url>https://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -65,6 +69,11 @@
|
||||
<version>4.13.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.dynmap</groupId>
|
||||
<artifactId>dynmap-api</artifactId>
|
||||
<version>3.1-beta-2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -3,6 +3,7 @@ package net.knarcraft.stargate.command;
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.ConfigOption;
|
||||
import net.knarcraft.stargate.config.ConfigTag;
|
||||
import net.knarcraft.stargate.config.DynmapManager;
|
||||
import net.knarcraft.stargate.config.OptionDataType;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalRegistry;
|
||||
@ -377,6 +378,10 @@ public class CommandConfig implements CommandExecutor {
|
||||
//Load or unload Vault and Economy as necessary
|
||||
Stargate.getStargateConfig().reloadEconomy();
|
||||
}
|
||||
if (ConfigTag.requiresDynmapReload(configOption)) {
|
||||
//Regenerate all Dynmap markers
|
||||
DynmapManager.addAllPortalMarkers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,18 @@ public enum ConfigOption {
|
||||
/**
|
||||
* The velocity of players exiting a stargate, relative to the entry velocity
|
||||
*/
|
||||
EXIT_VELOCITY("gates.exitVelocity", "The velocity of players exiting stargates, relative to the entry velocity", 0.1D);
|
||||
EXIT_VELOCITY("gates.exitVelocity", "The velocity of players exiting stargates, relative to the entry velocity", 0.1D),
|
||||
|
||||
/**
|
||||
* Whether to enable showing Stargates in Dynmap
|
||||
*/
|
||||
ENABLE_DYNMAP("dynmap.enableDynmap", "Whether to display Stargates in Dynmap's map", true),
|
||||
|
||||
/**
|
||||
* Whether to hide Dynmap icons by default
|
||||
*/
|
||||
DYNMAP_ICONS_DEFAULT_HIDDEN("dynmap.dynmapIconsHiddenByDefault",
|
||||
"Whether to hide Stargate's Dynmap icons by default, requiring the user to enable them.", true);
|
||||
|
||||
private final String configNode;
|
||||
private final String description;
|
||||
|
@ -9,7 +9,8 @@ public enum ConfigTag {
|
||||
|
||||
COLOR(new ConfigOption[]{ConfigOption.FREE_GATES_COLOR, ConfigOption.MAIN_SIGN_COLOR,
|
||||
ConfigOption.HIGHLIGHT_SIGN_COLOR, ConfigOption.PER_SIGN_COLORS}),
|
||||
FOLDER(new ConfigOption[]{ConfigOption.GATE_FOLDER, ConfigOption.PORTAL_FOLDER});
|
||||
FOLDER(new ConfigOption[]{ConfigOption.GATE_FOLDER, ConfigOption.PORTAL_FOLDER}),
|
||||
DYNMAP(new ConfigOption[]{ConfigOption.ENABLE_DYNMAP, ConfigOption.DYNMAP_ICONS_DEFAULT_HIDDEN});
|
||||
|
||||
private final ConfigOption[] taggedOptions;
|
||||
|
||||
@ -52,6 +53,16 @@ public enum ConfigTag {
|
||||
return FOLDER.isTagged(option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given config option requires a re-load of all Dynmap markers
|
||||
*
|
||||
* @param configOption <p>The config option to check</p>
|
||||
* @return <p>True if changing the config option requires a reload of all dynmap markers</p>
|
||||
*/
|
||||
public static boolean requiresDynmapReload(ConfigOption configOption) {
|
||||
return DYNMAP.isTagged(configOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given config option requires a portal reload to take effect
|
||||
*
|
||||
|
124
src/main/java/net/knarcraft/stargate/config/DynmapManager.java
Normal file
124
src/main/java/net/knarcraft/stargate/config/DynmapManager.java
Normal file
@ -0,0 +1,124 @@
|
||||
package net.knarcraft.stargate.config;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.portal.Portal;
|
||||
import net.knarcraft.stargate.portal.PortalRegistry;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.GenericMarker;
|
||||
import org.dynmap.markers.Marker;
|
||||
import org.dynmap.markers.MarkerIcon;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
|
||||
/**
|
||||
* A manager for dealing with everything Dynmap
|
||||
*/
|
||||
public final class DynmapManager {
|
||||
|
||||
private static MarkerSet markerSet;
|
||||
private static MarkerIcon portalIcon;
|
||||
|
||||
private DynmapManager() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the dynmap manager
|
||||
*
|
||||
* @param dynmapAPI <p>A reference</p>
|
||||
*/
|
||||
public static void initialize(DynmapAPI dynmapAPI) {
|
||||
if (dynmapAPI == null) {
|
||||
markerSet = null;
|
||||
portalIcon = null;
|
||||
} else {
|
||||
markerSet = dynmapAPI.getMarkerAPI().createMarkerSet("stargate", "Stargate", null, false);
|
||||
markerSet.setHideByDefault(Stargate.getStargateConfig().hideDynmapIcons());
|
||||
portalIcon = dynmapAPI.getMarkerAPI().getMarkerIcon("portal");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds all portal markers for all current portals
|
||||
*/
|
||||
public static void addAllPortalMarkers() {
|
||||
if (markerSet == null || Stargate.getStargateConfig().isDynmapDisabled()) {
|
||||
//Remove any existing markers if dynmap has been disabled after startup
|
||||
if (markerSet != null) {
|
||||
markerSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
||||
}
|
||||
return;
|
||||
}
|
||||
markerSet.setHideByDefault(Stargate.getStargateConfig().hideDynmapIcons());
|
||||
//Remove all existing markers for a clean start
|
||||
markerSet.getMarkers().forEach(GenericMarker::deleteMarker);
|
||||
|
||||
for (Portal portal : PortalRegistry.getAllPortals()) {
|
||||
addPortalMarker(portal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a portal marker for the given portal
|
||||
*
|
||||
* @param portal <p>The portal to add a marker for</p>
|
||||
*/
|
||||
public static void addPortalMarker(Portal portal) {
|
||||
if (markerSet == null || Stargate.getStargateConfig().isDynmapDisabled()) {
|
||||
return;
|
||||
}
|
||||
World world = portal.getWorld();
|
||||
if (portal.getOptions().isHidden() || world == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = portal.getBlockAt(portal.getGate().getLayout().getExit());
|
||||
Marker marker = markerSet.createMarker(getPortalMarkerId(portal), portal.getName(), world.getName(),
|
||||
location.getX(), location.getY(), location.getZ(), portalIcon, false);
|
||||
if (marker == null) {
|
||||
Stargate.logWarning(String.format(
|
||||
"""
|
||||
Unable to create marker for portal
|
||||
Portal marker id: %s
|
||||
Portal name: %s
|
||||
Portal world: %s
|
||||
Portal location: %s,%s,%s""",
|
||||
getPortalMarkerId(portal), portal.getName(), world.getName(), location.getX(), location.getY(),
|
||||
location.getZ()));
|
||||
return;
|
||||
}
|
||||
String markerDescription = String.format("<b>Name:</b> %s<br /><b>Network:</b> %s<br /><b>Destination:</b> " +
|
||||
"%s<br /><b>Owner:</b> %s<br />", portal.getName(), portal.getNetwork(),
|
||||
portal.getDestinationName(), portal.getOwner().getName());
|
||||
marker.setDescription(markerDescription);
|
||||
marker.setLabel(portal.getName(), true);
|
||||
marker.setMarkerIcon(portalIcon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the portal marker for the given portal
|
||||
*
|
||||
* @param portal <p>The portal to remove the marker for</p>
|
||||
*/
|
||||
public static void removePortalMarker(Portal portal) {
|
||||
if (markerSet == null || Stargate.getStargateConfig().isDynmapDisabled()) {
|
||||
return;
|
||||
}
|
||||
Marker marker = markerSet.findMarker(getPortalMarkerId(portal));
|
||||
if (marker != null) {
|
||||
marker.deleteMarker();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id used for the given portal's marker
|
||||
*
|
||||
* @param portal <p>The portal to get a marker id for</p>
|
||||
* @return <p></p>
|
||||
*/
|
||||
private static String getPortalMarkerId(Portal portal) {
|
||||
return portal.getNetwork() + "-:-" + portal.getName();
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
import org.dynmap.DynmapAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -101,6 +102,11 @@ public final class StargateConfig {
|
||||
|
||||
//Set up vault economy if vault has been loaded
|
||||
setupVaultEconomy();
|
||||
DynmapAPI dynmapAPI = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap");
|
||||
if (dynmapAPI != null) {
|
||||
DynmapManager.initialize(dynmapAPI);
|
||||
DynmapManager.addAllPortalMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,6 +158,24 @@ public final class StargateConfig {
|
||||
return (boolean) configOptions.get(ConfigOption.PERMISSION_DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether Dynmap integration is disabled
|
||||
*
|
||||
* @return <p>Whether Dynmap integration is disabled</p>
|
||||
*/
|
||||
public boolean isDynmapDisabled() {
|
||||
return !((boolean) configOptions.get(ConfigOption.ENABLE_DYNMAP));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether Dynmap icons should be hidden by default
|
||||
*
|
||||
* @return <p>Whether Dynmap icons should be hidden by default</p>
|
||||
*/
|
||||
public boolean hideDynmapIcons() {
|
||||
return (boolean) configOptions.get(ConfigOption.DYNMAP_ICONS_DEFAULT_HIDDEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the object containing economy config values
|
||||
*
|
||||
@ -189,6 +213,9 @@ public final class StargateConfig {
|
||||
startStopBungeeListener(stargateGateConfig.enableBungee());
|
||||
}
|
||||
|
||||
//Reload portal markers
|
||||
DynmapManager.addAllPortalMarkers();
|
||||
|
||||
messageSender.sendErrorMessage(sender, languageLoader.getString("reloaded"));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.knarcraft.stargate.portal;
|
||||
|
||||
import net.knarcraft.stargate.Stargate;
|
||||
import net.knarcraft.stargate.config.DynmapManager;
|
||||
import net.knarcraft.stargate.container.BlockLocation;
|
||||
import net.knarcraft.stargate.utility.PortalFileHelper;
|
||||
import org.bukkit.World;
|
||||
@ -224,6 +225,7 @@ public class PortalRegistry {
|
||||
|
||||
PortalFileHelper.saveAllPortals(portal.getWorld());
|
||||
portal.setRegistered(false);
|
||||
DynmapManager.removePortalMarker(portal);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -289,6 +291,7 @@ public class PortalRegistry {
|
||||
|
||||
allPortals.add(portal);
|
||||
portal.setRegistered(true);
|
||||
DynmapManager.addPortalMarker(portal);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,8 @@ gates:
|
||||
destroyedByExplosion: false
|
||||
# verifyPortals - Whether all the non-sign blocks are checked to match the gate layout when a stargate is loaded.
|
||||
verifyPortals: false
|
||||
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material)
|
||||
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using
|
||||
# destroyable open/closed material)
|
||||
protectEntrance: false
|
||||
functionality:
|
||||
enableBungee: false
|
||||
@ -48,18 +49,21 @@ gates:
|
||||
handleVehicles: true
|
||||
# handleEmptyVehicles - Whether to allow empty vehicles through gates (chest/hopper/tnt/furnace minecarts included)
|
||||
handleEmptyVehicles: true
|
||||
# handleCreatureTransportation - Whether to allow players to transport creatures by sending vehicles (minecarts, boats) through gates
|
||||
# handleCreatureTransportation - Whether to allow players to transport creatures by sending vehicles (minecarts,
|
||||
# boats) through gates
|
||||
handleCreatureTransportation: true
|
||||
# handleNonPlayerVehicles - Whether to allow vehicles with a passenger which is not a player through gates. handleCreatureTransportation must be enabled
|
||||
# handleNonPlayerVehicles - Whether to allow vehicles with a passenger which is not a player through gates.
|
||||
# handleCreatureTransportation must be enabled
|
||||
handleNonPlayerVehicles: true
|
||||
# handleLeashedCreatures - Whether to allow creatures lead by a player to teleport with the player
|
||||
handleLeashedCreatures: true
|
||||
# enableCraftBookRemoveOnEjectFix - Whether to enable a fix that causes loss of NBT data, but allows vehicle teleportation to work when CraftBook's remove minecart/boat on eject setting is enabled
|
||||
# enableCraftBookRemoveOnEjectFix - Whether to enable a fix that causes loss of NBT data, but allows vehicle
|
||||
# teleportation to work when CraftBook's remove minecart/boat on eject setting is enabled
|
||||
enableCraftBookRemoveOnEjectFix: false
|
||||
|
||||
#############################
|
||||
# ######################## #
|
||||
# stargate economy options #
|
||||
############################
|
||||
# ######################## #
|
||||
economy:
|
||||
# useEconomy - Whether to use an economy plugin
|
||||
useEconomy: false
|
||||
@ -78,14 +82,26 @@ economy:
|
||||
# freeGatesColor - The color to use for marking free gates
|
||||
freeGatesColor: DARK_GREEN
|
||||
|
||||
#################
|
||||
# ############# #
|
||||
# Debug options #
|
||||
#################
|
||||
# ############# #
|
||||
debugging:
|
||||
# debug - Debug -- Only enable if you have issues, massive console output
|
||||
debug: false
|
||||
# permissionDebug - This will output any and all Permissions checks to console, used for permissions debugging (Requires debug: true)
|
||||
# permissionDebug - This will output any and all Permissions checks to console, used for permissions debugging
|
||||
# (Requires debug: true)
|
||||
permissionDebug: false
|
||||
advanced:
|
||||
# waitForPlayerAfterTeleportDelay - The amount of ticks to wait before adding a player as passenger of a vehicle. On slow servers, a value of 6 is required to avoid client glitches after teleporting on a vehicle.
|
||||
waitForPlayerAfterTeleportDelay: 6
|
||||
# waitForPlayerAfterTeleportDelay - The amount of ticks to wait before adding a player as passenger of a vehicle.
|
||||
# On slow servers, a value of 6 is required to avoid client glitches after teleporting on a vehicle.
|
||||
waitForPlayerAfterTeleportDelay: 6
|
||||
|
||||
# ############## #
|
||||
# Dynmap options #
|
||||
# ############## #
|
||||
dynmap:
|
||||
# enableDynmap - Whether to display Stargates in Dynmap's map
|
||||
enableDynmap: true
|
||||
# dynmapIconsHiddenByDefault - Whether to hide the set of Stargate icons by default, requiring users to
|
||||
# manually enable them with a checkbox.
|
||||
dynmapIconsHiddenByDefault: true
|
@ -1,12 +1,12 @@
|
||||
name: Stargate
|
||||
main: net.knarcraft.stargate.Stargate
|
||||
version: 0.9.4.0
|
||||
version: 0.9.4.1
|
||||
description: Stargate mod for Bukkit Revived
|
||||
author: EpicKnarvik97
|
||||
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
|
||||
website: https://git.knarcraft.net/EpicKnarvik97/Stargate
|
||||
api-version: 1.19
|
||||
softdepend: [ Vault ]
|
||||
api-version: 1.18
|
||||
softdepend: [ Vault, dynmap ]
|
||||
commands:
|
||||
stargate:
|
||||
aliases:
|
||||
|
Loading…
Reference in New Issue
Block a user