feat theoretically added adding waypoints to player map (untested)

This commit is contained in:
2026-01-19 00:55:05 +01:00
parent 09cc058aa0
commit b7e8ccf8d2
7 changed files with 92 additions and 19 deletions

View File

@@ -18,7 +18,7 @@ repositories {
dependencies {
// Add Hytale Server as compileOnly dependency (not bundled in final JAR)
compileOnly(files("Hytaleserver.jar"))
}
compileOnly("org.xerial:sqlite-jdbc:3.45.1.0")}
tasks.jar {
// Set the archive name

BIN
sqlite-jdbc.jar Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
package de.slpnetwork.commands;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.component.Ref;
import com.hypixel.hytale.component.Store;
import com.hypixel.hytale.math.vector.Vector3d;
@@ -12,12 +13,14 @@ import com.hypixel.hytale.server.core.command.system.ParseResult;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgumentType;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.PlayerRef;
import com.hypixel.hytale.server.core.universe.world.World;
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import de.slpnetwork.managers.WaypointManager;
import de.slpnetwork.utils.StringArgument;
import javax.annotation.Nonnull;
@@ -32,9 +35,12 @@ public class WayPointCommand extends AbstractPlayerCommand {
private final RequiredArg<String> actionArg;
private final RequiredArg<String> markerNameArg;
private WaypointManager plugin;
public WayPointCommand(String name, String description) {
public WayPointCommand(WaypointManager plugin, String name, String description) {
super(name, description);
this.plugin = plugin;
actionArg = withRequiredArg("action", "should the server add or remove a waypoint", new StringArgument("action", "add | remove", "defines the command action"));
markerNameArg = withRequiredArg("action", "should the server add or remove a waypoint", new StringArgument("markerName", "yourMarker", "name of the map marker in one word "));
}
@@ -42,10 +48,10 @@ public class WayPointCommand extends AbstractPlayerCommand {
@Override
protected void execute(@Nonnull CommandContext commandContext, @Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> ref, @Nonnull PlayerRef playerRef, @Nonnull World world) {
// Get Player
Player player = store.getComponent(ref, Player.getComponentType());
WorldMapManager wm = player.getWorld().getWorldMapManager();
Map<String, MapMarker> pois = wm.getPointsOfInterest();
PlayerWorldData perWorldData = player.getPlayerConfigData().getPerWorldData(world.getName());
MapMarker[] worldMapMarkers = perWorldData.getWorldMapMarkers();
String markerName = commandContext.get(markerNameArg);
String action = commandContext.get(actionArg);
@@ -55,24 +61,15 @@ public class WayPointCommand extends AbstractPlayerCommand {
TransformComponent transformComponent = (TransformComponent)store.getComponent(ref, TransformComponent.getComponentType());
assert transformComponent != null;
Transform markerTransform = new Transform();
markerTransform.position = new Position(transformComponent.getPosition().getX(),transformComponent.getPosition().getY(),transformComponent.getPosition().getZ());
markerTransform.orientation = new Direction();
MapMarker marker = new MapMarker();
marker.id = UUID.randomUUID().toString();
marker.name = markerName;
marker.transform = markerTransform;
marker.markerImage = "manywaypoints:ui/map/wp_icon.png";
pois.putIfAbsent(markerName, marker);
SendMessage(player, "created marker: '" + markerName + "' on the map");
break;
case "remove":
pois.remove(markerName);
SendMessage(player, "removed marker: '" + markerName + "' from the map");
break;
case "toggle":
// TODO: this needs storage to function therefor nothing can be done here yet
break;
default:
SendMessage(player, "please used /waypoint <add | remove> <markername> ");
break;

View File

@@ -0,0 +1,6 @@
package de.slpnetwork.drivers;
public class SQLiteDriver {
// TODO: implement SQLite here
}

View File

@@ -0,0 +1,70 @@
package de.slpnetwork.managers;
import com.hypixel.hytale.common.util.ArrayUtil;
import com.hypixel.hytale.protocol.Direction;
import com.hypixel.hytale.protocol.Position;
import com.hypixel.hytale.protocol.Transform;
import com.hypixel.hytale.protocol.packets.worldmap.MapMarker;
import com.hypixel.hytale.server.core.entity.entities.Player;
import com.hypixel.hytale.server.core.entity.entities.player.data.PlayerWorldData;
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
import com.hypixel.hytale.server.core.universe.world.worldmap.WorldMapManager;
import de.slpnetwork.ManyWaypoints;
import java.util.Map;
import java.util.UUID;
public class WaypointManager {
private ManyWaypoints plugin;
public WaypointManager (ManyWaypoints plugin) {
this.plugin = plugin;
}
/**
* handles adding a waypoint to the players map and storage
* @param player the player reference of the waypoint owner
* @param transformComponent the players position as transform
* @param markerName the name of the waypoint
*/
public void AddWaypoint(Player player, TransformComponent transformComponent, String markerName, PlayerWorldData perWorldData, MapMarker[] worldMapMarkers) {
WorldMapManager wm = player.getWorld().getWorldMapManager();
Map<String, MapMarker> pois = wm.getPointsOfInterest();
Transform markerTransform = new Transform();
markerTransform.position = new Position(transformComponent.getPosition().getX(),transformComponent.getPosition().getY(),transformComponent.getPosition().getZ());
markerTransform.orientation = new Direction();
MapMarker marker = new MapMarker();
marker.id = UUID.randomUUID().toString();
marker.name = markerName;
marker.transform = markerTransform;
marker.markerImage = "manywaypoints:ui/map/wp_icon";
perWorldData.setWorldMapMarkers((MapMarker[]) ArrayUtil.append(worldMapMarkers, marker));
// pois.putIfAbsent(markerName, marker); this might not be required
}
/**
* handles removing a waypoint from the players map and storage
* @param player the player reference of the waypoint owner
* @param transformComponent the players position as transform
* @param markerName the name of the waypoint
*/
public void RemoveWaypoint(Player player,TransformComponent transformComponent, String markerName, PlayerWorldData perWorldData, MapMarker[] worldMapMarkers) {
WorldMapManager wm = player.getWorld().getWorldMapManager();
Map<String, MapMarker> pois = wm.getPointsOfInterest();
// TODO: implement removing waypoints code reference WorldMap.class:383 this function seems to remove MapMarkers from the Map
pois.remove(markerName);
}
/**
* looks up a waypoint for a player in storage if and shows or hides it if found
* @param player the player reference of the waypoint owner
* @param name the name of the waypoint
*/
public void ToggleWaypoint(Player player, String name) {}
}

View File

@@ -1,7 +1,7 @@
{
"markerTypes": {
"waypoint": {
"image": "manywaypoints:ui/map/wp_icon.png",
"image": "manywaypoints:ui/map/wp_icon",
"scale": 1.2
}
}

View File

@@ -15,6 +15,6 @@
"Dependencies": {},
"OptionalDependencies": {},
"DisabledByDefault": false,
"IncludesAssetPack": false,
"IncludesAssetPack": true,
"Main": "de.slpnetwork.ManyWaypoints"
}