Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
d0by1 committed Dec 6, 2021
1 parent e523f01 commit 5936018
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
defaultTasks 'build'

group 'eu.decentsoftware.holograms'
version '2.2.0'
version '2.2.1'
description 'Lightweight yet very powerful hologram plugin with many features and configuration options.'

repositories {
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/eu/decentsoftware/holograms/api/DHAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public static HologramPage addHologramPage(Hologram hologram, List<String> lines
page.addLine(line);
}
}
hologram.save();
return page;
}

Expand Down Expand Up @@ -217,6 +218,7 @@ public static HologramPage insertHologramPage(Hologram hologram, int index, List
page.addLine(line);
}
}
hologram.save();
return page;
}

Expand All @@ -231,7 +233,9 @@ public static HologramPage insertHologramPage(Hologram hologram, int index, List
@Nullable
public static HologramPage removeHologramPage(Hologram hologram, int index) throws IllegalArgumentException {
Validate.notNull(hologram);
return hologram.removePage(index);
HologramPage page = hologram.removePage(index);
hologram.save();
return page;
}

/**
Expand Down Expand Up @@ -317,6 +321,7 @@ public static HologramLine addHologramLine(Hologram hologram, int pageIndex, Str
public static HologramLine addHologramLine(HologramPage page, String content) throws IllegalArgumentException {
HologramLine line = new HologramLine(page, page.getNextLineLocation(), content);
page.addLine(line);
page.getParent().save();
return line;
}

Expand Down Expand Up @@ -368,6 +373,7 @@ public static HologramLine insertHologramLine(HologramPage page, int index, Stri
}
HologramLine line = new HologramLine(page, oldLine.getLocation(), content);
page.insertLine(index, line);
page.getParent().save();
return line;
}

Expand All @@ -389,6 +395,9 @@ public static void setHologramLine(HologramLine line, String content) throws Ill
line.getParent().realignLines();
}
}
if (line.hasParent()) {
line.getParent().getParent().save();
}
}

/**
Expand Down Expand Up @@ -474,7 +483,9 @@ public static HologramLine removeHologramLine(Hologram hologram, int pageIndex,
if (page == null) {
throw new IllegalArgumentException("Given page index is out of bounds for the hologram.");
}
return page.removeLine(lineIndex);
HologramLine line = page.removeLine(lineIndex);
hologram.save();
return line;
}

/**
Expand All @@ -488,7 +499,9 @@ public static HologramLine removeHologramLine(Hologram hologram, int pageIndex,
@Nullable
public static HologramLine removeHologramLine(HologramPage page, int lineIndex) throws IllegalArgumentException {
Validate.notNull(page);
return page.removeLine(lineIndex);
HologramLine line = page.removeLine(lineIndex);
page.getParent().save();
return line;
}

/**
Expand Down Expand Up @@ -540,6 +553,7 @@ public static void setHologramLines(Hologram hologram, int pageIndex, List<Strin
}
hologram.realignLines();
hologram.updateAll();
hologram.save();
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/decentsoftware/holograms/api/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static void sendVersionMessage(CommandSender sender) {

public static void sendUpdateMessage(CommandSender sender) {
Common.tell(sender,
"\n&fA new version of &3DecentHolograms &fis available. Download it from: &7%s",
"\n&fA newer version of &3DecentHolograms &fis available. Download it from: &7%s",
"https://www.spigotmc.org/resources/96927/"
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ public long getInterval() {
@Override
public void tick() {
if (tickCounter.get() == getUpdateInterval()) {
for (UUID uid : getViewers()) {
Player player = Bukkit.getPlayer(uid);
if (player == null) {
viewers.remove(uid);
}
}
updateAll();
tickCounter.set(0);
return;
Expand Down Expand Up @@ -352,10 +358,10 @@ public boolean show(Player player, int pageIndex) {
hide(player);
}
page.getLines().forEach(line -> line.show(player));
showClickableEntities(player);
// Add player to viewers
viewerPages.put(player.getUniqueId(), pageIndex);
viewers.add(player.getUniqueId());
showClickableEntities(player);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void tick() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (!hologram.isVisible(player) && hologram.canShow(player) && hologram.isInDisplayRange(player)) {
hologram.show(player, hologram.getPlayerPage(player));
} else if (hologram.isVisible(player) && (!hologram.canShow(player) || !hologram.isInDisplayRange(player))) {
} else if (hologram.isVisible(player) && !(hologram.canShow(player) && hologram.isInDisplayRange(player))) {
hologram.hide(player);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public PlayerListener(DecentHolograms decentHolograms) {
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
decentHolograms.getHologramManager().showAll(player);
decentHolograms.getPacketListener().register(player);
if (player.hasPermission("dh.admin") && decentHolograms.isUpdateAvailable()) {
Lang.sendUpdateMessage(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void destroy() {
* @param ticked The ticked object.
*/
public void register(ITicked ticked) {
if (tickedObjects.contains(ticked)) return;
synchronized (newTickedObjects) {
if (tickedObjects.contains(ticked)) return;
if (!newTickedObjects.contains(ticked)) {
newTickedObjects.add(ticked);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ defaults:
# Default line
text: Blank Line
# Default Hologram display range in blocks.
display-range: 64
display-range: 48
# Default Hologram update range in blocks.
update-range: 64
update-range: 48
# Default Hologram update interval in ticks.
update-interval: 20
# Default heigths of different hologram line types.
Expand Down

0 comments on commit 5936018

Please sign in to comment.