fix up some things
This commit is contained in:
parent
fb3bb8abaa
commit
1aea64407c
3 changed files with 48 additions and 75 deletions
|
@ -5,10 +5,8 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
|
<list default="true" id="9d5d9b6f-43c8-41a4-bb42-a66ffc96c9b0" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestDisplayCommand.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/java/me/tofaa/entitylib/TestCommand.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/test-plugin/src/main/resources/plugin.yml" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -71,30 +69,30 @@
|
||||||
<option name="showExcludedFiles" value="false" />
|
<option name="showExcludedFiles" value="false" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Gradle.Build EntityLib.executor": "Run",
|
"Gradle.Build EntityLib.executor": "Run",
|
||||||
"Gradle.EntityLib:test-plugin [runServer].executor": "Debug",
|
"Gradle.EntityLib:test-plugin [runServer].executor": "Run",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"jdk.selected.JAVA_MODULE": "corretto-17",
|
"jdk.selected.JAVA_MODULE": "corretto-17",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "D:/Github/EntityLib",
|
"last_opened_file_path": "D:/Github/EntityLib",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"project.structure.last.edited": "Modules",
|
"project.structure.last.edited": "Modules",
|
||||||
"project.structure.proportion": "0.0",
|
"project.structure.proportion": "0.0",
|
||||||
"project.structure.side.proportion": "0.0",
|
"project.structure.side.proportion": "0.0",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="D:\Github\EntityLib\test-plugin" />
|
<recent name="D:\Github\EntityLib\test-plugin" />
|
||||||
|
@ -214,7 +212,7 @@
|
||||||
<workItem from="1705534524814" duration="15424000" />
|
<workItem from="1705534524814" duration="15424000" />
|
||||||
<workItem from="1705578156456" duration="78000" />
|
<workItem from="1705578156456" duration="78000" />
|
||||||
<workItem from="1705636302508" duration="7111000" />
|
<workItem from="1705636302508" duration="7111000" />
|
||||||
<workItem from="1705951390204" duration="1790000" />
|
<workItem from="1705951390204" duration="2221000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class WrapperEntity implements Tickable {
|
||||||
WrapperEntity e = EntityLib.getEntity(passenger);
|
WrapperEntity e = EntityLib.getEntity(passenger);
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
e.riding = -1;
|
e.riding = -1;
|
||||||
|
e.teleport(e.getLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,71 +1,45 @@
|
||||||
package me.tofaa.entitylib;
|
package me.tofaa.entitylib;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.PacketEvents;
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||||
import com.github.retrooper.packetevents.util.Vector3d;
|
import com.github.retrooper.packetevents.protocol.world.Location;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
|
import me.tofaa.entitylib.entity.WrapperEntity;
|
||||||
import me.tofaa.entitylib.meta.EntityMeta;
|
|
||||||
import me.tofaa.entitylib.meta.mobs.passive.SheepMeta;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TestCommand implements CommandExecutor {
|
public class TestCommand implements CommandExecutor {
|
||||||
|
|
||||||
private int entityId = -1;
|
private WrapperEntity base, passenger;
|
||||||
private BukkitTask task;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!(sender instanceof Player)) return false;
|
if (!(sender instanceof Player)) return false;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (entityId == -1) {
|
|
||||||
createEntity(player);
|
if (base != null) {
|
||||||
}
|
base.removePassenger(passenger);
|
||||||
SheepMeta meta = EntityLib.getMeta(entityId, SheepMeta.class);
|
player.sendMessage("Removed");
|
||||||
if (task == null || task.isCancelled()) {
|
return true;
|
||||||
this.task = Bukkit.getScheduler().runTaskTimer(EntityLibPlugin.instance, () -> {
|
|
||||||
byte randomColor = (byte) (Math.random() * 15);
|
|
||||||
meta.setColor(randomColor);
|
|
||||||
meta.setSheared(!meta.isSheared());
|
|
||||||
WrapperPlayServerEntityMetadata packet = meta.createPacket();
|
|
||||||
packet.getEntityMetadata().forEach(s -> player.sendMessage(s.getValue().toString()));
|
|
||||||
PacketEvents.getAPI().getPlayerManager().getUser(player).sendPacket(packet);
|
|
||||||
player.sendMessage("Color is now " + meta.getColor() + " (" + randomColor + ")");
|
|
||||||
}, 0L, 4L);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
task.cancel();
|
|
||||||
task = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SHEEP);
|
||||||
|
passenger = EntityLib.createEntity(UUID.randomUUID(), EntityTypes.SKELETON);
|
||||||
|
|
||||||
|
Location location = SpigotConversionUtil.fromBukkitLocation(player.getLocation());
|
||||||
|
Location pass = location.clone();
|
||||||
|
pass.setPosition(location.getPosition().add(1, 0, 1));
|
||||||
|
base.spawn(location);
|
||||||
|
passenger.spawn(pass);
|
||||||
|
base.addPassenger(passenger);
|
||||||
|
|
||||||
|
player.sendMessage("Spawned");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void createEntity(Player player) {
|
|
||||||
entityId = (int) (Math.random() * 99999);
|
|
||||||
Optional<UUID> uuid = Optional.of(UUID.randomUUID());
|
|
||||||
Optional<Vector3d> velocity = Optional.empty();
|
|
||||||
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(
|
|
||||||
entityId,
|
|
||||||
uuid,
|
|
||||||
EntityTypes.SHEEP,
|
|
||||||
new Vector3d(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()),
|
|
||||||
player.getLocation().getPitch(),
|
|
||||||
player.getLocation().getYaw(),
|
|
||||||
90,
|
|
||||||
0,
|
|
||||||
velocity
|
|
||||||
);
|
|
||||||
PacketEvents.getAPI().getPlayerManager().getUser(player).sendPacket(packet);
|
|
||||||
EntityMeta meta = EntityLib.createMeta(entityId, EntityTypes.SHEEP);
|
|
||||||
player.sendMessage("Meta class is " + meta.getClass().getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue