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 effbd36 commit 53ce3d7
Show file tree
Hide file tree
Showing 189 changed files with 3,137 additions and 0 deletions.
Binary file added .gradle/8.4/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/8.4/checksums/md5-checksums.bin
Binary file not shown.
Binary file added .gradle/8.4/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added .gradle/8.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/8.4/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/8.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/8.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/8.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file added .gradle/8.4/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Fri Feb 02 14:47:16 CET 2024
gradle.version=8.4
Binary file added .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file added .gradle/file-system.probe
Binary file not shown.
Empty file added .gradle/vcs-1/gc.properties
Empty file.
42 changes: 42 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
kotlin("jvm") version "1.9.21"
id("com.github.johnrengelman.shadow") version "8.1.1"

}

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


repositories {
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
mavenCentral()
maven("https://repo.dmulloy2.net/repository/public/")
}

dependencies {
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT") // The Spigot API with no shadowing. Requires the OSS repo.
compileOnly("com.comphenix.protocol:ProtocolLib:5.1.0")
compileOnly("org.jetbrains:annotations:24.1.0")
}


tasks {
shadowJar {
relocate( "kotlin", "org.holoeasy.shaded.kotlin")
}
}

// include java
configure<SourceSetContainer> {
named("main") {
java.srcDir("src/main/kotlin")
}
}

tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(8)
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
¦�?�888
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
91
0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ί\έ Τ¦φ˜Ο‡π–ڍω“Π‰ώ~ί{λkοsшγ“ވο]�rΤξ~Γ~α|μqΟeΝp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions api/build/tmp/jar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

2 changes: 2 additions & 0 deletions api/build/tmp/shadowJar/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

31 changes: 31 additions & 0 deletions api/src/main/kotlin/org/holoeasy/HoloEasy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.holoeasy


import org.bukkit.plugin.Plugin
import org.holoeasy.pool.HologramPool
import org.holoeasy.pool.IHologramPool
import org.holoeasy.pool.InteractiveHologramPool

object HoloEasy {

@JvmField
var useLastSupportedVersion: Boolean = false

@JvmStatic
fun startPool(plugin: Plugin, spawnDistance: Double): IHologramPool {
val simplepool = HologramPool(plugin, spawnDistance)
return simplepool
}

@JvmStatic
fun startInteractivePool(
plugin: Plugin, spawnDistance: Double,
minHitDistance: Float, maxHitDistance: Float
): IHologramPool {
val simplepool = HologramPool(plugin, spawnDistance)
val interactivepool = InteractiveHologramPool(simplepool, minHitDistance, maxHitDistance)
return interactivepool
}


}
85 changes: 85 additions & 0 deletions api/src/main/kotlin/org/holoeasy/builder/HologramBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.holoeasy.builder;

import org.holoeasy.builder.interfaces.HologramConfigGroup;
import org.holoeasy.builder.interfaces.HologramSetupGroup;
import org.holoeasy.config.HologramKey;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
import org.holoeasy.hologram.Hologram;
import org.holoeasy.line.ILine;
import org.holoeasy.line.ITextLine;
import org.holoeasy.pool.IHologramPool;
import org.holoeasy.reactive.MutableState;
import org.jetbrains.annotations.NotNull;

public class HologramBuilder {

static Service getInstance() {
return Service.INSTANCE;
}

public static Hologram hologram(
@NotNull HologramKey key, @NotNull Location location, @NotNull HologramSetupGroup setupGroup) {
HologramConfig holoConfig = new HologramConfig(key, location);
getInstance().getStaticHologram().set(holoConfig);
setupGroup.setup();
getInstance().getStaticHologram().remove();

Hologram holo = new Hologram(key, holoConfig.location, holoConfig.loader);
holo.load(holoConfig.lines.toArray(new ILine[0]));
return holo;
}

public static void config(@NotNull HologramConfigGroup configGroup) {
getInstance().config(configGroup);
}


public static void textline(@NotNull String text, @NotNull Object... args) {
getInstance().textline(
text,
false,
null,
null,
args.length == 0 ? null : args
);
}

public static ITextLine clickable(@NotNull String text, @NotNull Object... args) {
return getInstance().textline(
text,
true,
null,
null,
args.length == 0 ? null : args

);
}

public static ITextLine clickable(@NotNull String text, float minHitDistance, float maxHitDistance,
@NotNull Object... args) {
return getInstance().textline(
text,
true,
minHitDistance,
maxHitDistance,
args.length == 0 ? null : args
);
}

public static void item(@NotNull ItemStack block) {
getInstance().itemline(block);
}

public static void item(@NotNull MutableState<ItemStack> block) {
getInstance().itemlineMutable(block);
}

public static void customline(@NotNull ILine<?> customLine) {
getInstance().customLine(customLine);
}

public static <T> MutableState<T> mutableStateOf(@NotNull T initialValue) {
return new MutableState<>(initialValue);
}
}
29 changes: 29 additions & 0 deletions api/src/main/kotlin/org/holoeasy/builder/HologramConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.holoeasy.builder;

