Skip to content

Commit

Permalink
update for api changes: max_health and sounds to use registry
Browse files Browse the repository at this point in the history
  • Loading branch information
steve4744 committed Nov 23, 2024
1 parent 54228a9 commit 027900c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/main/java/tntrun/arena/handlers/SoundHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

package tntrun.arena.handlers;

import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.google.common.base.Enums;

import tntrun.TNTRun;
import tntrun.utils.Sounds;

Expand All @@ -35,7 +35,8 @@ public SoundHandler (TNTRun plugin) {

@Override
public void NOTE_PLING(Player p, float volume, float pitch) {
p.playSound(p.getLocation(), Sound.valueOf("BLOCK_NOTE_BLOCK_PLING"), volume, pitch);
NamespacedKey key = NamespacedKey.minecraft("BLOCK_NOTE_BLOCK_PLING");
p.playSound(p.getLocation(), Registry.SOUNDS.get(key), volume, pitch);
}

@Override
Expand Down Expand Up @@ -73,7 +74,8 @@ public void BLOCK_BREAK(Block fblock) {
* @return sound
*/
private Sound getSound(String path) {
return Enums.getIfPresent(Sound.class, plugin.getConfig().getString("sounds." + path + ".sound")).orNull();
NamespacedKey key = NamespacedKey.minecraft(plugin.getConfig().getString("sounds." + path + ".sound"));
return Registry.SOUNDS.get(key);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tntrun/datahandler/PlayerDataStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void storePlayerHealth(Player player) {
LivingEntity le = (LivingEntity) player;
plhealth.put(player.getName(), le.getHealth());
if (plugin.getConfig().getBoolean("onjoin.fillhealth")) {
le.setHealth(le.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
le.setHealth(le.getAttribute(Attribute.MAX_HEALTH).getValue());
}
}

Expand Down Expand Up @@ -154,7 +154,7 @@ public void restorePlayerLevel(Player player) {

public void restorePlayerHealth(Player player) {
LivingEntity le = (LivingEntity) player;
le.setHealth(Math.min(le.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(), plhealth.remove(player.getName())));
le.setHealth(Math.min(le.getAttribute(Attribute.MAX_HEALTH).getValue(), plhealth.remove(player.getName())));
}

public void saveDoubleJumpsToFile(OfflinePlayer player, int amount) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: TNTRun_reloaded
main: tntrun.TNTRun
softdepend: [WorldEdit, Vault, HeadsPlus, mcMMO, PlaceholderAPI, Parties]
version: ${project.version}
api-version: 1.20.6
api-version: 1.21.3
author: [steve4744]
commands:
tntrunsetup:
Expand Down

0 comments on commit 027900c

Please sign in to comment.