Add own mod
This commit is contained in:
48
src/main/java/com/tikaiz/AddDefaultComponentTickSystem.java
Normal file
48
src/main/java/com/tikaiz/AddDefaultComponentTickSystem.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.*;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AddDefaultComponentTickSystem extends EntityTickingSystem<EntityStore> {
|
||||
private final ComponentType<EntityStore, CustomComponent> customComponentType;
|
||||
|
||||
public AddDefaultComponentTickSystem(ComponentType<EntityStore, CustomComponent> poisonComponentType) {
|
||||
this.customComponentType = poisonComponentType;
|
||||
}
|
||||
@Override
|
||||
public void tick(float dt,
|
||||
int i,
|
||||
@NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
|
||||
@NonNullDecl Store<EntityStore> store,
|
||||
@NonNullDecl CommandBuffer<EntityStore> commandBuffer) {
|
||||
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(i);
|
||||
CustomComponent component = store.getComponent(ref, customComponentType);
|
||||
if (component != null) {
|
||||
return;
|
||||
}
|
||||
DisplayNameComponent displayNameComponent = store.getComponent(ref, DisplayNameComponent.getComponentType());
|
||||
if (displayNameComponent == null || displayNameComponent.getDisplayName() == null) {
|
||||
// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Added Component to ref!");
|
||||
return;
|
||||
}
|
||||
var displayName = displayNameComponent.getDisplayName().getAnsiMessage();
|
||||
if (!"Bunny".equals(displayName)){
|
||||
return;
|
||||
}
|
||||
commandBuffer.addComponent(ref, customComponentType, new CustomComponent());
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Added Component to ref: " + displayName);
|
||||
}
|
||||
|
||||
@NullableDecl
|
||||
@Override
|
||||
public Query<EntityStore> getQuery() {
|
||||
return Query.any();
|
||||
}
|
||||
}
|
||||
14
src/main/java/com/tikaiz/CustomComponent.java
Normal file
14
src/main/java/com/tikaiz/CustomComponent.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.Component;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CustomComponent implements Component<EntityStore> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Component<EntityStore> clone() {
|
||||
return new CustomComponent();
|
||||
}
|
||||
}
|
||||
46
src/main/java/com/tikaiz/CustomComponentTickSystem.java
Normal file
46
src/main/java/com/tikaiz/CustomComponentTickSystem.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.*;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.component.system.tick.EntityTickingSystem;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CustomComponentTickSystem extends EntityTickingSystem<EntityStore> {
|
||||
private final ComponentType<EntityStore, CustomComponent> customComponentType;
|
||||
|
||||
public CustomComponentTickSystem(ComponentType<EntityStore, CustomComponent> poisonComponentType) {
|
||||
this.customComponentType = poisonComponentType;
|
||||
}
|
||||
@Override
|
||||
public void tick(float dt,
|
||||
int i,
|
||||
@NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
|
||||
@NonNullDecl Store<EntityStore> store,
|
||||
@NonNullDecl CommandBuffer<EntityStore> commandBuffer) {
|
||||
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(i);
|
||||
CustomComponent component = store.getComponent(ref, customComponentType);
|
||||
if (component == null) {
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("This should never happen! ");
|
||||
return;
|
||||
}
|
||||
DisplayNameComponent displayNameComponent = store.getComponent(ref, DisplayNameComponent.getComponentType());
|
||||
if (displayNameComponent == null || displayNameComponent.getDisplayName() == null) {
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("new Event Ticking system called on : " + ref);
|
||||
return;
|
||||
}
|
||||
var displayName = displayNameComponent.getDisplayName().getAnsiMessage();
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("new Event Ticking system called on : " + displayName);
|
||||
|
||||
}
|
||||
|
||||
@NullableDecl
|
||||
@Override
|
||||
public Query<EntityStore> getQuery() {
|
||||
return Query.and(customComponentType);
|
||||
}
|
||||
}
|
||||
73
src/main/java/com/tikaiz/DamageEventSystem.java
Normal file
73
src/main/java/com/tikaiz/DamageEventSystem.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.ArchetypeChunk;
|
||||
import com.hypixel.hytale.component.CommandBuffer;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.component.system.EntityEventSystem;
|
||||
import com.hypixel.hytale.math.vector.Vector3d;
|
||||
import com.hypixel.hytale.math.vector.Vector3f;
|
||||
import com.hypixel.hytale.server.core.entity.UUIDComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
|
||||
import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import com.hypixel.hytale.server.core.util.NotificationUtil;
|
||||
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DamageEventSystem extends EntityEventSystem<EntityStore, Damage> {
|
||||
protected DamageEventSystem() {
|
||||
super(Damage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(int i,
|
||||
@NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
|
||||
@NonNullDecl Store<EntityStore> store,
|
||||
@NonNullDecl CommandBuffer<EntityStore> commandBuffer,
|
||||
@NonNullDecl Damage damage) {
|
||||
Ref<EntityStore> ref = archetypeChunk.getReferenceTo(i);
|
||||
TransformComponent component = store.getComponent(ref, TransformComponent.getComponentType());
|
||||
if (component == null) {
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("Transform was Null");
|
||||
return;
|
||||
}
|
||||
var displayNameComponent = store.getComponent(ref, DisplayNameComponent.getComponentType());
|
||||
if (displayNameComponent == null) {
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("Display name was Null");
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationUtil.sendNotificationToUniverse(displayNameComponent.getDisplayName());
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Display name: " + displayNameComponent.getDisplayName());
|
||||
|
||||
var uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType());
|
||||
if (uuidComponent == null) {
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("UUID was Null");
|
||||
return;
|
||||
}
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("UUID: " + uuidComponent.getUuid());
|
||||
var transform = component.getTransform();
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Transform: "+transform);
|
||||
|
||||
Vector3d addPos = new Vector3d((Math.random()*20)-10, 3, (Math.random()*20)-10);
|
||||
|
||||
var newPos = transform.getPosition().add(addPos);
|
||||
|
||||
Teleport teleportForPlayer = Teleport.createForPlayer(newPos, new Vector3f());
|
||||
new Thread(()->{
|
||||
store.addComponent(ref,Teleport.getComponentType(),teleportForPlayer);
|
||||
}).start();
|
||||
}
|
||||
|
||||
@NullableDecl
|
||||
@Override
|
||||
public Query<EntityStore> getQuery() {
|
||||
return Query.any();
|
||||
}
|
||||
}
|
||||
94
src/main/java/com/tikaiz/EntitySpawnEventSystem.java
Normal file
94
src/main/java/com/tikaiz/EntitySpawnEventSystem.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.ArchetypeChunk;
|
||||
import com.hypixel.hytale.component.CommandBuffer;
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.component.system.EntityEventSystem;
|
||||
import com.hypixel.hytale.math.vector.Vector3d;
|
||||
import com.hypixel.hytale.math.vector.Vector3f;
|
||||
import com.hypixel.hytale.server.core.entity.UUIDComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
|
||||
import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import com.hypixel.hytale.server.core.util.NotificationUtil;
|
||||
import com.hypixel.hytale.server.npc.AllNPCsLoadedEvent;
|
||||
import com.hypixel.hytale.server.spawning.LoadedNPCEvent;
|
||||
import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
//public class EntitySpawnEventSystem extends EntityEventSystem<EntityStore, LoadedNPCEvent> {
|
||||
// protected EntitySpawnEventSystem() {
|
||||
// super(LoadedNPCEvent.class);
|
||||
// }
|
||||
//
|
||||
//// @Override
|
||||
//// public void handle(int i,
|
||||
//// @NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
|
||||
//// @NonNullDecl Store<EntityStore> store,
|
||||
//// @NonNullDecl CommandBuffer<EntityStore> commandBuffer,
|
||||
//// @NonNullDecl Damage damage) {
|
||||
//// Ref<EntityStore> ref = archetypeChunk.getReferenceTo(i);
|
||||
//// TransformComponent component = store.getComponent(ref, TransformComponent.getComponentType());
|
||||
//// if (component == null) {
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("Transform was Null");
|
||||
//// return;
|
||||
//// }
|
||||
//// var displayNameComponent = store.getComponent(ref, DisplayNameComponent.getComponentType());
|
||||
//// if (displayNameComponent == null) {
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("Display name was Null");
|
||||
//// return;
|
||||
//// }
|
||||
////
|
||||
//// NotificationUtil.sendNotificationToUniverse(displayNameComponent.getDisplayName());
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Display name: " + displayNameComponent.getDisplayName());
|
||||
////
|
||||
//// var uuidComponent = store.getComponent(ref, UUIDComponent.getComponentType());
|
||||
//// if (uuidComponent == null) {
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.SEVERE).log("UUID was Null");
|
||||
//// return;
|
||||
//// }
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("UUID: " + uuidComponent.getUuid());
|
||||
//// var transform = component.getTransform();
|
||||
//// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Transform: "+transform);
|
||||
////
|
||||
//// Vector3d addPos = new Vector3d((Math.random()*20)-10, 3, (Math.random()*20)-10);
|
||||
////
|
||||
//// var newPos = transform.getPosition().add(addPos);
|
||||
////
|
||||
//// Teleport teleportForPlayer = Teleport.createForPlayer(newPos, new Vector3f());
|
||||
//// new Thread(()->{
|
||||
//// store.addComponent(ref,Teleport.getComponentType(),teleportForPlayer);
|
||||
//// }).start();
|
||||
//// }
|
||||
//
|
||||
// @NullableDecl
|
||||
// @Override
|
||||
// public Query<EntityStore> getQuery() {
|
||||
// return Query.any();
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void handle(int i,
|
||||
// @NonNullDecl ArchetypeChunk<EntityStore> archetypeChunk,
|
||||
// @NonNullDecl Store<EntityStore> store,
|
||||
// @NonNullDecl CommandBuffer<EntityStore> commandBuffer,
|
||||
// @NonNullDecl LoadedNPCEvent loadedNPCEvent) {
|
||||
// Ref<EntityStore> ref = archetypeChunk.getReferenceTo(i);
|
||||
// var transformComponent = store.getComponent(ref, TransformComponent.getComponentType());
|
||||
// NotificationUtil.sendNotificationToUniverse(transformComponent != null ? transformComponent.getTransform().toString() : "null");
|
||||
// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log(transformComponent != null ? transformComponent.getTransform().toString() : "null");
|
||||
// var displayNameComponent = store.getComponent(ref, DisplayNameComponent.getComponentType());
|
||||
// NotificationUtil.sendNotificationToUniverse(displayNameComponent != null ? displayNameComponent.getDisplayName() != null ? displayNameComponent.getDisplayName().getAnsiMessage() : "null" : "null");
|
||||
// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log(displayNameComponent != null ? displayNameComponent.getDisplayName() != null ? displayNameComponent.getDisplayName().getAnsiMessage() : "null" : "null");
|
||||
//
|
||||
//// loadedNPCEvent.getBuilderInfo().getKeyName()
|
||||
//
|
||||
// }
|
||||
//}
|
||||
64
src/main/java/com/tikaiz/HytaleDemo.java
Normal file
64
src/main/java/com/tikaiz/HytaleDemo.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.SystemType;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.component.system.CancellableEcsEvent;
|
||||
import com.hypixel.hytale.component.system.EcsEvent;
|
||||
import com.hypixel.hytale.server.core.event.events.BootEvent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.damage.Damage;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||
import com.hypixel.hytale.server.core.universe.Universe;
|
||||
import com.hypixel.hytale.server.core.universe.world.World;
|
||||
import com.hypixel.hytale.server.core.universe.world.events.AllWorldsLoadedEvent;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import com.hypixel.hytale.server.core.util.NotificationUtil;
|
||||
import com.hypixel.hytale.server.npc.AllNPCsLoadedEvent;
|
||||
import com.hypixel.hytale.server.spawning.LoadedNPCEvent;
|
||||
import com.hypixel.hytale.server.spawning.assets.spawns.config.NPCSpawn;
|
||||
import com.tikaiz.commands.ExampleCommand;
|
||||
import jdk.jfr.EventType;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Queue;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class HytaleDemo extends JavaPlugin {
|
||||
|
||||
public HytaleDemo(@Nonnull JavaPluginInit init) {
|
||||
super(init);
|
||||
LoggerSingleton.getInstance().setHytaleLogger(this.getLogger());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
this.getCommandRegistry().registerCommand(new ExampleCommand());
|
||||
this.getEntityStoreRegistry().registerSystem(new DamageEventSystem());
|
||||
var type = this.getEntityStoreRegistry()
|
||||
.registerComponent(CustomComponent.class, CustomComponent::new);
|
||||
this.getEntityStoreRegistry().registerSystem(new AddDefaultComponentTickSystem(type));
|
||||
this.getEntityStoreRegistry().registerSystem(new CustomComponentTickSystem(type));
|
||||
// var list = new ArrayList<EntityStore>();
|
||||
this.getEventRegistry().registerGlobal(AllWorldsLoadedEvent.class, (x)->{
|
||||
LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("World has loaded!");
|
||||
});
|
||||
// Universe.get().getDefaultWorld().getEntityStore().getStore().fetch(new SystemType<>(), Query.any(),list);
|
||||
// EntityStore.REGISTRY.assertInStoreThread();
|
||||
// this.getEventRegistry().registerGlobal(LoadedNPCEvent.class, (x)->{
|
||||
// String id = x.getBuilderInfo().;
|
||||
// Arrays.stream(x.getNPCs()).forEach(x->x.getFlockDefinition().);
|
||||
// x.getAllNPCs().forEach((integer, builderInfo) -> {
|
||||
// builderInfo.
|
||||
// });
|
||||
// NotificationUtil.sendNotificationToUniverse(x.getBuilderInfo().getKeyName());
|
||||
// });
|
||||
// this.getEventRegistry().register(Damage.class,(x)->{
|
||||
// Damage.Source source = x.getSource();
|
||||
// });
|
||||
}
|
||||
}
|
||||
25
src/main/java/com/tikaiz/LoggerSingleton.java
Normal file
25
src/main/java/com/tikaiz/LoggerSingleton.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.tikaiz;
|
||||
|
||||
import com.hypixel.hytale.logger.HytaleLogger;
|
||||
|
||||
public class LoggerSingleton {
|
||||
private HytaleLogger hytaleLogger;
|
||||
private static LoggerSingleton instance;
|
||||
public static LoggerSingleton getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LoggerSingleton();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private LoggerSingleton() {
|
||||
}
|
||||
|
||||
public HytaleLogger getHytaleLogger() {
|
||||
return hytaleLogger;
|
||||
}
|
||||
|
||||
public void setHytaleLogger(HytaleLogger hytaleLogger) {
|
||||
this.hytaleLogger = hytaleLogger;
|
||||
}
|
||||
}
|
||||
92
src/main/java/com/tikaiz/commands/ExampleCommand.java
Normal file
92
src/main/java/com/tikaiz/commands/ExampleCommand.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.tikaiz.commands;
|
||||
|
||||
import com.hypixel.hytale.component.Ref;
|
||||
import com.hypixel.hytale.component.Store;
|
||||
import com.hypixel.hytale.component.query.Query;
|
||||
import com.hypixel.hytale.math.vector.Vector3d;
|
||||
import com.hypixel.hytale.math.vector.Vector3f;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandContext;
|
||||
import com.hypixel.hytale.server.core.command.system.arguments.system.DefaultArg;
|
||||
import com.hypixel.hytale.server.core.command.system.arguments.system.OptionalArg;
|
||||
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
|
||||
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractPlayerCommand;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.DisplayNameComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.component.TransformComponent;
|
||||
import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport;
|
||||
import com.hypixel.hytale.server.core.modules.physics.component.PhysicsValues;
|
||||
import com.hypixel.hytale.server.core.universe.PlayerRef;
|
||||
import com.hypixel.hytale.server.core.universe.Universe;
|
||||
import com.hypixel.hytale.server.core.universe.world.World;
|
||||
import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
|
||||
import com.tikaiz.LoggerSingleton;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ExampleCommand extends AbstractPlayerCommand {
|
||||
|
||||
public ExampleCommand() {
|
||||
super("tel", "Super test command!");
|
||||
}
|
||||
|
||||
DefaultArg<List<Double>> arg = this.withListDefaultArg("Pos", "Position", ArgTypes.DOUBLE,new ArrayList<Double>(),"Tell the Player the Position");
|
||||
|
||||
@Override
|
||||
protected void execute(@Nonnull CommandContext commandContext,
|
||||
@Nonnull Store<EntityStore> store,
|
||||
@Nonnull Ref<EntityStore> ref,
|
||||
@Nonnull PlayerRef playerRef,
|
||||
@Nonnull World world) {
|
||||
int size = arg.get(commandContext).size();
|
||||
playerRef.sendMessage(Message.raw("Arg size: " + size));
|
||||
if (!(size == 3 || size == 0)){
|
||||
|
||||
playerRef.sendMessage(Message.raw("Either specify 0 or 3 Arguments"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var transform = store.getComponent(ref, TransformComponent.getComponentType());
|
||||
if (transform == null) return;
|
||||
if (size == 0){
|
||||
var pos = transform.getPosition();
|
||||
playerRef.sendMessage(Message.raw("Player Position: " + pos));
|
||||
return;
|
||||
}
|
||||
var x = arg.get(commandContext).get(0);
|
||||
var y = arg.get(commandContext).get(1);
|
||||
var z = arg.get(commandContext).get(2);
|
||||
|
||||
var newPos = new Vector3d(x,y,z);
|
||||
|
||||
Teleport teleportForPlayer = Teleport.createForPlayer(newPos, new Vector3f());
|
||||
store.addComponent(ref,Teleport.getComponentType(),teleportForPlayer);
|
||||
// var results = new ArrayList<Object>();
|
||||
// store.fetch();
|
||||
|
||||
// transform.setPosition(newPos);
|
||||
|
||||
playerRef.sendMessage(Message.raw("Set Player Position to: " + newPos));
|
||||
|
||||
|
||||
// String message = messageArg.get(commandContext); // get the argument text by the player
|
||||
// playerRef.sendMessage(Message.raw("Player Name: " + playerRef.getUsername()));
|
||||
// var mass = store.getComponent(ref, PhysicsValues.getComponentType()).getMass();
|
||||
// playerRef.sendMessage(Message.raw("Player Mass: " + mass));
|
||||
// var archetype = store.getArchetype(ref);
|
||||
// playerRef.sendMessage(Message.raw("Archetype count: "+archetype.length()));
|
||||
// for (int i = 0; i < archetype.length(); i++) {
|
||||
// var type = archetype.get(i);
|
||||
// if (type!=null){
|
||||
// var typeClass = type.getTypeClass();
|
||||
// playerRef.sendMessage(Message.raw("Type class: "+typeClass));
|
||||
// LoggerSingleton.getInstance().getHytaleLogger().at(Level.INFO).log("Type class: "+typeClass);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package dev.hytalemodding.events;
|
||||
package com.tikaiz.events;
|
||||
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.entity.entities.Player;
|
||||
@@ -1,22 +0,0 @@
|
||||
package dev.hytalemodding;
|
||||
|
||||
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 dev.hytalemodding.commands.ExampleCommand;
|
||||
import dev.hytalemodding.events.ExampleEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ExamplePlugin extends JavaPlugin {
|
||||
|
||||
public ExamplePlugin(@Nonnull JavaPluginInit init) {
|
||||
super(init);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
|
||||
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package dev.hytalemodding.commands;
|
||||
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.AbstractCommand;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandContext;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ExampleCommand extends AbstractCommand {
|
||||
|
||||
public ExampleCommand(String name, String description) {
|
||||
super(name, description);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected CompletableFuture<Void> execute(@Nonnull CommandContext context) {
|
||||
context.sendMessage(Message.raw("Hello from ExampleCommand!"));
|
||||
return CompletableFuture.completedFuture(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,18 @@
|
||||
{
|
||||
"Group": "dev.hytalemodding",
|
||||
"Name": "ExamplePlugin",
|
||||
"Group": "com.tikaiz",
|
||||
"Name": "Hytale Plugin Demo",
|
||||
"Version": "${version}",
|
||||
"Description": "Description of your plugin",
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "Your Name",
|
||||
"Email": "your.email@example.com",
|
||||
"Url": "https://your-website.com"
|
||||
"Name": "Tikaiz",
|
||||
"Email": "tikaiz@gmx.at"
|
||||
}
|
||||
],
|
||||
"Website": "https://your-plugin-website.com",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {},
|
||||
"OptionalDependencies": {},
|
||||
"DisabledByDefault": false,
|
||||
"IncludesAssetPack": false,
|
||||
"Main": "dev.hytalemodding.ExamplePlugin"
|
||||
"Main": "com.tikaiz.HytaleDemo"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user