-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d010b6
commit 7ab4e73
Showing
11 changed files
with
257 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
api/src/main/java/de/pianoman911/mapengine/api/clientside/IHoldableDisplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package de.pianoman911.mapengine.api.clientside; | ||
|
||
import de.pianoman911.mapengine.api.pipeline.IPipeline; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public interface IHoldableDisplay { | ||
|
||
ItemStack itemStack(int z); | ||
|
||
IPipeline pipeline(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
plugin/src/main/java/de/pianoman911/mapengine/core/clientside/FilledMap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.pianoman911.mapengine.core.clientside; | ||
|
||
import de.pianoman911.mapengine.common.data.MapUpdateData; | ||
import de.pianoman911.mapengine.common.platform.PacketContainer; | ||
import de.pianoman911.mapengine.core.MapEnginePlugin; | ||
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap; | ||
import it.unimi.dsi.fastutil.ints.Int2IntMap; | ||
import org.bukkit.map.MapCursorCollection; | ||
|
||
public class FilledMap { | ||
|
||
// start counting down at -32768 for compatibility with other map plugins | ||
protected static int CURRENT_ID = -Short.MAX_VALUE; | ||
|
||
protected final Int2IntMap mapIds = new Int2IntArrayMap(); | ||
protected final MapEnginePlugin plugin; | ||
|
||
public FilledMap(MapEnginePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
protected PacketContainer<?> updatePacket(MapUpdateData data, boolean fullData, int z, MapCursorCollection cursors) { | ||
return plugin.platform().createMapDataPacket(data, fullData, mapId(z), cursors); | ||
} | ||
|
||
protected int mapId(int z) { | ||
return mapIds.computeIfAbsent(z, $ -> CURRENT_ID--); | ||
} | ||
} |
22 changes: 4 additions & 18 deletions
22
plugin/src/main/java/de/pianoman911/mapengine/core/clientside/Frame.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
plugin/src/main/java/de/pianoman911/mapengine/core/clientside/MapItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.pianoman911.mapengine.core.clientside; | ||
|
||
import de.pianoman911.mapengine.api.clientside.IHoldableDisplay; | ||
import de.pianoman911.mapengine.core.MapEnginePlugin; | ||
import de.pianoman911.mapengine.core.pipeline.Pipeline; | ||
import de.pianoman911.mapengine.core.util.DummyMapView; | ||
import org.bukkit.Material; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.MapMeta; | ||
|
||
public class MapItem extends FilledMap implements IHoldableDisplay { | ||
|
||
private final Pipeline pipeline; | ||
|
||
public MapItem(MapEnginePlugin plugin, Pipeline pipeline) { | ||
super(plugin); | ||
this.pipeline = pipeline; | ||
} | ||
|
||
@Override | ||
public ItemStack itemStack(int z) { | ||
ItemStack item = new ItemStack(Material.FILLED_MAP); | ||
item.editMeta(MapMeta.class, meta -> meta.setMapView(new DummyMapView(mapId(z)))); | ||
return item; | ||
} | ||
|
||
@Override | ||
public Pipeline pipeline() { | ||
return pipeline; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
plugin/src/main/java/de/pianoman911/mapengine/core/map/HoldableManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package de.pianoman911.mapengine.core.map; | ||
|
||
import de.pianoman911.mapengine.api.clientside.IHoldableDisplay; | ||
import de.pianoman911.mapengine.core.MapEnginePlugin; | ||
import de.pianoman911.mapengine.core.clientside.MapItem; | ||
import de.pianoman911.mapengine.core.pipeline.Pipeline; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class HoldableManager { | ||
|
||
private final Set<IHoldableDisplay> displays = new HashSet<>(); | ||
|
||
private final MapEnginePlugin plugin; | ||
|
||
public HoldableManager(MapEnginePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public IHoldableDisplay createDisplay(Pipeline pipeline) { | ||
MapItem item = new MapItem(plugin, pipeline); | ||
displays.add(item); | ||
return item; | ||
} | ||
|
||
public IHoldableDisplay createDisplay() { | ||
MapItem item = new MapItem(plugin, new Pipeline(plugin)); | ||
displays.add(item); | ||
return item; | ||
} | ||
|
||
public Set<IHoldableDisplay> displays() { | ||
return displays; | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
plugin/src/main/java/de/pianoman911/mapengine/core/util/DummyMapView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package de.pianoman911.mapengine.core.util; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.map.MapRenderer; | ||
import org.bukkit.map.MapView; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public record DummyMapView(int id) implements MapView { | ||
|
||
@Override | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public boolean isVirtual() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull | ||
Scale getScale() { | ||
return Scale.NORMAL; | ||
} | ||
|
||
@Override | ||
public void setScale(@NotNull Scale scale) { | ||
|
||
} | ||
|
||
@Override | ||
public int getCenterX() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getCenterZ() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void setCenterX(int x) { | ||
|
||
} | ||
|
||
@Override | ||
public void setCenterZ(int z) { | ||
|
||
} | ||
|
||
@Override | ||
public @Nullable | ||
World getWorld() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void setWorld(@NotNull World world) { | ||
|
||
} | ||
|
||
@Override | ||
public @NotNull | ||
List<MapRenderer> getRenderers() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public void addRenderer(@NotNull MapRenderer renderer) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean removeRenderer(@Nullable MapRenderer renderer) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isTrackingPosition() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setTrackingPosition(boolean trackingPosition) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isUnlimitedTracking() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void setUnlimitedTracking(boolean unlimited) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isLocked() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void setLocked(boolean locked) { | ||
|
||
} | ||
} |