Compare commits

...
6 changed files with 251 additions and 1 deletions

No files matched your search

+21
View File
@@ -20,6 +20,11 @@
<id>Bukkit Official</id>
<url>http://repo.bukkit.org/content/repositories/public</url>
</repository>
<!-- I've been told they'll have a repo this weekend :D
<repository>
<id>DynMap</id>
<url>TBD</url>
</repository> -->
<!-- Required for Metrics -->
<repository>
<id>mcstats</id>
@@ -278,6 +283,22 @@
<scope>compile</scope>
</dependency>
<!-- End of CommandHandler Dependency -->
<!-- Start DynMap Dependency -->
<dependency>
<groupId>org.dynmap</groupId>
<artifactId>DynmapCoreAPI</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.dynmap</groupId>
<artifactId>dynmap</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End DynMap Dependency -->
<!-- Start of Buscript Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
@@ -68,6 +68,7 @@ import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
import com.onarandombox.MultiverseCore.plugins.DynmapConnector;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
@@ -123,7 +124,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
private static Map<String, String> teleportQueue = new HashMap<String, String>();
private AnchorManager anchorManager = new AnchorManager(this);
// TODO please let's make this non-static
private DynmapConnector dynmapConnecter;
private volatile MultiverseCoreConfiguration config;
/**
@@ -337,6 +338,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
this.setSpout();
this.log(Level.INFO, "Spout integration enabled.");
}
// Check to see if Dynmap was already loaded:
if (this.getServer().getPluginManager().getPlugin("dynmap") != null) {
this.getDynmap();
this.log(Level.INFO, "Dynmap integration enabled.");
*/
this.initializeBuscript();
@@ -1307,6 +1313,22 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Listen
return MultiverseCoreConfiguration.getInstance();
}
/**
* Returns true if dynmap was detected.
* @return True if dynmap was detected.
*/
public boolean isDynmapLoaded() {
return !(this.dynmapConnecter == null);
}
public DynmapConnector getDynmap() {
return this.dynmapConnecter;
}
public void setDynmap() {
this.dynmapConnecter = new DynmapConnector(this.getServer().getPluginManager().getPlugin("dynmap"), this);
}
@Override
public Buscript getScriptAPI() {
return buscript;
@@ -48,6 +48,11 @@ public class MVPluginListener implements Listener {
this.plugin.setSpout();
this.plugin.log(Level.INFO, "Spout integration enabled.");
}
if (event.getPlugin().getDescription().getName().equals("dynmap")) {
this.plugin.setDynmap();
this.plugin.log(Level.INFO, "Dynmap integration enabled.");
}
*/
}
@@ -0,0 +1,57 @@
package com.onarandombox.MultiverseCore.plugins;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.plugins.destination.DynmapMarkerDestination;
import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
import org.dynmap.DynmapCore;
import org.dynmap.bukkit.DynmapPlugin;
import org.dynmap.markers.Marker;
import org.dynmap.markers.MarkerSet;
import java.util.List;
/**
* Non-Intrusive Connector class.
*/
public class DynmapConnector {
private DynmapPlugin plugin;
private MultiverseCore core;
/**
* This class should only ever get initialized ONCE!
*/
public DynmapConnector(Plugin dynmapCore, MultiverseCore core) {
this.plugin = ((DynmapPlugin) dynmapCore);
this.core = core;
this.addDestinationToManager();
}
private void addDestinationToManager() {
this.core.getDestFactory().registerDestinationType(DynmapMarkerDestination.class, "dm");
}
public Location getLocation(String markerSet, String marker) {
MarkerSet set = this.plugin.getMarkerAPI().getMarkerSet(markerSet);
if (set == null) {
return null;
}
// Try to find it by the ID
Marker m = set.findMarker(marker);
if (m != null) {
return this.getLocationFromMarker(m);
}
// Try to find it by the label
m = set.findMarkerByLabel(marker);
if (m != null) {
return this.getLocationFromMarker(m);
}
return null;
}
private Location getLocationFromMarker(Marker m) {
return new Location(this.core.getServer().getWorld(m.getWorld()), m.getX(), m.getY(), m.getZ());
}
}
@@ -0,0 +1,141 @@
package com.onarandombox.MultiverseCore.plugins.destination;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.plugins.DynmapConnector;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.List;
public class DynmapMarkerDestination implements MVDestination{
private MultiverseCore plugin;
private Location location;
private DynmapConnector dynmap;
private boolean isValid;
private String name;
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return "dm";
}
/**
* {@inheritDoc}
*/
@Override
public boolean isThisType(JavaPlugin plugin, String destination) {
if (!(plugin instanceof MultiverseCore)) {
return false;
}
this.plugin = (MultiverseCore) plugin;
if (!this.plugin.isDynmapLoaded()) {
return false;
}
List<String> parsed = Arrays.asList(destination.split(":"));
// Need at least: a:set:name
if (!(parsed.size() == 3)) {
return false;
}
// If it's not a Dynmap type
return parsed.get(0).equalsIgnoreCase("dm");
}
/**
* {@inheritDoc}
*/
@Override
public Location getLocation(Entity entity) {
return this.location;
}
/**
* {@inheritDoc}
*/
@Override
public Vector getVelocity() {
return new Vector(0, 0, 0);
}
/**
* {@inheritDoc}
*/
@Override
public void setDestination(JavaPlugin plugin, String destination) {
List<String> parsed = Arrays.asList(destination.split(":"));
if (!parsed.get(0).equalsIgnoreCase(this.getIdentifier())) {
this.isValid = false;
return;
}
if (!(plugin instanceof MultiverseCore)) {
return;
}
this.plugin = (MultiverseCore) plugin;
if (!this.plugin.isDynmapLoaded()) {
return;
}
this.dynmap = this.plugin.getDynmap();
// Need at least: e:world:x,y,z
// OR e:world:x,y,z:pitch:yaw
// so basically 3 or 5
if (!(parsed.size() == 3)) {
this.isValid = false;
return;
}
this.location = this.dynmap.getLocation(parsed.get(1), parsed.get(2));
if (this.location == null) {
this.isValid = false;
return;
}
this.isValid = true;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isValid() {
return this.isValid;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return "Dynmap Marker";
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return String.format("%s: %s", this.getType(), this.name);
}
/**
* {@inheritDoc}
*/
@Override
public String getRequiredPermission() {
return String.format("multiverse.access.", this.location.getWorld().getName());
}
/**
* {@inheritDoc}
*/
@Override
public boolean useSafeTeleporter() {
return false;
}
}
@@ -168,6 +168,10 @@ public class MVPermissions implements PermissionsInterface {
"The player will spawn at an %sindeterminate location%s. Talk to the MV Devs if you see this",
ChatColor.RED, ChatColor.WHITE));
cango = false;
asker.sendMessage(String.format(
"Here are some more details for you:"));
asker.sendMessage(d.toString());
return;
}
String worldName = d.getLocation(p).getWorld().getName();
if (!this.worldMgr.isMVWorld(worldName)) {