Code Monkey home page Code Monkey logo

soundapi's Introduction

SoundAPI

This is a plugin that allows you to send to any vanilla minecraft audio in an easy way.

How to use

Send to the coordinates of the player standing any sound

First, you have to register the plugin, you can do this during the onEnable() of your plugin main class.

protected function onEnable(): void {
	$this->getServer()->getPluginManager()->registerEvents($this, $this);
	$this->SoundAPI = $this->getServer()->getPluginManager()->getPlugin("SoundAPI");
}

You can then send the player an sound track with the following code:

Click here to see the sound list

$soundName = "sound.name";
$player = $event->getPlayer();
$this->SoundAPI->playSound($soundName, $player);

I will now send the player a thunderclap sound when they join the server using the code below:

public function onJoin(PlayerJoinEvent $event): void {
	$soundName = "ambient.weather.lightning.impact";
	$player = $event->getPlayer();
	$this->SoundAPI->playSound($soundName, $player);
}

How to stop the sound that is playing

# Remember to register the plugin in `onEnable()`

To stop an sound, follow the steps below

$soundName = "sound.name";
/**
 * $soundName = "";
 * This will stop all playing sound!
 */
$stopAll = true;
$player = $event->getPlayer();
$this->SoundAPI->stopSound($soundName, $stopAll, $player);

I will now stop any audio when a player joins the server

public function onJoin(PlayerJoinEvent $event): void {
	$soundName = "ambient.cave";
	$stopAll = true;
	$player = $event->getPlayer();
	$this->SoundAPI->stopSound($soundName, $stopAll, $player);
}

Still sending the player an sound track, but it allows for more customization

You should use playSound() to make it easier to send sounds to players

# Remember to register the plugin in `onEnable()`

I'll send players a bell sound when they join the server

public function onJoin(PlayerJoinEvent $event): void {
	$player = $event->getPlayer();
	$soundName = "block.bell.hit"
	$x = $player->getPosition()->getX();
	$y = $player->getPosition()->getY();
	$z = $player->getPosition()->getZ();
	$volume = 1.0;
	$pitch = 1.0;
	$this->SoundAPI->playSoundCustom($soundName, $x, $y, $z, $volume, $pitch, $player);
}

Sounds

Click on the link below to see the sound list

https://www.digminecraft.com/lists/sound_list_pe.php

Contact

Discord
You can contact me directly via Discord NhanAZ#9115

soundapi's People

Contributors

nhanaz avatar poggit-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.