mirror of
https://github.com/craftaro/EpicSpawners.git
synced 2025-01-08 11:37:51 +08:00
Update to new hologram system.
This commit is contained in:
parent
7c7bf2be91
commit
c560b55722
4
pom.xml
4
pom.xml
@ -106,12 +106,13 @@
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>2.6.10</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
@ -129,6 +130,7 @@
|
||||
<groupId>com.github.brcdev-minecraft</groupId>
|
||||
<artifactId>shopgui-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
|
@ -217,24 +217,39 @@ public class EpicSpawners extends SongodaPlugin {
|
||||
|
||||
for (PlacedSpawner spawner : spawners) {
|
||||
if (spawner.getWorld() == null) continue;
|
||||
updateHologram(spawner);
|
||||
createHologram(spawner);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearHologram(PlacedSpawner spawner) {
|
||||
HologramManager.removeHologram(spawner.getLocation());
|
||||
HologramManager.removeHologram(spawner.getHologramId());
|
||||
}
|
||||
|
||||
public void createHologram(PlacedSpawner spawner) {
|
||||
// are holograms enabled?
|
||||
if (!Settings.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
|
||||
|
||||
// create the hologram
|
||||
HologramManager.createHologram(spawner.getHologramId(), spawner.getLocation(), getHologramName(spawner));
|
||||
}
|
||||
|
||||
public void updateHologram(PlacedSpawner spawner) {
|
||||
// are holograms enabled?
|
||||
if (!Settings.SPAWNER_HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
|
||||
|
||||
int stackSize = spawner.getStackSize();
|
||||
if (spawner.getSpawnerStacks().isEmpty()) return;
|
||||
String name = spawner.getFirstTier().getCompiledDisplayName(spawner.getSpawnerStacks().size() > 1, stackSize).trim();
|
||||
|
||||
// check if it is created
|
||||
if (!HologramManager.isHologramLoaded(spawner.getHologramId())) return;
|
||||
|
||||
// create the hologram
|
||||
HologramManager.updateHologram(spawner.getLocation(), name);
|
||||
HologramManager.updateHologram(spawner.getHologramId(), getHologramName(spawner));
|
||||
}
|
||||
|
||||
public String getHologramName(PlacedSpawner spawner) {
|
||||
int stackSize = spawner.getStackSize();
|
||||
if (spawner.getSpawnerStacks().isEmpty()) return null;
|
||||
return spawner.getFirstTier().getCompiledDisplayName(spawner.getSpawnerStacks().size() > 1, stackSize).trim();
|
||||
}
|
||||
|
||||
public void processChange(Block block) {
|
||||
|
@ -190,7 +190,7 @@ public class BlockListeners implements Listener {
|
||||
EpicSpawners.getInstance().getDataManager().createSpawner(spawner);
|
||||
|
||||
plugin.processChange(block);
|
||||
plugin.updateHologram(spawner);
|
||||
plugin.createHologram(spawner);
|
||||
plugin.getAppearanceTask().updateDisplayItem(spawner, spawnerTier);
|
||||
return;
|
||||
}
|
||||
|
@ -41,6 +41,11 @@ import java.util.UUID;
|
||||
|
||||
public class PlacedSpawner extends SSpawner {
|
||||
|
||||
// This is the unique identifier for this hologram.
|
||||
// It is reset on every plugin load.
|
||||
// Used for holograms.
|
||||
private final UUID uniqueId = UUID.randomUUID();
|
||||
|
||||
// Id for database use.
|
||||
private int id;
|
||||
|
||||
@ -489,6 +494,10 @@ public class PlacedSpawner extends SSpawner {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public String getHologramId() {
|
||||
return "EpicSpawners-" + uniqueId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 31 * (location == null ? 0 : location.hashCode());
|
||||
|
Loading…
Reference in New Issue
Block a user