Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions core/src/main/java/dev/pgm/community/freeze/FreezeManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.pgm.community.freeze;

import static net.kyori.adventure.key.Key.key;
import static net.kyori.adventure.sound.Sound.sound;
import static net.kyori.adventure.text.Component.empty;
import static net.kyori.adventure.text.Component.space;
import static net.kyori.adventure.text.Component.text;
Expand All @@ -14,11 +12,11 @@
import dev.pgm.community.CommunityPermissions;
import dev.pgm.community.utils.BroadcastUtils;
import dev.pgm.community.utils.CommandAudience;
import dev.pgm.community.utils.Sounds;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
Expand All @@ -43,10 +41,6 @@
/** FreezeManager - Handles freezing of players */
public class FreezeManager {

private final Sound FREEZE_SOUND =
sound(key("mob.enderdragon.growl"), Sound.Source.PLAYER, 1f, 1f);
private final Sound THAW_SOUND = sound(key("mob.enderdragon.growl"), Sound.Source.PLAYER, 1f, 2f);

private final OnlinePlayerMapAdapter<Player> frozenPlayers;
private final Cache<UUID, String> offlineFrozenCache =
CacheBuilder.newBuilder().expireAfterWrite(3, TimeUnit.MINUTES).build();
Expand Down Expand Up @@ -142,7 +136,7 @@ private void freeze(Player freezee, Component senderName, boolean silent) {
freezeTitle.build(),
Times.of(Ticks.duration(5), Ticks.duration(9999), Ticks.duration(5))));
}
Audience.get(freezee).playSound(FREEZE_SOUND);
Audience.get(freezee).playSound(Sounds.FREEZE_SOUND);

BroadcastUtils.sendAdminChatMessage(
createInteractiveBroadcast(senderName, freezee, true), CommunityPermissions.FREEZE);
Expand All @@ -160,7 +154,7 @@ private void thaw(Player freezee, Component senderName, boolean silent) {
}

freezee.resetTitle();
Audience.get(freezee).playSound(THAW_SOUND);
Audience.get(freezee).playSound(Sounds.THAW_SOUND);
Audience.get(freezee).sendMessage(thawedTitle.color(NamedTextColor.GREEN));

BroadcastUtils.sendAdminChatMessage(
Expand Down
41 changes: 22 additions & 19 deletions core/src/main/java/dev/pgm/community/utils/Sounds.java
Original file line number Diff line number Diff line change
@@ -1,56 +1,59 @@
package dev.pgm.community.utils;

import static net.kyori.adventure.key.Key.key;
import static net.kyori.adventure.sound.Sound.sound;
import static tc.oc.pgm.util.bukkit.Sounds.sound;

import net.kyori.adventure.sound.Sound;

public class Sounds {

// Played when a player is reported
public static final Sound PLAYER_REPORT = sound(key("random.pop"), Sound.Source.MASTER, 1f, 1.2f);
public static final Sound PLAYER_REPORT = sound("ITEM_PICKUP", "ENTITY_ITEM_PICKUP", 1f, 1.2f);

// Played when a ban evader joins the server
public static final Sound BAN_EVASION = sound(key("random.pop"), Sound.Source.MASTER, 1f, 0.8f);
public static final Sound BAN_EVASION = sound("ITEM_PICKUP", "ENTITY_ITEM_PICKUP", 1f, 0.8f);

// Played when a player is warned
public static final Sound WARN_SOUND =
sound(key("mob.enderdragon.growl"), Sound.Source.MASTER, 1f, 1f);
public static final Sound WARN_SOUND = sound("ENDERDRAGON_GROWL", "ENTITY_ENDER_DRAGON_GROWL");

// Played when a player is frozen
public static final Sound FREEZE_SOUND = WARN_SOUND;

// Played when a player is unfrozen
public static final Sound THAW_SOUND =
sound("ENDERDRAGON_GROWL", "ENTITY_ENDER_DRAGON_GROWL", 1f, 2f);

// Played when an infraction is lifted
public static final Sound PUNISHMENT_PARDON =
sound(key("note.harp"), Sound.Source.MASTER, 0.7f, 1.5f);
sound("NOTE_PIANO", "BLOCK_NOTE_BLOCK_HARP", 0.7f, 1.5f);

// Played when a player is teleported via command
public static final Sound TELEPORT =
sound(key("mob.endermen.portal"), Sound.Source.MASTER, 0.7f, 0.9f);
sound("ENDERMAN_TELEPORT", "ENTITY_ENDERMAN_TELEPORT", 0.7f, 0.9f);

// Played when player logs in and has a pending friend request
public static final Sound FRIEND_REQUEST_LOGIN =
sound(key("note.harp"), Sound.Source.MASTER, 1f, 1.2f);
sound("NOTE_PIANO", "BLOCK_NOTE_BLOCK_HARP", 1f, 1.2f);

// Played when a player requests help
public static final Sound HELP_REQUEST =
sound(key("mob.cat.meow"), Sound.Source.MASTER, 1f, 0.9f);
public static final Sound HELP_REQUEST = sound("CAT_MEOW", "ENTITY_CAT_AMBIENT", 1f, 0.9f);

// Played when a message is broadcasted (/broadcast)
public static final Sound BROADCAST = sound(key("note.pling"), Sound.Source.MASTER, 1f, 1.4f);
public static final Sound BROADCAST = sound("NOTE_PLING", "BLOCK_NOTE_BLOCK_PLING", 1f, 1.4f);

// Played when a message is sent to admin chat
public static final Sound ADMIN_CHAT = sound(key("random.orb"), Sound.Source.MASTER, 1f, 0.7f);
public static final Sound ADMIN_CHAT =
sound("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP", 1f, 0.7f);

// Played when a a prominent message is broadcasted
public static final Sound ALERT = sound(key("note.harp"), Sound.Source.MASTER, 1f, 0.1f);
public static final Sound ALERT = sound("NOTE_PIANO", "BLOCK_NOTE_BLOCK_HARP", 1f, 0.1f);

// Played when a target is selected for the teleport hook
public static final Sound TARGET_CONFIRM =
sound(key("random.wood_click"), Sound.Source.MASTER, 1f, 1.5f);
sound("WOOD_CLICK", "BLOCK_WOODEN_BUTTON_CLICK_ON", 1f, 1.5f);

// Played when a player receives tokens (login or /token give)
public static final Sound GET_TOKENS =
sound(key("random.levelup"), Sound.Source.MASTER, 1f, 1.1f);
public static final Sound GET_TOKENS = sound("LEVEL_UP", "ENTITY_PLAYER_LEVELUP", 1f, 1.1f);

// Played when a player spends tokens (/sponsor)
public static final Sound SPEND_TOKENS =
sound(key("random.anvil_land"), Sound.Source.MASTER, 1f, 1.3f);
public static final Sound SPEND_TOKENS = sound("ANVIL_LAND", "BLOCK_ANVIL_LAND", 1f, 1.3f);
}