本文整理汇总了Java中org.spongepowered.api.effect.sound.SoundType类的典型用法代码示例。如果您正苦于以下问题:Java SoundType类的具体用法?Java SoundType怎么用?Java SoundType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoundType类属于org.spongepowered.api.effect.sound包,在下文中一共展示了SoundType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SecondOpenManager
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public SecondOpenManager(Optional<String> id, Optional<SoundType> open_sound, Optional<Text> display_name,
ItemStack hidden_item, boolean increase_hidden_item_quantity,
int rows, boolean show_other_drops, int close_delay,
boolean forbid_close, boolean give_random_on_close,
Optional<SoundType> click_sound) {
super("SECOND", id, open_sound);
this.display_name = display_name;
this.hidden_item = hidden_item;
this.increase_hidden_item_quantity = increase_hidden_item_quantity;
if (rows < 1 || rows > 6) {
GWMCrates.getInstance().getLogger().info("ROWS value more than 6 or less than 1! Force set it to 3!");
rows = 3;
}
this.rows = rows;
this.show_other_drops = show_other_drops;
this.close_delay = close_delay;
if (close_delay <= show_other_drops_delay) {
GWMCrates.getInstance().getLogger().info("SHOW OTHER DROPS DELAY more or equal to CLOSE DELAY! Force set it to 0!");
show_other_drops_delay = 0;
}
this.forbid_close = forbid_close;
this.give_random_on_close = give_random_on_close;
this.click_sound = click_sound;
}
示例2: FirstOpenManager
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public FirstOpenManager(Optional<String> id, Optional<SoundType> open_sound, Optional<Text> display_name,
List<ItemStack> decorative_items, List<Integer> scroll_delays,
boolean clear_decorative_items, boolean clear_other_drops,
int close_delay, Optional<SoundType> scroll_sound,
Optional<SoundType> win_sound, Optional<DecorativeItemsChangeMode> decorative_items_change_mode) {
super("FIRST", id, open_sound);
this.display_name = display_name;
if (decorative_items.size() != 20) {
throw new RuntimeException("DECORATIVE_ITEMS size must be 20 instead of " + decorative_items.size() + "!");
}
this.decorative_items = decorative_items;
this.scroll_delays = scroll_delays;
this.clear_decorative_items = clear_decorative_items;
this.clear_other_drops = clear_other_drops;
this.close_delay = close_delay;
this.scroll_sound = scroll_sound;
this.win_sound = win_sound;
this.decorative_items_change_mode = decorative_items_change_mode;
}
示例3: onChat
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
@Listener
public void onChat(MessageChannelEvent.Chat event) {
String message = event.getRawMessage().toPlain();
for (Player p : Sponge.getServer().getOnlinePlayers()) {
if (message.contains(p.getName())) {
ModuleConfig config = Modules.POKE.get().getConfig().get();
CommentedConfigurationNode node = config.get();
String soundname = node.getNode("sound", "sound").getString();
String categoryname = node.getNode("sound", "category").getString();
Double volume = node.getNode("sound", "volume").getDouble();
Double pitch = node.getNode("sound", "pitch").getDouble();
Double minVolume = node.getNode("sound", "minVolume").getDouble();
SoundType type = Sponge.getRegistry().getType(CatalogTypes.SOUND_TYPE, soundname.toUpperCase()).get();
//TODO wait for CatalogTypes.SOUND_CATEGORY to be added
SoundCategory category;
try {
category = Sponge.getRegistry().getType(CatalogTypes.SOUND_CATEGORY, categoryname.toUpperCase()).get();
} catch (Error ex) {
category = SoundCategories.PLAYER;
}
p.playSound(type, category, p.getLocation().getPosition(), volume, pitch, minVolume);
}
}
}
示例4: OpenManager
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public OpenManager(ConfigurationNode node) {
super(node);
ConfigurationNode open_sound_node = node.getNode("OPEN_SOUND");
try {
if (!open_sound_node.isVirtual()) {
open_sound = Optional.of(open_sound_node.getValue(TypeToken.of(SoundType.class)));
}
} catch (Exception e) {
GWMCrates.getInstance().getLogger().warn("Exception creating Open Manager!", e);
}
}
示例5: Animation1OpenManager
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public Animation1OpenManager(Optional<String> id, Optional<SoundType> open_sound, BlockType floor_block_type,
BlockType fence_block_type, BlockType crate_block_type, OpenManager open_manager,
Optional<Text> hologram, int close_delay) {
super("ANIMATION1", id, open_sound);
this.floor_block_type = floor_block_type;
this.fence_block_type = fence_block_type;
this.crate_block_type = crate_block_type;
this.open_manager = open_manager;
this.hologram = hologram;
this.close_delay = close_delay;
}
示例6: setSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
@Override
public void setSound(SoundType type) {
if(type instanceof SoundEvent) {
sound = (SoundEvent)type;
} else {
throw new IllegalArgumentException("PacketGameSound only accepts vanilla sound types. Use PacketCustomSound instead.");
}
}
示例7: playWorldSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
void playWorldSound(World world, SoundType sound) {
if (!playSound) {
return;
}
for (Player p : world.getPlayers()) {
if (!sleepVoteManager.isMute(p)) {
p.playSound(sound, p.getLocation().getPosition(), 1);
}
}
}
示例8: playSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
private static void playSound(String command, Player player, Location<World> location, double pitch)
{
double volume;
SoundType soundType;
GameRegistry registry = Sponge.getRegistry();
Optional<SoundType> soundTypeOptional = registry.getType(SoundType.class, command);
if (soundTypeOptional.isPresent())
{
volume = 1;
soundType = soundTypeOptional.get();
}
else
{
int index = command.lastIndexOf(':');
String id = index > 0 ? command.substring(0, index).toLowerCase() : "";
Supplier<RuntimeException> error = () -> new NoSuchElementException("No value available for " + id);
soundType = registry.getType(SoundType.class, id).orElseThrow(error);
volume = Double.parseDouble(command.substring(index + 1));
}
if (Double.isNaN(pitch))
{
player.playSound(soundType, soundCategory, location.getPosition(), volume);
}
else
{
player.playSound(soundType, soundCategory, location.getPosition(), volume, pitch);
}
}
示例9: mention
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
private static String mention(Object sender, Object receiver, String msg) {
if (UChat.get().getConfig().root().mention.enable){
for (Player p:Sponge.getServer().getOnlinePlayers()){
if (!sender.equals(p) && Arrays.stream(msg.split(" ")).anyMatch(p.getName()::equalsIgnoreCase)){
if (receiver instanceof Player && receiver.equals(p)){
String mentionc = UChat.get().getConfig().root().mention.color_template.replace("{mentioned-player}", p.getName());
mentionc = formatTags("", mentionc, sender, p, "", new UCChannel("mention"));
if (msg.contains(mentionc) || sender instanceof CommandSource && !UChat.get().getPerms().hasPerm((CommandSource)sender, "chat.mention")){
msg = msg.replaceAll("(?i)\\b"+p.getName()+"\\b", p.getName());
continue;
}
Optional<SoundType> sound = Sponge.getRegistry().getType(SoundType.class, UChat.get().getConfig().root().mention.playsound);
if (sound.isPresent() && !msg.contains(mentionc)){
p.playSound(sound.get(), p.getLocation().getPosition(), 1, 1);
}
msg = msg.replace(mentionc, p.getName());
msg = msg.replaceAll("(?i)\\b"+p.getName()+"\\b", mentionc);
} else {
msg = msg.replaceAll("(?i)\\b"+p.getName()+"\\b", p.getName());
}
}
}
}
return msg;
}
示例10: playSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
@Override
public void playSound(SoundType sound, SoundCategory category, Vector3d position, double volume, double pitch, double minVolume) {
checkNotNull(sound, "sound");
checkNotNull(position, "position");
checkNotNull(category, "category");
this.broadcast(() -> ((LanternSoundType) sound).createMessage(position,
category, (float) Math.max(minVolume, volume), (float) pitch));
}
示例11: playSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
@Override
public void playSound(SoundType sound, SoundCategory category, Vector3d position, double volume, double pitch, double minVolume) {
checkNotNull(sound, "sound");
checkNotNull(position, "position");
checkNotNull(category, "category");
this.session.send(((LanternSoundType) sound).createMessage(position,
category, (float) Math.max(minVolume, volume), (float) pitch));
}
示例12: toSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public static SoundType toSound(Effect effect, int data) {
if (effect.getType() == Effect.Type.SOUND) {
switch (effect) {
case CLICK2:
return SoundTypes.WOOD_CLICK;
case CLICK1:
return SoundTypes.CLICK;
case BOW_FIRE:
return SoundTypes.SHOOT_ARROW;
case DOOR_TOGGLE:
return Math.random() >= 0.5 ? SoundTypes.DOOR_OPEN : SoundTypes.DOOR_CLOSE;
case EXTINGUISH:
return SoundTypes.FIZZ; //TODO: verify this is the correct sound
case RECORD_PLAY:
throw new NotImplementedException("TODO");
case GHAST_SHRIEK:
return SoundTypes.GHAST_SCREAM;
case GHAST_SHOOT:
return SoundTypes.GHAST_FIREBALL;
case BLAZE_SHOOT:
return SoundTypes.BLAZE_BREATH;
case ZOMBIE_CHEW_WOODEN_DOOR:
return SoundTypes.ZOMBIE_WOOD;
case ZOMBIE_CHEW_IRON_DOOR:
return SoundTypes.ZOMBIE_METAL;
case ZOMBIE_DESTROY_DOOR:
return SoundTypes.ZOMBIE_WOODBREAK;
case STEP_SOUND:
throw new NotImplementedException("TODO"); //TODO: determine generic type of block
default:
return null;
}
}
return null;
}
示例13: playSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
@Override
public void playSound(Location location, String sound, float volume, float pitch) {
// TODO: Isn't the String sound the ID and not the name?
//TODO: no idea whether this is right
Optional<SoundType> spongeSound = Pore.getGame().getRegistry().getType(SoundType.class, sound);
if (spongeSound.isPresent()) {
getHandle().playSound(spongeSound.get(), VectorConverter.create3d(location), volume, pitch);
}
}
示例14: getOpenSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public Optional<SoundType> getOpenSound() {
return open_sound;
}
示例15: setOpenSound
import org.spongepowered.api.effect.sound.SoundType; //导入依赖的package包/类
public void setOpenSound(Optional<SoundType> open_sound) {
this.open_sound = open_sound;
}