Skip to content

Commit

Permalink
Merge pull request #119 from FN-FAL113/Dev/jukebox-fixes
Browse files Browse the repository at this point in the history
jukebox missing discs and duration tick rate fix
  • Loading branch information
FN-FAL113 authored Feb 9, 2024
2 parents 2650389 + 9c63956 commit db4457d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<groupId>ne.fnfal113</groupId>
<artifactId>FNAmplifications</artifactId>
<version>Unoffical-4.1.7</version>
<version>Unoffical-4.1.8</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>

<description>Adds different kind of items in-game from machines, utilities to pvp related items! Take part on exploring FN's offering!</description>
<description>Adds different kind of in-game items from machines, utilities to pvp related items! Take part on exploring FN's offering!</description>

<properties>
<java.version>1.8</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
import ne.fnfal113.fnamplifications.FNAmplifications;
import ne.fnfal113.fnamplifications.machines.abstracts.AbstractJukeBox;
import ne.fnfal113.fnamplifications.machines.implementation.DiscDurationsEnum;
import ne.fnfal113.fnamplifications.utils.Utils;
Expand Down Expand Up @@ -303,17 +302,22 @@ public void onTick(@Nonnull Block b) {
menu.replaceExistingItem(48, OPERATING);

if(jukebox.getPlaying() != Material.AIR) {
menu.replaceExistingItem(49, new CustomItemStack(Material.PINK_STAINED_GLASS_PANE,
"&d&lPlaying: " + jukebox.getPlaying().toString().replace("_", " "),
"&eDuration : " +
durationMap.get(b.getLocation()) + "/" +
(DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDurationInSec() * 2)));
menu.replaceExistingItem(
49,
new CustomItemStack(
Material.PINK_STAINED_GLASS_PANE,
"&d&lPlaying: " + jukebox.getPlaying().toString().replace("_", " "),
"&eDuration : " +
durationMap.get(b.getLocation()) + "/" +
(DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDuration())
)
);
}
}

// when disc duration has elapsed, check next slot if there is a disc else stop the jukebox or go back to default slot when upper bound is reached
if(durationMap.containsKey(b.getLocation())) {
if (durationMap.get(b.getLocation()) >= (DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDurationInSec() * 2)) {
if (durationMap.get(b.getLocation()) >= DiscDurationsEnum.valueOf(jukebox.getPlaying().toString().toUpperCase()).getDuration()) {
goToNextSlot(menu, null);

currentTime = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ne.fnfal113.fnamplifications.machines.implementation;

import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

public enum DiscDurationsEnum {

MUSIC_DISC_13(180),
Expand All @@ -16,16 +18,18 @@ public enum DiscDurationsEnum {
MUSIC_DISC_WAIT(235),
MUSIC_DISC_OTHERSIDE(180),
MUSIC_DISC_PIGSTEP(148),
MUSIC_DISC_5(178),
MUSIC_DISC_RELIC(216),
;

private final int durationInSec;
private final int duration;

DiscDurationsEnum(int durationInSec) {
this.durationInSec = durationInSec;
DiscDurationsEnum(int durationInSeconds) {
this.duration = durationInSeconds * (int) 20.0 / Slimefun.getTickerTask().getTickRate();
}

public int getDurationInSec(){
return durationInSec;
public int getDuration() {
return duration;
}

}

0 comments on commit db4457d

Please sign in to comment.