mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 05:55:48 +01:00
Maps can now be made for non default worlds! Fixes #972
This commit is contained in:
parent
b2135a8f42
commit
9e029ad6ae
@ -65,6 +65,7 @@ import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
|||||||
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||||
|
import com.onarandombox.MultiverseCore.listeners.MVMapListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||||
@ -463,7 +464,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
pm.registerEvents(this.pluginListener, this);
|
pm.registerEvents(this.pluginListener, this);
|
||||||
pm.registerEvents(this.weatherListener, this);
|
pm.registerEvents(this.weatherListener, this);
|
||||||
pm.registerEvents(this.portalListener, this);
|
pm.registerEvents(this.portalListener, this);
|
||||||
|
pm.registerEvents(new MVMapListener(this), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.onarandombox.MultiverseCore.listeners;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.MapInitializeEvent;
|
||||||
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener for bukkit map events.
|
||||||
|
*/
|
||||||
|
public class MVMapListener implements Listener {
|
||||||
|
|
||||||
|
private final MultiverseCore plugin;
|
||||||
|
|
||||||
|
public MVMapListener(final MultiverseCore plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void mapInitialize(final MapInitializeEvent event) {
|
||||||
|
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if ((player.getItemInHand().getType() == Material.MAP
|
||||||
|
|| player.getItemInHand().getType() == Material.EMPTY_MAP)
|
||||||
|
&& player.getItemInHand().getDurability() == event.getMap().getId()) {
|
||||||
|
final Location playerLoc = player.getLocation();
|
||||||
|
final MapView map = event.getMap();
|
||||||
|
map.setCenterX(playerLoc.getBlockX());
|
||||||
|
map.setCenterZ(playerLoc.getBlockZ());
|
||||||
|
map.setWorld(playerLoc.getWorld());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user