Skip to content

Commit

Permalink
3.1.1:
Browse files Browse the repository at this point in the history
- 1.8.8 fixed(item lines *not* supported)
- 1.19.4 fixed
- gradle instead of maven for build performance
- added example-plugin
  • Loading branch information
unldenis committed Feb 2, 2024
1 parent 46abf6b commit effbd36
Show file tree
Hide file tree
Showing 68 changed files with 126 additions and 2,790 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
HoloEasy is a simple, modern and high-performant Java and Kotlin Minecraft Hologram library for 1.8-1.20.4 servers.

<p align="center">
<img src="gif.gif" alt="holoeasy video"/>
<img src="preview/gif.gif" alt="holoeasy video"/>
</p>

## Quickstart
Expand Down Expand Up @@ -78,7 +78,7 @@ fun addHologram(location: Location) {
From 3.1.0 version, the parameters of text lines and item lines **_can also be reactive_**. This means that you can update the line by simply calling the 'set' method to these.

<p align="center">
<img src="state.gif" alt="holoeasy state video"/>
<img src="preview/state.gif" alt="holoeasy state video"/>
</p>

> [!WARNING]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.holoeasy.packet.metadata.item

import com.comphenix.protocol.PacketType
import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.utility.MinecraftVersion
import com.comphenix.protocol.wrappers.WrappedChatComponent
import com.comphenix.protocol.wrappers.WrappedDataValue
import com.comphenix.protocol.wrappers.WrappedDataWatcher
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject
import com.google.common.collect.Lists
import org.bukkit.inventory.ItemStack
import org.holoeasy.ext.bukkitGeneric
import org.holoeasy.ext.parse119
import org.holoeasy.ext.setBool
import org.holoeasy.util.BOOL_SERIALIZER
import org.holoeasy.util.ITEM_SERIALIZER
import org.holoeasy.util.VersionEnum
import java.util.*


object MetadataItemPacketD : IMetadataItemPacket {
override val versionSupport: Array<out ClosedRange<VersionEnum>>
get() = arrayOf(VersionEnum.V1_19..VersionEnum.V1_19)

override fun metadata(entityId: Int, item: ItemStack): PacketContainer {
val packet = PacketContainer(PacketType.Play.Server.ENTITY_METADATA)
packet.integers.write(0, entityId)

val watcher = WrappedDataWatcher()

val gravity = WrappedDataWatcherObject(
5, BOOL_SERIALIZER
)
watcher.setObject(gravity,true)

val itemSer = WrappedDataWatcherObject(
8, ITEM_SERIALIZER
)
watcher.setObject(itemSer, item.bukkitGeneric())

// https://www.spigotmc.org/threads/unable-to-modify-entity-metadata-packet-using-protocollib-1-19-3.582442/#post-4517187
packet.parse119(watcher)

return packet
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import org.holoeasy.util.ITEM_SERIALIZER
import org.holoeasy.util.VersionEnum


object MetadataItemPacketD : IMetadataItemPacket {
object MetadataItemPacketE : IMetadataItemPacket {
override val versionSupport: Array<out ClosedRange<VersionEnum>>
get() = arrayOf(VersionEnum.V1_20..VersionEnum.V1_20)
get() = arrayOf(VersionEnum.V1_19..VersionEnum.V1_20)

override fun metadata(entityId: Int, item: ItemStack): PacketContainer {
val packet = PacketContainer(PacketType.Play.Server.ENTITY_METADATA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package org.holoeasy.packet.metadata.text
import com.comphenix.protocol.PacketType
import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.wrappers.WrappedDataWatcher
import org.holoeasy.ext.set
import org.holoeasy.ext.setBool
import org.holoeasy.ext.setByte
import org.holoeasy.ext.setChatComponent
import org.holoeasy.ext.*
import org.holoeasy.packet.packet
import org.holoeasy.util.VersionEnum

object MetadataTextPacketC : IMetadataTextPacket {
object MetadataTextPacketD : IMetadataTextPacket {
override val versionSupport: Array<out ClosedRange<VersionEnum>>
get() = arrayOf(VersionEnum.V1_13..VersionEnum.V1_19)
get() = arrayOf(VersionEnum.V1_19..VersionEnum.V1_19)

override fun metadata(entityId: Int, nameTag: String?, invisible : Boolean): PacketContainer {
val packet = PacketContainer(PacketType.Play.Server.ENTITY_METADATA)
packet.integers.write(0, entityId)

val watcher = WrappedDataWatcher()

if(invisible)
Expand All @@ -24,10 +24,11 @@ object MetadataTextPacketC : IMetadataTextPacket {
watcher.setChatComponent(2, nameTag)
watcher.setBool(3, true)
}
return packet(PacketType.Play.Server.ENTITY_METADATA) {
integers[0] = entityId
watchableCollectionModifier[0] = watcher.watchableObjects
}

// https://www.spigotmc.org/threads/unable-to-modify-entity-metadata-packet-using-protocollib-1-19-3.582442/#post-4517187
packet.parse119(watcher)

return packet
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.holoeasy.util.BYTE_SERIALIZER
import org.holoeasy.util.VersionEnum
import java.util.*

object MetadataTextPacketD : IMetadataTextPacket {
object MetadataTextPacketE : IMetadataTextPacket {
override val versionSupport: Array<out ClosedRange<VersionEnum>>
get() = arrayOf(VersionEnum.V1_20..VersionEnum.V1_20)

Expand Down
20 changes: 20 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
kotlin("jvm") version "1.9.21"
}

group = "org.holoeasy"
version = "3.1.1"

repositories {
}

dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test")
}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(8)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.holoeasy.plugin;


import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.holoeasy.HoloEasy;
import org.holoeasy.config.HologramKey;
import org.holoeasy.pool.IHologramPool;
import org.holoeasy.reactive.MutableState;
import org.jetbrains.annotations.NotNull;
import static org.holoeasy.builder.HologramBuilder.*;
public class ExamplePlugin extends JavaPlugin {

@Override
public void onEnable() {
IHologramPool pool = HoloEasy.startInteractivePool(this, 60, 0.5f, 5f);
getCommand("hologram").setExecutor((sender, cmd, s, args) -> {

Player player = (Player) sender;
MutableState<Integer> clickCount = mutableStateOf(0); // can be any type

hologram(new HologramKey(pool, "unique-id-holo"), player.getLocation(), () -> {
textline("Hello");
textline("Count {}", clickCount);
clickable("Click me").onClick(p -> clickCount.set(clickCount.get() + 1));
item(new ItemStack(Material.APPLE));
});

return true;
});
}


}
7 changes: 7 additions & 0 deletions example-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: ExamplePlugin
main: org.holoeasy.plugin.ExamplePlugin
version: 1.0
depend: [ProtocolLib]
api-version: 1.8
commands:
hologram:
176 changes: 0 additions & 176 deletions pom.xml

This file was deleted.

File renamed without changes
File renamed without changes
Loading

0 comments on commit effbd36

Please sign in to comment.