Skip to content

Commit

Permalink
Added Sound Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiamded authored Sep 16, 2021
1 parent 887c47f commit e0674a2
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 147 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.dummyperson</groupId>
<artifactId>weathereffect</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.3</version>
<packaging>jar</packaging>

<name>WeatherEffect</name>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/me/dummyperson/weathereffect/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public void onEnable() {
saveDefaultConfig();
runnable();
reloadConfig();
this.getLogger().info("&bWeathereEffect Enabled!");
}

@Override
public void onDisable() {
this.getLogger().info("&4WeathereEffect Disabled!");
// Plugin shutdown logic
}

Expand Down
48 changes: 43 additions & 5 deletions src/main/java/me/dummyperson/weathereffect/WeatherEffectTask.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package me.dummyperson.weathereffect;

import com.destroystokyo.paper.ParticleBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import net.minecraft.server.commands.CommandPlaySound;
import org.bukkit.*;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;


import java.util.List;
import java.util.Random;

public class WeatherEffectTask {

Expand All @@ -24,11 +25,11 @@ public void criteriaChecker(Player player, Configuration configuration) {
String weather = effect.getString("weathertype");
boolean biomesCheck = effect.getBoolean("biomes-check");
ConfigurationSection particle = effect.getConfigurationSection("particle");
ConfigurationSection sound = effect.getConfigurationSection("sound");
List<String> biomes = effect.getStringList("biomes");
if (checker.weatherCheck(player).equals(weather) & biomes.contains(biome) & biomesCheck){
spawnParticles(particle, player.getLocation(), player);
Bukkit.getLogger().info(String.valueOf(conf.getKeys(false)));
//run spawnParticles n amount of times
soundGenerator(sound, player.getLocation(), player);
}
}
}
Expand Down Expand Up @@ -118,6 +119,7 @@ public void spawnParticlesPassed(ConfigurationSection particle, Location locatio
pb.count(count);
pb.location(location);
pb.offset(deltax, deltay, deltaz);
pb.data(Bukkit.createBlockData(Material.valueOf(particle.getString("particledata"))));
pb.extra(particle.getDouble("speed"));
pb.force(particle.getBoolean("force"));
pb.spawn();
Expand All @@ -127,4 +129,40 @@ public double rando (double min, double max) {
return (double)Math.floor(Math.random()*(max-min+1)+min);
}

public void soundGenerator(ConfigurationSection sound, @NotNull Location location, Player player) {
double max = sound.getInt("radius");
double min = -sound.getInt("radius");
double x = (rando(min, max));
double y = (rando(min, max));
double z = (rando(min, max));
Float volume = Float.parseFloat(sound.getString("pitch"));
Float pitch = Float.parseFloat(sound.getString("pitch"));
String category = sound.getString("category");
String name = sound.getString("name");
Location randoLoc = location.add(x, y, z);

Blockabovecheck check = new Blockabovecheck() {
@Override
public void checker() {
if (sound.getBoolean("blockabovecheck")) {
if (!checker.blockAbove(randoLoc)) {
int a = new Random().nextInt(100);
if (a <= sound.getInt("chance")) {
player.playSound(randoLoc, Sound.valueOf(name), volume, pitch);
} else { }
} else if (checker.blockAbove(randoLoc)) { }
} else {
int a = new Random().nextInt(100);
if (a <= sound.getInt("chance")) {
player.playSound(randoLoc, Sound.valueOf(name), volume, pitch);
}
}
}
};
check.checker();
}

public void entitygenerator() {

}
}
89 changes: 20 additions & 69 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#Weather effect only available in "world"
#lisf ot weathers that are enabled.
#You might want to change this depends on what particle you used. 20 tick = 1 second
ticks: 4
ticks: 1
#how many times to attempt spawning particles every ticks rate above
attempts: 25
attempts: 50
enabled-weather:
#Weather Effect Names
sandstorm:
snow:
#thunder, rain, clear
#not sure if thunder check is working use rain or clear
weathertype: rain
Expand All @@ -31,19 +31,21 @@ enabled-weather:
- UNKNOWN
#particle name to send
#https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html
name: SNOWFLAKE
name: FALLING_DUST
#Leave this alone if not using falling_dust
particledata: SNOW_BLOCK
#particles movement when spawned
delta-x: 2
delta-y: 2
delta-z: 2
delta-x: 0
delta-y: 0
delta-z: 0
#particle speed
speed: 0
speed: 0.25
#particle count
count: 5
#How many blocks from player's current location can the particles spawned up to.
radius: 25
radius: 50
#force spawning particles if true otherwise it will spawn within where player looking at.
force: false
force: true
#Skylight level 0-15 depends on where particle spawned at not player skylightlevel.
#If chances 100, any area with light level 15 will have particles spawned
#chance = Skylightlevel * 100
Expand All @@ -57,68 +59,17 @@ enabled-weather:
cooldown: 4
#Play sound at the location of where the particle spawned
sound:
name:
volume:
pitch:
chance:
summon:
mobs:
- zombies
- skeleton
chance: 5
othervariant:
#thunder, rain, clear
#not sure if thunder check is working use rain or clear
weathertype: rain
blockstate:
#Check if particles should only be spawned inside a biome
biomes-check: true
#list of biome names. Ex: minecraft:badlands, terralith:mirage_isles <-- Datapack Biome name
biomes:
- terralith:mirage_isles
- terralith:amethyst_rainforest
- minecraft:badlands
#More information for particles
#https://minecraft.fandom.com/wiki/Particles
particle:
blockabovecheck: true
#valid block types for air checking can be any material
aircheck: true
blocktype: AIR
#particle name to send
#https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html
name: SOUL_FIRE_FLAME
#particles movement when spawned
delta-x: 2
delta-y: 2
delta-z: 2
#particle speed
speed: 0
#particle count
count: 5
#How many blocks from player's current location can the particles spawned up to.
radius: 25
#force spawning particles if true otherwise it will spawn within where player looking at.
force: false
#Skylight level 0-15 depends on where particle spawned at not player skylightlevel.
#If chances 100, any area with light level 15 will have particles spawned
#chance = Skylightlevel * 100
chances: 100
# **** options below not available yet ****
#Effects given to players
effects:
- blind
#Effect cooldown. Will be reapplied with interval
#Like Players still blind for a while when they left the storm. Cause they need to wash their eyes xd.
cooldown: 4
#Play sound at the location of where the particle spawned
sound:
name:
volume:
pitch:
chance:
#https://papermc.io/javadocs/paper/1.16/org/bukkit/Sound.html
name: ENTITY_HORSE_BREATHE
pitch: 1
radius: 20
volume: 1
chance: 100
summon:
mobs:
- zombies
- skeleton
groundtype:
radius:
chance: 5
87 changes: 18 additions & 69 deletions target/classes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#Weather effect only available in "world"
#lisf ot weathers that are enabled.
#You might want to change this depends on what particle you used. 20 tick = 1 second
ticks: 4
ticks: 1
#how many times to attempt spawning particles every ticks rate above
attempts: 25
attempts: 50
enabled-weather:
#Weather Effect Names
sandstorm:
snow:
#thunder, rain, clear
#not sure if thunder check is working use rain or clear
weathertype: rain
Expand All @@ -31,19 +31,21 @@ enabled-weather:
- UNKNOWN
#particle name to send
#https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html
name: SNOWFLAKE
name: FALLING_DUST
#Leave this alone if not using falling_dust
particledata: SNOW_BLOCK
#particles movement when spawned
delta-x: 2
delta-y: 2
delta-z: 2
delta-x: 0
delta-y: 0
delta-z: 0
#particle speed
speed: 0
speed: 0.25
#particle count
count: 5
#How many blocks from player's current location can the particles spawned up to.
radius: 25
radius: 50
#force spawning particles if true otherwise it will spawn within where player looking at.
force: false
force: true
#Skylight level 0-15 depends on where particle spawned at not player skylightlevel.
#If chances 100, any area with light level 15 will have particles spawned
#chance = Skylightlevel * 100
Expand All @@ -57,66 +59,13 @@ enabled-weather:
cooldown: 4
#Play sound at the location of where the particle spawned
sound:
name:
volume:
pitch:
chance:
summon:
mobs:
- zombies
- skeleton
chance: 5
othervariant:
#thunder, rain, clear
#not sure if thunder check is working use rain or clear
weathertype: rain
blockstate:
#Check if particles should only be spawned inside a biome
biomes-check: true
#list of biome names. Ex: minecraft:badlands, terralith:mirage_isles <-- Datapack Biome name
biomes:
- terralith:mirage_isles
- terralith:amethyst_rainforest
- minecraft:badlands
#More information for particles
#https://minecraft.fandom.com/wiki/Particles
particle:
blockabovecheck: true
#valid block types for air checking can be any material
aircheck: true
blocktype: AIR
#particle name to send
#https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html
name: SOUL_FIRE_FLAME
#particles movement when spawned
delta-x: 2
delta-y: 2
delta-z: 2
#particle speed
speed: 0
#particle count
count: 5
#How many blocks from player's current location can the particles spawned up to.
radius: 25
#force spawning particles if true otherwise it will spawn within where player looking at.
force: false
#Skylight level 0-15 depends on where particle spawned at not player skylightlevel.
#If chances 100, any area with light level 15 will have particles spawned
#chance = Skylightlevel * 100
chances: 100
# **** options below not available yet ****
#Effects given to players
effects:
- blind
#Effect cooldown. Will be reapplied with interval
#Like Players still blind for a while when they left the storm. Cause they need to wash their eyes xd.
cooldown: 4
#Play sound at the location of where the particle spawned
sound:
name:
volume:
pitch:
chance:
#https://papermc.io/javadocs/paper/1.16/org/bukkit/Sound.html
name: ENTITY_HORSE_BREATHE
pitch: 1
radius: 20
volume: 1
chance: 100
summon:
mobs:
- zombies
Expand Down
Binary file modified target/classes/me/dummyperson/weathereffect/Main$1.class
Binary file not shown.
Binary file modified target/classes/me/dummyperson/weathereffect/Main.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion target/classes/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: WeatherEffect
version: 1.0-SNAPSHOT
version: 0.2
main: me.dummyperson.weathereffect.Main
api-version: 1.17
authors: [ Dummyperson ]
Expand Down
4 changes: 2 additions & 2 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Thu Sep 16 14:57:09 AEST 2021
#Thu Sep 16 21:54:46 AEST 2021
groupId=me.dummyperson
artifactId=weathereffect
version=1.0-SNAPSHOT
version=0.2
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ me\dummyperson\weathereffect\Checker.class
me\dummyperson\weathereffect\WeatherEffectTask$1.class
me\dummyperson\weathereffect\WeatherEffectTask.class
me\dummyperson\weathereffect\Main.class
me\dummyperson\weathereffect\WeatherEffectTask$2.class
me\dummyperson\weathereffect\Main$1.class
me\dummyperson\weathereffect\WeatherEffectTask$Blockabovecheck.class

0 comments on commit e0674a2

Please sign in to comment.