techbrew

JourneyMap Client API v1 DRAFT

Dec 10th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.08 KB | None | 0 0
  1. /*///////////////////////////////////////////////////////////////////////
  2. This is a draft.  Feedback/comments welcome on Espernet IRC #journeymap
  3. //////////////////////////////////////////////////////////////////////*/
  4.        
  5. package journeymap.api.v1;
  6.  
  7. import java.util.List;
  8.  
  9. /**
  10.  * JourneyMap Client API v1 DRAFT (Dec 10, 2015 18:00)
  11.  */
  12. public interface JourneymapClientAPI
  13. {
  14.     /**
  15.      * Whether the JourneyMap client mod is loaded.
  16.      *
  17.      * @return true if loaded
  18.      */
  19.     public boolean isModLoaded();
  20.  
  21.     /**
  22.      * Whether the JourneyMap client mod loaded has a compatible
  23.      * version of the API.
  24.      *
  25.      * @return true if mod is loaded and API is compatible
  26.      */
  27.     public boolean isModAPICompatible();
  28.  
  29.     /**
  30.      * The API version of the JourneyMap client mod.
  31.      *
  32.      * @return 0 if client mod isn't loaded, otherwise the API version.
  33.      */
  34.     public int getModAPIVersion();
  35.  
  36.     /**
  37.      * Check whether player will accept waypoint additions/removals by your mod.
  38.      *
  39.      * @param modId Mod id
  40.      * @return Unknown: Player hasn't decided how to respond to waypoint suggestions.
  41.      * Prompt:  Player will be prompted to add/remove each suggested waypoint.
  42.      * Allow:   Player will automatically add/remove suggested waypoints
  43.      * Block:   Player will not receive waypoints from your mod.
  44.      */
  45.     public PlayerResponse checkPlayerWaypointOptIn(String modId);
  46.  
  47.     /**
  48.      * Check whether player will accept map overlays (markers and polygons) from your mod.
  49.      *
  50.      * @param modId Mod id
  51.      * @return Unknown: Player hasn't decided how to respond to map overlays.
  52.      * Allow:   Player will receive and automatically see map overlays.
  53.      * Hide:    Player will receive map overlays but is currently hiding them.
  54.      * Block:   Player will not receive map overlays from your mod.
  55.      */
  56.     public PlayerResponse checkPlayerMapOverlayOptIn(String modId);
  57.  
  58.     /**
  59.      * Suggest a waypoint to the player. The outcome is based on what the PlayerResponse is
  60.      * regarding your mod and waypoint suggestions.  Note that just because a player accepts
  61.      * a suggested waypoint, doesn't mean they'll keep it forever.
  62.      *
  63.      * @param modId          Mod id
  64.      * @param specification  Specification for the waypoint to display.
  65.      * @see #checkPlayerWaypointOptIn(String)
  66.      */
  67.     public void addWaypoint(String modId, WaypointSpec specification);
  68.  
  69.     /**
  70.      * Remove a player's waypoint, if it exists. The outcome is based on what the PlayerResponse is
  71.      * regarding your mod and waypoint suggestions.
  72.      *
  73.      * @param modId      Mod id
  74.      * @param waypointId A unique id (within your mod) for the waypoint.
  75.      * @see #checkPlayerWaypointOptIn(String)
  76.      */
  77.     public void removeWaypoint(String modId, String waypointId);
  78.  
  79.     /**
  80.      * Check whether the player has a waypoint with the given waypointId associated with your mod.
  81.      * If the PlayerResponse regarding waypoints from your mod is Block, this will always return false.
  82.      *
  83.      * @param modId      Mod id
  84.      * @param waypointId A unique id (within your mod) for the waypoint.
  85.      * @return true if a waypoint with the id exists.
  86.      */
  87.     public boolean getWaypointExists(String modId, String waypointId);
  88.  
  89.     /**
  90.      * Gets a list of player waypoint ids associated with your mod.
  91.      * If the PlayerResponse regarding waypoints from your mod is Block, an empty list will be returned.
  92.      *
  93.      * @param modId Mod id
  94.      * @return A list, possibly empty.
  95.      */
  96.     public List<String> getWaypointIds(String modId);
  97.  
  98.     /**
  99.      * Attempt to show a marker on one or more map views.  The outcome is based on
  100.      * what the PlayerResponse is regarding your mod and map overlays.
  101.      * <p/>
  102.      * If a marker with the provided featureId already exists, the new one will replace the old one.
  103.      *
  104.      * @param modId            Mod id
  105.      * @param specification    Specification for the map marker.
  106.      * @see #checkPlayerMapOverlayOptIn(String)
  107.      */
  108.     public void addMarker(String modId, MarkerSpec specification);
  109.  
  110.     /**
  111.      * Gets a list of map marker ids associated with your mod.
  112.      * If the PlayerResponse regarding map overlays from your mod is Block, an empty list will be returned.
  113.      *
  114.      * @param modId Mod id
  115.      * @return A list, possibly empty.
  116.      */
  117.     public List<String> getMarkerIds(String modId);
  118.  
  119.     /**
  120.      * Remove a map marker, if it exists. The outcome is based on what the PlayerResponse is
  121.      * regarding your mod and map overlays.
  122.      *
  123.      * @param modId    Mod id
  124.      * @param markerId A unique id (within your mod) for the map marker.
  125.      */
  126.     public void removeMarker(String modId, String markerId);
  127.  
  128.     /**
  129.      * Check whether the player has a map marker with the given markerId associated with your mod.
  130.      * If the PlayerResponse regarding map overlays from your mod is Block, this will always return false.
  131.      *
  132.      * @param modId    Mod id
  133.      * @param markerId A unique id (within your mod) for the map marker.
  134.      * @return true if a waypoint with the id exists.
  135.      */
  136.     public boolean getMarkerExists(String modId, String markerId);
  137.  
  138.     /**
  139.      * Attempt to show a polygon on one or more map views.  The outcome is based on
  140.      * what the PlayerResponse is regarding your mod and map overlays.
  141.      * <p/>
  142.      * If a polygon with the provided featureId already exists, the new one will replace the old one.
  143.      *
  144.      * @param modId            Mod id
  145.      * @param specification    Specification of the polygon to display
  146.      * @see #checkPlayerMapOverlayOptIn(String)
  147.      */
  148.     public void showPolygon(String modId, PolygonSpec specification);
  149.  
  150.     /**
  151.      * Gets a list of polygon ids associated with your mod.  If the PlayerResponse regarding map overlays from your
  152.      * mod is Block, an empty list will be returned.
  153.      *
  154.      * @param modId Mod id
  155.      * @return A list, possibly empty.
  156.      */
  157.     public List<String> getPolygonIds(String modId);
  158.  
  159.     /**
  160.      * Remove a polygon, if it exists. The outcome is based on what the PlayerResponse is
  161.      * regarding your mod and map overlays.
  162.      *
  163.      * @param modId     Mod id
  164.      * @param polygonId A unique id (within your mod) for the polygon.
  165.      */
  166.     public void removePolygon(String modId, String polygonId);
  167.  
  168.     /**
  169.      * Check whether the player has a polygon with the given markerId associated with your mod.
  170.      * If the PlayerResponse regarding map overlays from your mod is Block, this will always return false.
  171.      *
  172.      * @param modId     Mod id
  173.      * @param polygonId A unique id (within your mod) for the polygon.
  174.      * @return true if a polygon with the id exists.
  175.      */
  176.     public boolean getPolygonExists(String modId, String polygonId);
  177. }
  178.  
  179. ////////////////////////////////////////////////////////////////////
  180.  
  181. /**
  182.  * A MapPoint is a triple of world coordinates.
  183.  */
  184. public class MapPoint
  185. {
  186.     public int x;
  187.     public int y;
  188.     public int z;
  189. }
  190.  
  191. ////////////////////////////////////////////////////////////////////
  192.  
  193. /**
  194.  * A MapPolygon is a sequence of at least 4 points, the first and last being equal.
  195.  */
  196. public class MapPolygon extends ArrayList<MapPoint>
  197. {
  198. }
  199.  
  200. ////////////////////////////////////////////////////////////////////
  201.  
  202. /**
  203.  * Options defining how a map Marker should be displayed.
  204.  */
  205. public class MarkerSpec
  206. {
  207.     /**
  208.      * A unique id for the marker which can be used to remove/update it.
  209.      */
  210.     public String markerId;
  211.  
  212.     /**
  213.      * A suggested group or category name used to organize map overlays.
  214.      */
  215.     public String overlayGroupName;
  216.  
  217.     /**
  218.      * Location of the marker.
  219.      */
  220.     public MapPoint point;
  221.  
  222.     /**
  223.      * Rollover text to be displayed when the mouse is over the polygon.
  224.      */
  225.     public String title;
  226.  
  227.     /**
  228.      * Label text to be displayed in the center of the polygon.
  229.      */
  230.     public String label;
  231.  
  232.     /**
  233.      * Font color (rgb) of the label and title.
  234.      */
  235.     public int color;
  236.  
  237.     /**
  238.      * Resource location of an icon to display
  239.      */
  240.     public String iconResourceLocation;
  241.  
  242.     /**
  243.      * X offset for icon (necessary for sprite sheets).
  244.      * Leave as 0 for default.
  245.      */
  246.     public int iconOriginX;
  247.  
  248.     /**
  249.      * Y offset for icon (necessary for sprite sheets).
  250.      * Leave as 0 for default.
  251.      */
  252.     public int iconOriginY;
  253.  
  254.     /**
  255.      * Icon width in pixels from iconOriginX.
  256.      */
  257.     public int iconWidth;
  258.  
  259.     /**
  260.      * Icon height in pixels from iconOriginY.
  261.      */
  262.     public int iconHeight;
  263.  
  264.     /**
  265.      * Number of pixels to offset the icon laterally from the point on the map.
  266.      */
  267.     public int iconAnchorX;
  268.  
  269.     /**
  270.      * Number of pixels to offset the icon vertically from the point on the map.
  271.      */
  272.     public int iconAnchorY;
  273.  
  274.     /**
  275.      * If true, a click event (from fullscreen map or web map) will be generated via the API.
  276.      */
  277.     public boolean clickable;
  278.  
  279.     /**
  280.      * The minimum zoom level (0 is lowest) where the polygon should be visible.
  281.      */
  282.     public int minZoom = 0;
  283.  
  284.     /**
  285.      * The maximum zoom level (8 is highest) where the polygon should be visible.
  286.      */
  287.     public int maxZoom = 8;
  288.  
  289.     /**
  290.      * All features are displayed on the map in order of their zIndex, with higher values
  291.      * displaying in front of features with lower values. Default is 1000.
  292.      */
  293.     public int zIndex = 1000;
  294.  
  295.     /**
  296.      * Whether the polygon should be displayed in the Minimap.
  297.      */
  298.     public boolean inMinimap = true;
  299.  
  300.     /**
  301.      * Whether the polygon should be displayed in the Fullscreen map.
  302.      */
  303.     public boolean inFullscreen = true;
  304.  
  305.     /**
  306.      * Whether the polygon should be displayed in the Web map (when enabled).
  307.      */
  308.     public boolean inWebmap = true;
  309. }
  310.  
  311. ////////////////////////////////////////////////////////////////////
  312.  
  313. /**
  314.  * Describes the player's response to the attempt by your mod to
  315.  * display waypoints or map features.
  316.  */
  317. public enum PlayerResponse
  318. {
  319.     /**
  320.      * Player hasn't decided how to respond.
  321.      */
  322.     Unknown,
  323.  
  324.     /**
  325.      * Player will be prompted to accept/reject each item.
  326.      */
  327.     Prompt,
  328.  
  329.     /**
  330.      * Player will automatically accept or display each item.
  331.      */
  332.     Allow,
  333.  
  334.     /**
  335.      * Player will recieve item but has elected to hide them.
  336.      */
  337.     Hide,
  338.  
  339.     /**
  340.      * Player will not receive the item at all.
  341.      */
  342.     Block;
  343. }
  344.  
  345. ////////////////////////////////////////////////////////////////////
  346.  
  347. /**
  348.  * Specification defining how a polygon map overlay should be displayed.
  349.  */
  350. public class PolygonSpec
  351. {
  352.     /**
  353.      * A unique id for the polygon which can be used to remove/update it.
  354.      */
  355.     String polygonId;
  356.  
  357.     /**
  358.      * A suggested group or category name used to organize map overlays.
  359.      */
  360.     String overlayGroupName;
  361.  
  362.     /**
  363.      * Rollover text to be displayed when the mouse is over the polygon.
  364.      */
  365.     public String title;
  366.  
  367.     /**
  368.      * Label text to be displayed in the center of the polygon.
  369.      */
  370.     public String label;
  371.  
  372.     /**
  373.      * A polygon of the outer area to be displayed.
  374.      */
  375.     MapPolygon outerArea;
  376.  
  377.     /**
  378.      * (optional) A list of polygons treated as holes inside the outerArea
  379.      */
  380.     List<MapPolygon> holes;
  381.  
  382.     /**
  383.      * If true, a click event (from fullscreen map or web map) will be generated via the API.
  384.      */
  385.     public boolean clickable;
  386.  
  387.     /**
  388.      * Line thickness of the polygon edges.
  389.      */
  390.     public float strokeWidth;
  391.  
  392.     /**
  393.      * Line color (rgb) of the polygon edges.
  394.      */
  395.     public int strokeColor;
  396.  
  397.     /**
  398.      * Line opacity (between 0 and 1) of the polygon edges.
  399.      */
  400.     public float strokeOpacity;
  401.  
  402.     /**
  403.      * Fill color (rgb) of the polygon.
  404.      */
  405.     public int fillColor;
  406.  
  407.     /**
  408.      * Fill opacity of the polygon.
  409.      */
  410.     public int fillOpacity;
  411.  
  412.     /**
  413.      * The minimum zoom level (0 is lowest) where the polygon should be visible.
  414.      */
  415.     public int minZoom = 0;
  416.  
  417.     /**
  418.      * The maximum zoom level (8 is highest) where the polygon should be visible.
  419.      */
  420.     public int maxZoom = 8;
  421.  
  422.     /**
  423.      * All features are displayed on the map in order of their zIndex, with higher values
  424.      * displaying in front of features with lower values. Default is 1000.
  425.      */
  426.     public int zIndex = 1000;
  427.  
  428.     /**
  429.      * Whether the polygon should be displayed in the Minimap.
  430.      */
  431.     public boolean inMinimap = true;
  432.  
  433.     /**
  434.      * Whether the polygon should be displayed in the Fullscreen map.
  435.      */
  436.     public boolean inFullscreen = true;
  437.  
  438.     /**
  439.      * Whether the polygon should be displayed in the Web map (when enabled).
  440.      */
  441.     public boolean inWebmap = true;
  442. }
  443.  
  444. ////////////////////////////////////////////////////////////////////
  445.  
  446. /**
  447.  * Specification defining how a waypoint will be suggested to a user.
  448.  */
  449. public class WaypointSpec
  450. {
  451.     /**
  452.      * Unique id (scoped to your mod)
  453.      */
  454.     String waypointId;
  455.  
  456.     /**
  457.      * (Optional) Group or category name for the waypoint.
  458.      */
  459.     String waypointGroupName;
  460.  
  461.     /**
  462.      * Waypoint name.
  463.      */
  464.     String waypointName;
  465.  
  466.     /**
  467.      * Waypoint location.
  468.      */
  469.     MapPoint point;
  470.  
  471.     /**
  472.      * Dimensions where waypoint should be displayed.
  473.      */
  474.     int[] dimensions;
  475.  
  476.     /**
  477.      * Color of the waypoint.
  478.      */
  479.     public int color;
  480.  
  481.     /**
  482.      * Resource location of an icon to display
  483.      */
  484.     public String iconResourceLocation;
  485.  
  486.     /**
  487.      * X offset for icon (necessary for sprite sheets).
  488.      * Leave as 0 for default.
  489.      */
  490.     public int iconOriginX;
  491.  
  492.     /**
  493.      * Y offset for icon (necessary for sprite sheets).
  494.      * Leave as 0 for default.
  495.      */
  496.     public int iconOriginY;
  497.  
  498.     /**
  499.      * Icon width in pixels from iconOriginX.
  500.      */
  501.     public int iconWidth;
  502.  
  503.     /**
  504.      * Icon height in pixels from iconOriginY.
  505.      */
  506.     public int iconHeight;
  507. }
Advertisement
Add Comment
Please, Sign In to add comment