forked from unldenis/holoeasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
68 changed files
with
126 additions
and
2,790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
api/src/main/kotlin/org/holoeasy/packet/metadata/item/MetadataItemPacketD.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
36 changes: 36 additions & 0 deletions
36
example-plugin/src/main/java/org/holoeasy/plugin/ExamplePlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
File renamed without changes
File renamed without changes
Oops, something went wrong.