mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 22:17:17 +00:00
Fix dynmap warp command popup, auto-detect map plugin
This commit is contained in:
1 parent
18c739246b
commit
d158973450
5 files changed
+16
-54
No files matched your search
@@ -8,6 +8,7 @@ import net.william278.huskhomes.command.BukkitCommand;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.command.DisabledCommand;
|
||||
import net.william278.huskhomes.config.Locales;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.config.Settings;
|
||||
import net.william278.huskhomes.config.Spawn;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
@@ -22,7 +23,6 @@ import net.william278.huskhomes.network.Broker;
|
||||
import net.william278.huskhomes.network.PluginMessageBroker;
|
||||
import net.william278.huskhomes.network.RedisBroker;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.config.Server;
|
||||
import net.william278.huskhomes.position.World;
|
||||
import net.william278.huskhomes.random.NormalDistributionEngine;
|
||||
import net.william278.huskhomes.random.RandomTeleportEngine;
|
||||
@@ -36,7 +36,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
@@ -169,26 +168,18 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
|
||||
private void loadHooks() {
|
||||
this.hooks = new ArrayList<>();
|
||||
if (settings.doEconomy()) {
|
||||
if (getSettings().doEconomy()) {
|
||||
if (Bukkit.getPluginManager().getPlugin("RedisEconomy") != null) {
|
||||
hooks.add(new RedisEconomyHook(this));
|
||||
} else if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||
hooks.add(new VaultEconomyHook(this));
|
||||
}
|
||||
}
|
||||
if (settings.doMapHook()) {
|
||||
switch (settings.getMappingPlugin()) {
|
||||
case DYNMAP -> {
|
||||
final Plugin dynmapPlugin = Bukkit.getPluginManager().getPlugin("Dynmap");
|
||||
if (dynmapPlugin != null) {
|
||||
hooks.add(new DynmapHook(this));
|
||||
}
|
||||
}
|
||||
case BLUEMAP -> {
|
||||
if (Bukkit.getPluginManager().getPlugin("BlueMap") != null) {
|
||||
hooks.add(new BlueMapHook(this));
|
||||
}
|
||||
}
|
||||
if (getSettings().doMapHook()) {
|
||||
if (Bukkit.getPluginManager().getPlugin("Dynmap") != null) {
|
||||
hooks.add(new DynmapHook(this));
|
||||
} else if (Bukkit.getPluginManager().getPlugin("BlueMap") != null) {
|
||||
hooks.add(new BlueMapHook(this));
|
||||
}
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("Plan") != null) {
|
||||
@@ -440,9 +431,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
|
||||
metrics.addCustomChart(new SimplePie("database_type", () -> getSettings().getDatabaseType().getDisplayName()));
|
||||
metrics.addCustomChart(new SimplePie("using_economy", () -> Boolean.toString(getSettings().doEconomy())));
|
||||
metrics.addCustomChart(new SimplePie("using_map", () -> Boolean.toString(getSettings().doMapHook())));
|
||||
if (getSettings().doMapHook()) {
|
||||
metrics.addCustomChart(new SimplePie("map_type", () -> getSettings().getMappingPlugin().getDisplayName()));
|
||||
}
|
||||
getMapHook().ifPresent(hook -> metrics.addCustomChart(new SimplePie("map_type", hook::getName)));
|
||||
} catch (Exception e) {
|
||||
log(Level.WARNING, "Failed to register metrics", e);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import net.william278.annotaml.YamlKey;
|
||||
import net.william278.huskhomes.command.Command;
|
||||
import net.william278.huskhomes.database.Database;
|
||||
import net.william278.huskhomes.hook.EconomyHook;
|
||||
import net.william278.huskhomes.hook.MapHook;
|
||||
import net.william278.huskhomes.network.Broker;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -244,12 +243,9 @@ public class Settings {
|
||||
}
|
||||
|
||||
// Mapping plugins
|
||||
@YamlComment("Display public homes/warps on web maps (DYNMAP, BLUEMAP)")
|
||||
@YamlComment("Display public homes/warps on your web map (supports Dynmap and BlueMap)")
|
||||
@YamlKey("map_hook.enabled")
|
||||
private boolean doMapHook = false;
|
||||
|
||||
@YamlKey("map_hook.map_plugin")
|
||||
private MapHook.Plugin type = MapHook.Plugin.DYNMAP;
|
||||
private boolean doMapHook = true;
|
||||
|
||||
@YamlKey("map_hook.show_public_homes")
|
||||
private boolean publicHomesOnMap = true;
|
||||
@@ -479,10 +475,6 @@ public class Settings {
|
||||
return doMapHook;
|
||||
}
|
||||
|
||||
public MapHook.Plugin getMappingPlugin() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean doPublicHomesOnMap() {
|
||||
return publicHomesOnMap;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class BlueMapHook extends MapHook {
|
||||
private Map<String, MarkerSet> warpsMarkerSets;
|
||||
|
||||
public BlueMapHook(@NotNull HuskHomes plugin) {
|
||||
super(plugin, Plugin.BLUEMAP);
|
||||
super(plugin, "BlueMap");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DynmapHook extends MapHook {
|
||||
private MarkerSet warpsMarkers;
|
||||
|
||||
public DynmapHook(@NotNull HuskHomes plugin) {
|
||||
super(plugin, Plugin.DYNMAP);
|
||||
super(plugin, "Dynmap");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +75,7 @@ public class DynmapHook extends MapHook {
|
||||
.thumbnail(PUBLIC_HOME_MARKER_IMAGE_NAME)
|
||||
.field("Owner", home.getOwner().getUsername())
|
||||
.field("Description", plugin.getLocales().wrapText(home.getMeta().getDescription(), 60))
|
||||
.field("Command", "/phome " + home.getName())
|
||||
.field("Command", "/phome " + home.getOwner().getUsername() + "." + home.getName())
|
||||
.toHtml());
|
||||
});
|
||||
});
|
||||
@@ -116,7 +116,7 @@ public class DynmapHook extends MapHook {
|
||||
.setDescription(MarkerInformationPopup.create(warp.getName())
|
||||
.thumbnail(WARP_MARKER_IMAGE_NAME)
|
||||
.field("Description", plugin.getLocales().wrapText(warp.getMeta().getDescription(), 60))
|
||||
.field("Command", "/phome " + warp.getName())
|
||||
.field("Command", "/warp " + warp.getName())
|
||||
.toHtml());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,8 +15,8 @@ public abstract class MapHook extends Hook {
|
||||
protected static final String WARP_MARKER_IMAGE_NAME = "warp";
|
||||
protected static final String PUBLIC_HOME_MARKER_IMAGE_NAME = "public-home";
|
||||
|
||||
protected MapHook(@NotNull HuskHomes plugin, @NotNull MapHook.Plugin type) {
|
||||
super(plugin, type.getDisplayName());
|
||||
protected MapHook(@NotNull HuskHomes plugin, @NotNull String name) {
|
||||
super(plugin, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,23 +115,4 @@ public abstract class MapHook extends Hook {
|
||||
.orElse("Warps");
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies types of supported Map plugins
|
||||
*/
|
||||
public enum Plugin {
|
||||
DYNMAP("Dynmap"),
|
||||
BLUEMAP("BlueMap");
|
||||
|
||||
private final String displayName;
|
||||
|
||||
Plugin(@NotNull String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user