initial commit
This commit is contained in:
22
src/main/java/de/slpnetwork/ManyWaypoints.java
Normal file
22
src/main/java/de/slpnetwork/ManyWaypoints.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package de.slpnetwork;
|
||||
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||
import com.hypixel.hytale.server.core.universe.world.map.WorldMap;
|
||||
import de.slpnetwork.commands.WayPointCommand;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ManyWaypoints extends JavaPlugin {
|
||||
|
||||
public ManyWaypoints(@Nonnull JavaPluginInit init) {
|
||||
super(init);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
this.getCommandRegistry().registerCommand(new WayPointCommand("waypoint", "used to add or remove waypoints from the map"));
|
||||
}
|
||||
}
|
||||
81
src/main/java/de/slpnetwork/commands/WayPointCommand.java
Normal file
81
src/main/java/de/slpnetwork/commands/WayPointCommand.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package de.slpnetwork.commands;
|
||||
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.math.vector.Vector3d;
|
||||
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.command.system.CommandContext;
|
||||
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.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.utils.StringArgument;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static de.slpnetwork.utils.MessageUtil.SendMessage;
|
||||
|
||||
public class WayPointCommand extends AbstractPlayerCommand {
|
||||
|
||||
private final RequiredArg<String> actionArg;
|
||||
private final RequiredArg<String> markerNameArg;
|
||||
|
||||
public WayPointCommand(String name, String description) {
|
||||
super(name, description);
|
||||
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 "));
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
String markerName = commandContext.get(markerNameArg);
|
||||
String action = commandContext.get(actionArg);
|
||||
|
||||
switch (action) {
|
||||
case "add":
|
||||
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;
|
||||
default:
|
||||
SendMessage(player, "please used /waypoint <add | remove> <markername> ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/main/java/de/slpnetwork/utils/MessageUtil.java
Normal file
15
src/main/java/de/slpnetwork/utils/MessageUtil.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package de.slpnetwork.utils;
|
||||
|
||||
import com.hypixel.hytale.protocol.FormattedMessage;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
|
||||
public class MessageUtil {
|
||||
public static void SendMessage(Player player, String message) {
|
||||
FormattedMessage fm = new FormattedMessage();
|
||||
fm.rawText = message;
|
||||
|
||||
Message messageObj = new Message(fm);
|
||||
player.sendMessage(messageObj);
|
||||
}
|
||||
}
|
||||
23
src/main/java/de/slpnetwork/utils/StringArgument.java
Normal file
23
src/main/java/de/slpnetwork/utils/StringArgument.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package de.slpnetwork.utils;
|
||||
|
||||
import com.hypixel.hytale.protocol.GameMode;
|
||||
import com.hypixel.hytale.server.core.command.system.ParseResult;
|
||||
import com.hypixel.hytale.server.core.command.system.arguments.types.SingleArgumentType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class StringArgument extends SingleArgumentType<String> {
|
||||
public StringArgument(String name, @Nonnull String argumentUsage, @Nullable String... examples) {
|
||||
super(name, argumentUsage, examples);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String parse(String s, ParseResult parseResult) {
|
||||
if (s.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 469 B |
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"markerTypes": {
|
||||
"waypoint": {
|
||||
"image": "manywaypoints:ui/map/wp_icon.png",
|
||||
"scale": 1.2
|
||||
}
|
||||
}
|
||||
}
|
||||
20
src/main/resources/manifest.json
Normal file
20
src/main/resources/manifest.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"Group": "de.slpnetwork",
|
||||
"Name": "ManyWaypoints",
|
||||
"Version": "1.0.0",
|
||||
"Description": "Description of your plugin",
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "Steev",
|
||||
"Email": "your.email@example.com",
|
||||
"Url": "https://your-website.com"
|
||||
}
|
||||
],
|
||||
"Website": "https://your-plugin-website.com",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {},
|
||||
"OptionalDependencies": {},
|
||||
"DisabledByDefault": false,
|
||||
"IncludesAssetPack": false,
|
||||
"Main": "de.slpnetwork.ManyWaypoints"
|
||||
}
|
||||
Reference in New Issue
Block a user