refactor!: Remove redundant MapInitializeEvent (#2507)

This commit is contained in:
Ben Woo 2023-02-03 22:11:38 +08:00 committed by GitHub
parent 0117159159
commit 4ad6c53ba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 45 deletions

View File

@ -82,7 +82,6 @@ import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVMapListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
@ -395,7 +394,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
pm.registerEvents(this.weatherListener, this);
pm.registerEvents(this.portalListener, this);
pm.registerEvents(this.worldListener, this);
pm.registerEvents(new MVMapListener(this), this);
}
/**

View File

@ -1,43 +0,0 @@
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;
}
/**
* This method is called when a map is initialized.
* @param event The event that was fired.
*/
@EventHandler
public void mapInitialize(final MapInitializeEvent event) {
for (final Player player : Bukkit.getOnlinePlayers()) {
if ((player.getItemInHand().getType() == Material.MAP
|| player.getItemInHand().getType() == Material.FILLED_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;
}
}
}
}