import org.holoeasy.config.HologramKey;
import org.bukkit.Location;
import org.holoeasy.hologram.IHologramLoader;
import org.holoeasy.hologram.TextBlockStandardLoader;
import org.holoeasy.line.ILine;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;


public class HologramConfig {

@NotNull
final HologramKey key;
@NotNull
final Location location;
final List<ILine<?>> lines = new ArrayList<>();
public IHologramLoader loader = new TextBlockStandardLoader();

HologramConfig(@NotNull HologramKey key, @NotNull Location location) {
this.key = key;
this.location = location;
}


}
69 changes: 69 additions & 0 deletions api/src/main/kotlin/org/holoeasy/builder/Service.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.holoeasy.builder


import org.bukkit.inventory.ItemStack
import org.holoeasy.builder.interfaces.HologramConfigGroup
import org.holoeasy.hologram.TextBlockStandardLoader
import org.holoeasy.line.*
import org.holoeasy.reactive.MutableState
import kotlin.math.min

object Service {

val staticHologram: ThreadLocal<HologramConfig> = ThreadLocal()

private fun getStaticHolo(): HologramConfig {
val holo = staticHologram.get() ?: throw RuntimeException("You must call config() inside hologram block")
return holo
}

fun config(configGroup: HologramConfigGroup) {
val config = getStaticHolo()

configGroup.configure(config)


config.loader = config.loader ?: TextBlockStandardLoader()
}

@JvmOverloads
fun textline(
text: String, clickable: Boolean = false, minHitDistance: Float? = null,
maxHitDistance: Float? = null, args: Array<*>? = null
) : ITextLine {
val holo = getStaticHolo()

if (minHitDistance == null || maxHitDistance == null) {
if(holo.key.pool == null && clickable) {
throw IllegalStateException("This hologram is not in a pool,so use the method #clickable(text, minHitDistance, maxHitDistance)")
}

val textLine = TextLine(holo.key.plugin, text, clickable = clickable, args = args)
holo.lines.add(textLine)
return textLine

}
val textLine = TextLine(holo.key.plugin, text, clickable = false, args = args)
val clickableTextLine = ClickableTextLine(textLine, minHitDistance, maxHitDistance)
holo.lines.add(clickableTextLine)
return clickableTextLine
}

fun itemline(block: ItemStack) {
val holo = getStaticHolo()
val blockline = BlockLine(holo.key.plugin, block)
holo.lines.add(blockline)
}

fun itemlineMutable(block: MutableState<ItemStack>) {
val holo = getStaticHolo()
val blockline = BlockLine(holo.key.plugin, block)
holo.lines.add(blockline)
}

fun customLine(customLine: ILine<*>) {
val holo = getStaticHolo()
holo.lines.add(customLine)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.holoeasy.builder.interfaces;

import org.holoeasy.builder.HologramConfig;
import org.jetbrains.annotations.NotNull;

@FunctionalInterface
public interface HologramConfigGroup {
void configure(@NotNull HologramConfig context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.holoeasy.builder.interfaces;

@FunctionalInterface
public interface HologramSetupGroup {
void setup();

}
68 changes: 68 additions & 0 deletions api/src/main/kotlin/org/holoeasy/config/HologramKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.holoeasy.config;

import org.bukkit.plugin.Plugin;
import org.holoeasy.pool.IHologramPool;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public class HologramKey {

private final Plugin plugin;
private final String id;

private final IHologramPool pool;


public HologramKey(@NotNull Plugin plugin, @NotNull String id, @Nullable IHologramPool pool) {
this.plugin = plugin;
this.id = id;
this.pool = pool;
}

public HologramKey(@NotNull Plugin plugin, @NotNull String id) {
this(plugin, id, null);
}

public HologramKey(@NotNull IHologramPool pool, @NotNull String id) {
this(pool.getPlugin(), id, pool);
}

@NotNull
public Plugin getPlugin() {
return plugin;
}

@NotNull
public String getId() {
return id;
}

@Nullable
public IHologramPool getPool() {
return pool;
}

@Override
public int hashCode() {
return Objects.hash(plugin, id, pool);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HologramKey that = (HologramKey) o;
return Objects.equals(plugin, that.plugin) && Objects.equals(id, that.id) && Objects.equals(pool, that.pool);
}

@Override
public String toString() {
return "HologramKey{" +
"plugin=" + plugin +
", id='" + id + '\'' +
", pool=" + pool +
'}';
}
}
9 changes: 9 additions & 0 deletions api/src/main/kotlin/org/holoeasy/ext/DoubleExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.holoeasy.ext

import kotlin.math.floor

val Double.compressAngle: Byte
get() = (this * 256f / 360f).toInt().toByte()

val Double.fixCoordinate: Int
get() = floor(this * 32.0).toInt()
9 changes: 9 additions & 0 deletions api/src/main/kotlin/org/holoeasy/ext/ItemStackExt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.holoeasy.ext

import com.comphenix.protocol.wrappers.BukkitConverters
import org.bukkit.inventory.ItemStack


fun ItemStack.bukkitGeneric() : Any {
return BukkitConverters.getItemStackConverter().getGeneric(this)
}
Loading

0 comments on commit 53ce3d7

Please sign in to comment.