Added render distance info to README
This commit is contained in:
parent
293c239fb8
commit
8206cb403b
2 changed files with 82 additions and 0 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ComposerSettings">
|
<component name="ComposerSettings">
|
||||||
<execution />
|
<execution />
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
<option value="$PROJECT_DIR$/NMS-v1_19_R1/pom.xml" />
|
<option value="$PROJECT_DIR$/NMS-v1_19_R1/pom.xml" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
|
80
README.md
80
README.md
|
@ -4,6 +4,8 @@ This plugin helps developer with displaying images on maps. It supports Spigot 1
|
||||||
|
|
||||||
## Usage:
|
## Usage:
|
||||||
|
|
||||||
|
### Using the API:
|
||||||
|
|
||||||
First, include the API using Maven:
|
First, include the API using Maven:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
@ -80,6 +82,84 @@ controller.showInFrames(p, frames, true);
|
||||||
|
|
||||||
More information can be found on the [JavaDoc](https://sbdevelopment.tech/javadoc/mapreflectionapi/).
|
More information can be found on the [JavaDoc](https://sbdevelopment.tech/javadoc/mapreflectionapi/).
|
||||||
|
|
||||||
|
### Notes on map render distance:
|
||||||
|
|
||||||
|
MapReflectionAPI does not implement render distance to images shown on maps. This should be implemented by yourself. An example of this is below.
|
||||||
|
|
||||||
|
```java
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
public class MapRenderDistanceListener implements Listener {
|
||||||
|
private static final int MAP_RENDER_DISTANCE_SQUARED = 1024;
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(MyPluginInstance, () -> {
|
||||||
|
//Show the maps to the player which are within distance
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent e) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(MyPluginInstance, () -> {
|
||||||
|
//Hide the maps to the player which are within distance
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChangeWorld(PlayerChangedWorldEvent e) {
|
||||||
|
//Hide all the maps in the e.getFrom() world
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(MyPluginInstance, () -> {
|
||||||
|
//Show the maps to the player which are within distance in e.getPlayer().getWorld()
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
|
//Hide all the maps in the e.getEntity().getWorld()
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(MyPluginInstance, () -> {
|
||||||
|
//Show the maps to the player which are within distance in e.getPlayer().getWorld()
|
||||||
|
}, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
|
//Hide all the maps in the e.getFrom() world
|
||||||
|
//Show the maps to the player which are within distance in e.getTo().getWorld()
|
||||||
|
|
||||||
|
//FOR EXAMPLE:
|
||||||
|
if (e.getTo() == null) return;
|
||||||
|
if (e.getFrom().getChunk().equals(e.getTo().getChunk())) return;
|
||||||
|
|
||||||
|
for (Frame frame : API.getFramesInWorld(e.getPlayer().getWorld())) {
|
||||||
|
double distanceSquared = e.getTo().distanceSquared(frame.getLocation());
|
||||||
|
|
||||||
|
if (distanceSquared > MAP_RENDER_DISTANCE_SQUARED) {
|
||||||
|
API.hideFrame(e.getPlayer(), frame);
|
||||||
|
} else {
|
||||||
|
API.showFrame(e.getPlayer(), frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent e) {
|
||||||
|
//Hide all the maps in the e.getFrom() world
|
||||||
|
//Show the maps to the player which are within distance in e.getTo().getWorld()
|
||||||
|
|
||||||
|
//SEE EXAMPLE ABOVE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Credits:
|
## Credits:
|
||||||
|
|
||||||
This is a fork of [MapManager](https://github.com/InventivetalentDev/MapManager). It updates the API to 1.19 and uses
|
This is a fork of [MapManager](https://github.com/InventivetalentDev/MapManager). It updates the API to 1.19 and uses
|
||||||
|
|
Loading…
Add table
Reference in a new issue