forked from AlpsBTE/Plot-System
-
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.
feat: ported HolographicDisplay plugin to DecentHologram
* Since HolographicDisplay is no longer in maintenance, we port nearly every uses to DecentHologram instead * This fixed a bug of Bedrock player not able to view newly created hologram * The port is not yet 100%, so HolographicDisplay is still a requirement due to a use in alpslib.npc
- Loading branch information
1 parent
156fc5b
commit c2894e2
Showing
25 changed files
with
791 additions
and
114 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
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
55 changes: 55 additions & 0 deletions
55
src/main/java/com/alpsbte/plotsystem/core/holograms/HologramManager.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,55 @@ | ||
package com.alpsbte.plotsystem.core.holograms; | ||
|
||
import com.alpsbte.plotsystem.PlotSystem; | ||
import com.alpsbte.plotsystem.core.holograms.connector.DecentHologramDisplay; | ||
import com.alpsbte.plotsystem.utils.Utils; | ||
import com.alpsbte.plotsystem.utils.io.ConfigUtil; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.logging.Level; | ||
|
||
public abstract class HologramManager { | ||
public static List<DecentHologramDisplay> activeDisplays = new ArrayList<>(); | ||
|
||
public static void reload() { | ||
for (DecentHologramDisplay display : activeDisplays) { | ||
Bukkit.getLogger().log(Level.INFO, "Enabling Hologram: " + PlotSystem.getPlugin().getConfig().getBoolean(((HologramConfiguration) display).getEnablePath())); | ||
|
||
if (PlotSystem.getPlugin().getConfig().getBoolean(((HologramConfiguration) display).getEnablePath())) | ||
for (Player player : Objects.requireNonNull(Bukkit.getWorld(display.getLocation().getWorld().getName())).getPlayers()) display.create(player); | ||
else display.removeAll(); | ||
} | ||
} | ||
|
||
public static Location getLocation(HologramConfiguration configPaths) { | ||
FileConfiguration config = PlotSystem.getPlugin().getConfig(); | ||
|
||
return new Location(Objects.requireNonNull(Utils.getSpawnLocation().getWorld()), | ||
config.getDouble(configPaths.getXPath()), | ||
config.getDouble(configPaths.getYPath()), | ||
config.getDouble(configPaths.getZPath()) | ||
); | ||
} | ||
|
||
public static void saveLocation(String id, HologramConfiguration configPaths, Location newLocation) { | ||
FileConfiguration config = PlotSystem.getPlugin().getConfig(); | ||
config.set(configPaths.getEnablePath(), true); | ||
config.set(configPaths.getXPath(), newLocation.getX()); | ||
config.set(configPaths.getYPath(), newLocation.getY()); | ||
config.set(configPaths.getZPath(), newLocation.getZ()); | ||
ConfigUtil.getInstance().saveFiles(); | ||
|
||
LeaderboardManager.getActiveDisplays().stream().filter(leaderboard -> leaderboard.getId().equals(id)).findFirst() | ||
.ifPresent(holo -> holo.setLocation(newLocation)); | ||
} | ||
|
||
public static List<DecentHologramDisplay> getActiveDisplays() { | ||
return activeDisplays; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/alpsbte/plotsystem/core/holograms/MessagesManager.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,17 @@ | ||
package com.alpsbte.plotsystem.core.holograms; | ||
|
||
import com.alpsbte.plotsystem.core.holograms.connector.DecentHologramDisplay; | ||
import eu.decentsoftware.holograms.api.DHAPI; | ||
import eu.decentsoftware.holograms.api.holograms.Hologram; | ||
import eu.decentsoftware.holograms.api.holograms.HologramLine; | ||
import eu.decentsoftware.holograms.api.utils.entity.HologramEntity; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.EntityType; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class MessagesManager extends HologramManager { | ||
public static void init() { | ||
activeDisplays.add(new WelcomeMessage()); | ||
} | ||
} |
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
Oops, something went wrong.