Change 'int blkid' to 'String material' for block and sign-change events.

This commit is contained in:
Mitch Talmadge 2019-12-19 21:34:32 -07:00
parent 5dbb58dfda
commit a3cb46e286
6 changed files with 20 additions and 19 deletions

View File

@ -84,7 +84,7 @@ public class DynmapCore implements DynmapCommonAPI {
*/ */
public static abstract class EnableCoreCallbacks { public static abstract class EnableCoreCallbacks {
/** /**
* Called during enableCore to report that confniguration.txt is loaded * Called during enableCore to report that configuration.txt is loaded
*/ */
public abstract void configurationLoaded(); public abstract void configurationLoaded();
} }
@ -2400,10 +2400,10 @@ public class DynmapCore implements DynmapCommonAPI {
} }
@Override @Override
public void processSignChange(int blkid, String world, int x, int y, int z, public void processSignChange(String material, String world, int x, int y, int z,
String[] lines, String playerid) { String[] lines, String playerid) {
DynmapPlayer dp = server.getPlayer(playerid); DynmapPlayer dp = server.getPlayer(playerid);
listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, blkid, world, x, y, z, lines, dp); listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, material, world, x, y, z, lines, dp);
} }
public MapStorage getDefaultMapStorage() { public MapStorage getDefaultMapStorage() {

View File

@ -30,10 +30,10 @@ public class DynmapListenerManager {
public void chatEvent(DynmapPlayer p, String msg); public void chatEvent(DynmapPlayer p, String msg);
} }
public interface BlockEventListener extends EventListener { public interface BlockEventListener extends EventListener {
public void blockEvent(int blkid, String w, int x, int y, int z); public void blockEvent(String material, String w, int x, int y, int z);
} }
public interface SignChangeEventListener extends EventListener { public interface SignChangeEventListener extends EventListener {
public void signChangeEvent(int blkid, String w, int x, int y, int z, String[] lines, DynmapPlayer p); public void signChangeEvent(String material, String w, int x, int y, int z, String[] lines, DynmapPlayer p);
} }
public enum EventType { public enum EventType {
WORLD_LOAD, WORLD_LOAD,
@ -105,7 +105,7 @@ public class DynmapListenerManager {
} }
} }
} }
public void processBlockEvent(EventType type, int blkid, String world, int x, int y, int z) public void processBlockEvent(EventType type, String material, String world, int x, int y, int z)
{ {
ArrayList<EventListener> lst = listeners.get(type); ArrayList<EventListener> lst = listeners.get(type);
if(lst == null) return; if(lst == null) return;
@ -114,14 +114,14 @@ public class DynmapListenerManager {
EventListener el = lst.get(i); EventListener el = lst.get(i);
if(el instanceof BlockEventListener) { if(el instanceof BlockEventListener) {
try { try {
((BlockEventListener)el).blockEvent(blkid, world, x, y, z); ((BlockEventListener)el).blockEvent(material, world, x, y, z);
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("processBlockEvent(" + type + "," + blkid + "," + world + "," + x + "," + y + "," + z + ") - exception", t); Log.warning("processBlockEvent(" + type + "," + material + "," + world + "," + x + "," + y + "," + z + ") - exception", t);
} }
} }
} }
} }
public void processSignChangeEvent(EventType type, int blkid, String world, int x, int y, int z, String[] lines, DynmapPlayer p) public void processSignChangeEvent(EventType type, String material, String world, int x, int y, int z, String[] lines, DynmapPlayer p)
{ {
ArrayList<EventListener> lst = listeners.get(type); ArrayList<EventListener> lst = listeners.get(type);
if(lst == null) return; if(lst == null) return;
@ -130,9 +130,9 @@ public class DynmapListenerManager {
EventListener el = lst.get(i); EventListener el = lst.get(i);
if(el instanceof SignChangeEventListener) { if(el instanceof SignChangeEventListener) {
try { try {
((SignChangeEventListener)el).signChangeEvent(blkid, world, x, y, z, lines, p); ((SignChangeEventListener)el).signChangeEvent(material, world, x, y, z, lines, p);
} catch (Throwable t) { } catch (Throwable t) {
Log.warning("processSignChangeEvent(" + type + "," + blkid + "," + world + "," + x + "," + y + "," + z + ") - exception", t); Log.warning("processSignChangeEvent(" + type + "," + material + "," + world + "," + x + "," + y + "," + z + ") - exception", t);
} }
} }
} }

View File

@ -2603,7 +2603,7 @@ public class TexturePack {
* @param ps - perspective state * @param ps - perspective state
* @param mapiter - map iterator * @param mapiter - map iterator
* @param rslt - color result (returned with value) * @param rslt - color result (returned with value)
* @param blkid - block ID * @param blk - block state
* @param lastblocktype - last block ID * @param lastblocktype - last block ID
* @param ss - shader state * @param ss - shader state
*/ */

View File

@ -28,7 +28,7 @@ public class MarkerSignManager {
private static class SignListener implements DynmapListenerManager.SignChangeEventListener, Runnable { private static class SignListener implements DynmapListenerManager.SignChangeEventListener, Runnable {
@Override @Override
public void signChangeEvent(int blkid, String wname, int x, int y, int z, String[] lines, DynmapPlayer p) { public void signChangeEvent(String material, String wname, int x, int y, int z, String[] lines, DynmapPlayer p) {
if(mgr == null) if(mgr == null)
return; return;

View File

@ -135,7 +135,7 @@ public interface DynmapCommonAPI {
public boolean testIfPlayerInfoProtected(); public boolean testIfPlayerInfoProtected();
/** /**
* Process sign change * Process sign change
* @param blkid - block ID * @param material - block's Material enum value as a string
* @param world - world name * @param world - world name
* @param x - x coord * @param x - x coord
* @param y - y coord * @param y - y coord
@ -143,5 +143,5 @@ public interface DynmapCommonAPI {
* @param lines - sign lines (input and output) * @param lines - sign lines (input and output)
* @param playerid - player ID * @param playerid - player ID
*/ */
public void processSignChange(int blkid, String world, int x, int y, int z, String[] lines, String playerid); public void processSignChange(String material, String world, int x, int y, int z, String[] lines, String playerid);
} }

View File

@ -100,6 +100,7 @@ import org.dynmap.common.DynmapListenerManager.EventType;
import org.dynmap.hdmap.HDMap; import org.dynmap.hdmap.HDMap;
import org.dynmap.markers.MarkerAPI; import org.dynmap.markers.MarkerAPI;
import org.dynmap.modsupport.ModSupportImpl; import org.dynmap.modsupport.ModSupportImpl;
import org.dynmap.renderer.DynmapBlockState;
import org.dynmap.utils.MapChunkCache; import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.Polygon; import org.dynmap.utils.Polygon;
import org.dynmap.utils.VisibilityLimit; import org.dynmap.utils.VisibilityLimit;
@ -351,7 +352,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
Block b = evt.getBlock(); Block b = evt.getBlock();
if(b == null) return; /* Work around for stupid mods.... */ if(b == null) return; /* Work around for stupid mods.... */
Location l = b.getLocation(); Location l = b.getLocation();
core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().getId(), core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().name(),
getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ()); getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ());
} }
}, DynmapPlugin.this); }, DynmapPlugin.this);
@ -366,7 +367,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
DynmapPlayer dp = null; DynmapPlayer dp = null;
Player p = evt.getPlayer(); Player p = evt.getPlayer();
if(p != null) dp = new BukkitPlayer(p); if(p != null) dp = new BukkitPlayer(p);
core.listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, b.getType().getId(), core.listenerManager.processSignChangeEvent(EventType.SIGN_CHANGE, b.getType().name(),
getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ(), lines, dp); getWorld(l.getWorld()).getName(), l.getBlockX(), l.getBlockY(), l.getBlockZ(), lines, dp);
} }
}, DynmapPlugin.this); }, DynmapPlugin.this);
@ -1631,9 +1632,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
})); }));
} }
@Override @Override
public void processSignChange(int blkid, String world, int x, int y, int z, public void processSignChange(String material, String world, int x, int y, int z,
String[] lines, String playerid) { String[] lines, String playerid) {
core.processSignChange(blkid, world, x, y, z, lines, playerid); core.processSignChange(material, world, x, y, z, lines, playerid);
} }
Polygon getWorldBorder(World w) { Polygon getWorldBorder(World w) {