Closed 7FULL closed 7 months ago
Caused by: java.lang.NullPointerException: Cannot invoke "com.maximfiedler.hologramapi.hologram.HologramManager.removeAll(String)" because "this.hologramManager" is null at com.prueba.prueba.listeners.PlayerListeners.onPlayerLeave(PlayerListeners.java:62) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
So you have a global variable hologramManager right? Are you sure that first someone joined (to initilize the hologramManager variable) before someone left?
You can just init that variable on the top because the plugin is anyways loaded after the api...
private HologramManager hologramManager = HologramAPI.getHologramManager();
(on top)
Also add HologramAPI to your plugin.yml (depend: [HologramAPI]) and make sure that you have also uploaded the plugin jar from the releases or spigotmc on to your server.
I described how to do everything in the wiki https://github.com/MaximFiedler/HologramAPI/wiki
I have It all. The plugon the dependency, all. The holograma is shown whe Simeone joins but when Simeone leaves It tells that. Sorry for my english btw im fron Spain
And are you sure that you did not compile the api directly into your plugin (for example by using the shadow plugin)? You can open the .jar using winrar for example and look you have there a com package which contains a maximfiedler packages and if so remove it. Can you maybe also show me your pom or build.gradle file?
Reason why this is a problem: If you use the TextHologram class there is no problem because you create a new Instance of that class But if you use the HologramAPI.getHologramManager() method and it uses the code in your jar it will return null because its inizilized in the onEnable() method which gets only called if it only runs on the server thats why you need to use the data from the plugin instead of the code in the jar so look that you only compile your plugin with the api but the jar should not contain the code of the hologram api
You can also take a look at my example plugin which uses the hologram api https://github.com/MaximFiedler/ExampleHologramPlugin
If you want i can add a check to the getter method and initilize the hologram api variable if its null even without the onEnable So after that it should work without removing it from the jar
But the animations will still not work because they need the plugin instance
I have It all. The plugon the dependency, all. The holograma is shown whe Simeone joins but when Simeone leaves It tells that. Sorry for my english btw im fron Spain
If thats to complicated you can maybe just sent me your pom.xml file or build.gradle file and i can take a look
¿Todavía estás aquí? Creo que tengo una solución para ti: Actualiza a la última versión de la api (1.1.4) en pom.xml o build.gradle o actualiza el jar que usas como librería en tu IDE/editor de código y elimina el plugin hologramapi de tu servidor.
Than you so much for the effort or answering me Ill be back home in 20 min and Ill let you know
Code: ` HologramManager hologramManager = HologramAPI.getHologramManager();
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
//Para que no salga cuando se une un jugador
event.setJoinMessage("");
TextHologram hologram = new TextHologram(player.getUniqueId().toString())
.setText(ChatColor.AQUA + "Hello world!")
.addLine(ChatColor.RED + "Second line")
.addLine("Third line")
.addLine("Another line...") // You can add as many lines as you want
.setBillboard(Display.Billboard.VERTICAL)
.setTextShadow(true)
.setBackgroundColor(Color.fromARGB(0/*Opacity*/, 255/*Red*/, 236/*Green*/, 222/*Blue*/)) // You can use the https://htmlcolorcodes.com/color-picker/ to get the RGB color you want!
.spawn(player.getLocation().add(0, 2, 0));
player.sendMessage("Hola " + player.getName());
if (player.hasPlayedBefore()){
//Displayname basicamente es el nombre que se muestra en el chat pero puede que haya sido personalizado
player.sendMessage("Bienvenido de nuevo " + player.getDisplayName());
} else {
player.sendMessage("Bienvenido por primera vez");
}
}
//Jugador se va del servidor
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
Player player = event.getPlayer();
System.out.println("Adios " + player.getName());
event.setQuitMessage("");
player.sendMessage("Adios " + player.getName());
hologramManager.removeAll(player.getUniqueId().toString());
}`
Pom.xml `<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>com.prueba</groupId>
<artifactId>Prueba</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Prueba</name>
<properties>
<java.version>16</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Configuración del plugin maven-compiler-plugin para compilar el código fuente -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<!-- Configuración del plugin maven-shade-plugin para crear un JAR sombreado (shaded JAR) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<!-- Configuración del plugin maven-resources-plugin para copiar el JAR generado -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-plugin</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- Aquí se define la carpeta de destino, reemplaza la ruta a tu carpeta de plugins -->
<outputDirectory>C:/Users/phgfu/staff/MCServers/1.19.4/plugins</outputDirectory>
<resources>
<resource>
<!-- El archivo JAR generado se copiará a la carpeta de destino con el mismo nombre -->
<directory>${project.build.directory}</directory>
<includes>
<include>Prueba-1.0-SNAPSHOT.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MaximFiedler</groupId>
<artifactId>HologramAPI</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies>
`
Error:
org.bukkit.event.EventException: null at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?] at net.minecraft.server.players.PlayerList.remove(PlayerList.java:521) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1790) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.network.NetworkManager.m(NetworkManager.java:444) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.network.ServerConnection.c(ServerConnection.java:195) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1326) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:388) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1200) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1017) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3763-Spigot-7d7b241-5a5e43e] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: java.lang.NullPointerException: Cannot invoke "com.maximfiedler.hologramapi.hologram.HologramManager.removeAll(String)" because "this.hologramManager" is null at com.prueba.prueba.listeners.PlayerListeners.onPlayerLeave(PlayerListeners.java:60) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?] ... 13 more
Btw with that code I see them like this
Forgot to mention when compiling this appears in console
Ok one moment please i need to read and understand everything first...
Sorry
Okay so... you use the shade plugin you just need to exclude my api from it
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<excludes>
<!-- Exclude HologramAPI from shading -->
<exclude>com.github.MaximFiedler:HologramAPI</exclude>
</excludes>
</artifactSet>
put this into the < configuration > tag
Also if you already removed the hologramapi plugin jar from your server add it again
Here is the full edited pom.xml (I did not tested it so if there is a problem tell me)
<groupId>com.prueba</groupId>
<artifactId>Prueba</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Prueba</name>
<properties>
<java.version>16</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Configuración del plugin maven-compiler-plugin para compilar el código fuente -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<!-- Configuración del plugin maven-shade-plugin para crear un JAR sombreado (shaded JAR) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<excludes>
<!-- Exclude HologramAPI from shading -->
<exclude>com.github.MaximFiedler:HologramAPI</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<!-- Configuración del plugin maven-resources-plugin para copiar el JAR generado -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-plugin</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- Aquí se define la carpeta de destino, reemplaza la ruta a tu carpeta de plugins -->
<outputDirectory>C:/Users/phgfu/staff/MCServers/1.19.4/plugins</outputDirectory>
<resources>
<resource>
<!-- El archivo JAR generado se copiará a la carpeta de destino con el mismo nombre -->
<directory>${project.build.directory}</directory>
<includes>
<include>Prueba-1.0-SNAPSHOT.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MaximFiedler</groupId>
<artifactId>HologramAPI</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies>
WORKS PERFECTLY!!!! Thank you so much and excuse me for bothering you. Btw any idea why they look like that?
No problem! Actually i dont know why they look like that... which client are you using? Can you add this line after the hologram creation for debugging in the join event? player.sendMessage(hologram.getText());
and show me that message?
Thats how it should look... can i join your server maybe and look by myself?
Like how the holograms are there using my client
Or can you stand nearby a hologram (max 2 blocks away) and use this command: /data get entity @e[type=minecraft:text_display,distance=..2,limit=1]
It is running in localhost how do I change the ip
It doesnt found the entity
Increase the distance in the command from 2 to like 10
/data get entity @e[type=minecraft:text_display,distance=..10,limit=1]
It is running in localhost how do I change the ip
You can use ngrok (port tunnel), open the port on the router or find a host/rent or buy a root, v or dedicated server.. But you dont have to do that I just thought the server is already public that's why I asked
I mean i could host the server for you as long as i still have server capacity in surplus (but it would be a bit complicated i would need to give you access in some way)
If you need the server anyways after this Ill do it
I will try to solve this problem tomorrow then I come back here again
I think i have found the problem... In the screenshot you have sent me the line width is set to 0 and if i spawn such a display manually it looks like your display. On the left a display with the line width of 0 and on the right side a display with the line width of 200
Add this line to your code:
.setLineWidth(200)
Or
hologram.setLineWidth(200);
hologram.update();
Also use /version HologramAPI
and check the version of the plugin
if its not 1.1.4 update it.
Still the same and it is 1.1.4
Can you share the code for spawning the hologram again?
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
//Para que no salga cuando se une un jugador
// Create the event here
CustomEvent customEvent = new CustomEvent("Sample Message");
// Call the event
Bukkit.getServer().getPluginManager().callEvent(customEvent);
// Now you do the event
Bukkit.getServer().broadcastMessage(customEvent.getMessage());
event.setJoinMessage("");
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = manager.getNewScoreboard();
Objective objective = scoreboard.registerNewObjective("Title", "dummy");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(ChatColor.BLUE + "Scoreboard Title");
Score score = objective.getScore(ChatColor.GOLD + "Money: $" + ChatColor.GREEN + 1); //create a line for the board
Score s2 = objective.getScore(""); //blank space
Score s3 = objective.getScore(ChatColor.DARK_PURPLE + "https://google.com");
score.setScore(3);
s2.setScore(2);
s3.setScore(1);
s2.setScore(0);
player.setScoreboard(scoreboard);
TextHologram hologram = new TextHologram(player.getUniqueId().toString())
.setText(ChatColor.AQUA + "Hello world!")
.addLine(ChatColor.RED + "Second line")
.addLine("Third line")
.addLine("Another line...") // You can add as many lines as you want
.setBillboard(Display.Billboard.VERTICAL)
.setTextShadow(true)
.setBackgroundColor(Color.fromARGB(0/*Opacity*/, 255/*Red*/, 236/*Green*/, 222/*Blue*/)) // You can use the https://htmlcolorcodes.com/color-picker/ to get the RGB color you want!
.spawn(player.getLocation().add(0, 2, 0))
.setLineWidth(200);
player.sendMessage(hologram.getText());
player.sendMessage("Hola " + player.getName());
if (player.hasPlayedBefore()){
//Displayname basicamente es el nombre que se muestra en el chat pero puede que haya sido personalizado
player.sendMessage("Bienvenido de nuevo " + player.getDisplayName());
} else {
player.sendMessage("Bienvenido por primera vez");
}
}
You need to set the line width before the spawn method call
because otherwise it will not be updated anymore unless you call the .update()
method
.setLineWidth(200)
.spawn(player.getLocation().add(0, 2, 0));
``@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer();