Skip to content

Commit

Permalink
Added animation & updated TextHologram.java
Browse files Browse the repository at this point in the history
  • Loading branch information
max1mde committed Aug 3, 2023
1 parent 0069219 commit 68da91f
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 302 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'com.maximfiedler'
version = '1.0.5'
version = '1.1'

repositories {
mavenCentral()
Expand All @@ -19,6 +19,8 @@ repositories {

dependencies {
compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT"
compileOnly 'org.projectlombok:lombok:1.18.28'
annotationProcessor 'org.projectlombok:lombok:1.18.28'
}

def targetJavaVersion = 17
Expand Down
68 changes: 5 additions & 63 deletions src/main/java/com/maximfiedler/hologramapi/HologramAPI.java
Original file line number Diff line number Diff line change
@@ -1,75 +1,17 @@
package com.maximfiedler.hologramapi;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.TextDisplay;
import org.bukkit.plugin.PluginDescriptionFile;
import com.maximfiedler.hologramapi.hologram.HologramManager;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
import org.joml.Vector3f;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

public final class HologramAPI extends JavaPlugin {

private static HologramAPI hologramAPI;
private static @Getter(AccessLevel.PUBLIC) HologramManager hologramManager;

@Override
public void onEnable() {
hologramAPI = this;
getServer().getLogger().log(Level.INFO, ChatColor.GREEN + "Enabled HologramAPI v" + this.getDescription().getVersion());
}

public static HologramAPI getHologramAPI() {
return hologramAPI;
}

public void removeAllHologramsByID(String id) {
for(World world : Bukkit.getWorlds()) {
for(Entity entity : world.getEntities()) {
if(!(entity instanceof TextDisplay textDisplay)) continue;
if(!textDisplay.getScoreboardTags().contains(id + "_hologram_api")) continue;
textDisplay.remove();
}
}
}

public List<TextHologram> getHologramsByID(String id) {
List<TextDisplay> displays = new ArrayList<>();
List<TextHologram> holograms = new ArrayList<>();
for(World world : Bukkit.getWorlds()) {
for(Entity entity : world.getEntities()) {
if(!(entity instanceof TextDisplay textDisplay)) continue;
if(!textDisplay.getScoreboardTags().contains(id + "_hologram_api")) continue;
displays.add(textDisplay);
}
}
for(TextDisplay textDisplay : displays) {
TextHologram hologram = new TextHologram("id");
hologram.setDisplay(textDisplay);
hologram.setText(textDisplay.getText());
hologram.setBillboard(textDisplay.getBillboard());
hologram.setBackgroundColor(textDisplay.getBackgroundColor());
hologram.setAlignment(textDisplay.getAlignment());
hologram.setViewRange(textDisplay.getViewRange());
hologram.setSeeThrough(textDisplay.isSeeThrough());
hologram.setTextShadow(textDisplay.isShadowed());
hologram.setLineWidth(textDisplay.getLineWidth());
hologram.setTextOpacity(textDisplay.getTextOpacity());
hologram.setBrightness(textDisplay.getBrightness());
var transformation = textDisplay.getTransformation();
hologram.setSize(transformation.getScale());
hologram.setLeftRotation(transformation.getLeftRotation());
hologram.setRightRotation(transformation.getRightRotation());
hologram.setTranslation(transformation.getTranslation());
holograms.add(hologram);
}
displays.clear();
return holograms;
hologramManager = new HologramManager(this);
}

}
238 changes: 0 additions & 238 deletions src/main/java/com/maximfiedler/hologramapi/TextHologram.java

This file was deleted.

Loading

0 comments on commit 68da91f

Please sign in to comment.