diff --git a/pom.xml b/pom.xml index bf42974..c128aca 100644 --- a/pom.xml +++ b/pom.xml @@ -5,8 +5,8 @@ 4.0.0 me.dummyperson - weathereffect - 0.3 + WeatherEffect + 0.4 jar WeatherEffect diff --git a/src/main/java/me/dummyperson/weathereffect/Checker.java b/src/main/java/me/dummyperson/weathereffect/Checker.java index 3910850..b6d5b1e 100644 --- a/src/main/java/me/dummyperson/weathereffect/Checker.java +++ b/src/main/java/me/dummyperson/weathereffect/Checker.java @@ -72,4 +72,8 @@ public String airCheck (Location location) { String airchecker = location.getBlock().getType().name(); return airchecker; } + + public Boolean groundCheck (Location location, int chances) { + return false; + } } diff --git a/src/main/java/me/dummyperson/weathereffect/Main.java b/src/main/java/me/dummyperson/weathereffect/Main.java index 538a229..37c0188 100644 --- a/src/main/java/me/dummyperson/weathereffect/Main.java +++ b/src/main/java/me/dummyperson/weathereffect/Main.java @@ -3,13 +3,14 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; -public final class Main extends JavaPlugin implements Listener { +public final class Main extends JavaPlugin implements CommandExecutor, Listener { @Override public void onEnable() { @@ -19,35 +20,36 @@ public void onEnable() { saveDefaultConfig(); runnable(); reloadConfig(); - this.getLogger().info("&bWeathereEffect Enabled!"); + this.getLogger().info(ChatColor.LIGHT_PURPLE + "[ " + ChatColor.AQUA + "WeathereEffect" + ChatColor.LIGHT_PURPLE + " ]" + ChatColor.GREEN + " ⁑ Enabled!"); + getCommand("weathereffect").setExecutor(this); } @Override public void onDisable() { - this.getLogger().info("&4WeathereEffect Disabled!"); + this.getLogger().info(ChatColor.LIGHT_PURPLE + "[ " + ChatColor.AQUA + "WeathereEffect" + ChatColor.LIGHT_PURPLE + " ]" + ChatColor.RED + " ⁑ Disabled!"); // Plugin shutdown logic } - public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) { - Player player = (Player) sender; - if (!sender.hasPermission("weathereffect.reload") || !sender.isOp()) { - if (alias.equalsIgnoreCase("weathereffect")) { - if (args.length == 0) { - sender.sendMessage(ChatColor.GREEN + "To reload do /weathereffect reload"); - } else if (args[0].equalsIgnoreCase("reload")) { - saveDefaultConfig(); - reloadConfig(); - sender.sendMessage(ChatColor.GREEN + "WeatherEffect reloaded!"); + + public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { + if(cmd.getName().equalsIgnoreCase("weathereffect")) { + if(args.length == 0) { + if(sender.hasPermission("weathereffect.player")) { + sender.sendMessage(ChatColor.LIGHT_PURPLE + "[ " + ChatColor.AQUA + "WeathereEffect" + ChatColor.LIGHT_PURPLE + "] " + ChatColor.RED + " ⁑ Unknown commands or No permissions..."); + return true; } - else { - sender.sendMessage(ChatColor.RED + "Unknown Command"); + } + if((args.length == 1) && (args[0].equalsIgnoreCase("reload"))) { + if(sender.hasPermission("weathereffect.reload")) { + reloadConfig(); + sender.sendMessage(ChatColor.LIGHT_PURPLE + "[ " + ChatColor.AQUA + "WeathereEffect" + ChatColor.LIGHT_PURPLE + "] " + ChatColor.GREEN + " ⁑ Reloaded!"); + return true; } } - } else { - sender.sendMessage(ChatColor.RED + "Permission Denied!"); } - return false; - }; + return true; + } + public void runnable() { new BukkitRunnable() { diff --git a/src/main/java/me/dummyperson/weathereffect/WeatherEffectTask.java b/src/main/java/me/dummyperson/weathereffect/WeatherEffectTask.java index 3697b32..2029798 100644 --- a/src/main/java/me/dummyperson/weathereffect/WeatherEffectTask.java +++ b/src/main/java/me/dummyperson/weathereffect/WeatherEffectTask.java @@ -1,14 +1,17 @@ package me.dummyperson.weathereffect; import com.destroystokyo.paper.ParticleBuilder; -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.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.NotNull; +import java.util.Collections; +import java.util.Enumeration; import java.util.List; import java.util.Random; @@ -26,10 +29,14 @@ public void criteriaChecker(Player player, Configuration configuration) { boolean biomesCheck = effect.getBoolean("biomes-check"); ConfigurationSection particle = effect.getConfigurationSection("particle"); ConfigurationSection sound = effect.getConfigurationSection("sound"); + ConfigurationSection summon = effect.getConfigurationSection("summon"); + ConfigurationSection effects = effect.getConfigurationSection("effects"); List biomes = effect.getStringList("biomes"); if (checker.weatherCheck(player).equals(weather) & biomes.contains(biome) & biomesCheck){ spawnParticles(particle, player.getLocation(), player); soundGenerator(sound, player.getLocation(), player); + effectgiver(effects, player.getLocation(), player); + entitygenerator(summon, player.getLocation(), player); } } } @@ -48,40 +55,40 @@ public void spawnParticles(ConfigurationSection particle, Location location, Pla Blockabovecheck check = new Blockabovecheck() { public void checker() { if (particle.getBoolean("blockabovecheck")) { - blockabovechecking(); + blockAboveChecking(); } else if (!particle.getBoolean("blockabovecheck")) { if (checker.skylightChance(randoLoc, particle.getInt("chances"))) { spawnParticlesPassed(particle, randoLoc, player); } else { // Bruh Attempt Fails - retryonfail(); + retryOnFail(); } } else { - retryonfail(); + retryOnFail(); } } - public void blockabovechecking() { + public void blockAboveChecking() { if (!checker.blockAbove(randoLoc)) { spawnParticlesPassed(particle, randoLoc, player); } else if (checker.blockAbove(randoLoc)){ //Do not attempt to spawn particle again if there's a block above - //retryonfail(); + //retryOnFail(); } else { } } - public void retryonfail() { + public void retryOnFail() { double max = particle.getInt("radius"); double min = -particle.getInt("radius"); double x = (rando(min, max)); double y = (rando(min, max)); double z = (rando(min, max)); Location randoLoc = location.add(x, y, z); - airchecking(randoLoc); + airChecking(randoLoc); } - public void airchecking(Location randoLoc) { + public void airChecking(Location randoLoc) { if (particle.getBoolean("aircheck")) { if (particle.getList("blocktypes").contains(checker.airCheck(randoLoc))) { checker(); @@ -162,7 +169,24 @@ public void checker() { check.checker(); } - public void entitygenerator() { + public void entitygenerator(ConfigurationSection summon, Location location, Player player) { } + + public void effectgiver(ConfigurationSection effects, Location location, Player player) { + int duration = effects.getInt("duration"); + int amplifier= effects.getInt("amplifier"); + Boolean ambient = effects.getBoolean("isambient"); + Boolean particles = effects.getBoolean("effectparticle"); + Enumeration e = Collections.enumeration(effects.getStringList("types")); + while(e.hasMoreElements()) { + int type = (Integer.parseInt(e.nextElement())) -1; + int a = new Random().nextInt(100); + if (a <= effects.getInt("chance")) { + PotionEffect potion = new PotionEffect(PotionEffectType.values()[type], duration, amplifier, ambient, particles); + player.addPotionEffect(potion); + } + } + } + } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 50e7888..e3b9d77 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -28,7 +28,6 @@ enabled-weather: aircheck: true blocktypes: - AIR - - UNKNOWN #particle name to send #https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html name: FALLING_DUST @@ -53,10 +52,86 @@ enabled-weather: # **** options below not available yet **** #Effects given to players effects: - - blind + #https://gamedb.gg/games/minecraft/potion-effect-ids/ + types: + - 1 + #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. + duration: 60 + amplifier: 1 + isambient: false + effectparticle: false + chance: 100 + #Play sound at the location of where the particle spawned + sound: + blockabovecheck: true + #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 + snowvariant: + #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 + blocktypes: + - AIR + #particle name to send + #https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html + name: FALLING_DUST + #Leave this alone if not using falling_dust + particledata: SAND + #particles movement when spawned + delta-x: 0 + delta-y: 0 + delta-z: 0 + #particle speed + speed: 0.25 + #particle count + count: 5 + #How many blocks from player's current location can the particles spawned up to. + radius: 50 + #force spawning particles if true otherwise it will spawn within where player looking at. + 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 + chances: 100 + # **** options below not available yet **** + #Effects given to players + effects: + #https://gamedb.gg/games/minecraft/potion-effect-ids/ + types: + - 1 #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 + #Like Players still blind for a while when they left the storm. Cause they need to wash their eyes xd. + duration: 60 + amplifier: 1 + isambient: false + effectparticle: false + chance: 100 #Play sound at the location of where the particle spawned sound: blockabovecheck: true diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 218d09b..50fd0dc 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,3 +5,9 @@ api-version: 1.17 authors: [ Dummyperson ] description: Generate Customizable Particle at certain biomes. Support for Datapack. website: www.breadstick.info + +commands: + weathereffect: + description: WeatherEffect reload command + permission: weathereffect.player + usage: / \ No newline at end of file diff --git a/target/classes/config.yml b/target/classes/config.yml index 69c7497..e3b9d77 100644 --- a/target/classes/config.yml +++ b/target/classes/config.yml @@ -28,7 +28,6 @@ enabled-weather: aircheck: true blocktypes: - AIR - - UNKNOWN #particle name to send #https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html name: FALLING_DUST @@ -53,10 +52,86 @@ enabled-weather: # **** options below not available yet **** #Effects given to players effects: - - blind + #https://gamedb.gg/games/minecraft/potion-effect-ids/ + types: + - 1 + #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. + duration: 60 + amplifier: 1 + isambient: false + effectparticle: false + chance: 100 + #Play sound at the location of where the particle spawned + sound: + blockabovecheck: true + #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 + snowvariant: + #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 + blocktypes: + - AIR + #particle name to send + #https://papermc.io/javadocs/paper/1.17/org/bukkit/Particle.html + name: FALLING_DUST + #Leave this alone if not using falling_dust + particledata: SAND + #particles movement when spawned + delta-x: 0 + delta-y: 0 + delta-z: 0 + #particle speed + speed: 0.25 + #particle count + count: 5 + #How many blocks from player's current location can the particles spawned up to. + radius: 50 + #force spawning particles if true otherwise it will spawn within where player looking at. + 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 + chances: 100 + # **** options below not available yet **** + #Effects given to players + effects: + #https://gamedb.gg/games/minecraft/potion-effect-ids/ + types: + - 1 #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 + #Like Players still blind for a while when they left the storm. Cause they need to wash their eyes xd. + duration: 60 + amplifier: 1 + isambient: false + effectparticle: false + chance: 100 #Play sound at the location of where the particle spawned sound: blockabovecheck: true @@ -70,4 +145,6 @@ enabled-weather: mobs: - zombies - skeleton + groundtype: + radius: chance: 5 \ No newline at end of file diff --git a/target/classes/me/dummyperson/weathereffect/Checker.class b/target/classes/me/dummyperson/weathereffect/Checker.class index e28c48d..c486367 100644 Binary files a/target/classes/me/dummyperson/weathereffect/Checker.class and b/target/classes/me/dummyperson/weathereffect/Checker.class differ diff --git a/target/classes/me/dummyperson/weathereffect/Main$1.class b/target/classes/me/dummyperson/weathereffect/Main$1.class index 544c182..207a395 100644 Binary files a/target/classes/me/dummyperson/weathereffect/Main$1.class and b/target/classes/me/dummyperson/weathereffect/Main$1.class differ diff --git a/target/classes/me/dummyperson/weathereffect/Main.class b/target/classes/me/dummyperson/weathereffect/Main.class index fd61d44..8cc00d9 100644 Binary files a/target/classes/me/dummyperson/weathereffect/Main.class and b/target/classes/me/dummyperson/weathereffect/Main.class differ diff --git a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$1.class b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$1.class index 2f4dcde..86125a7 100644 Binary files a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$1.class and b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$1.class differ diff --git a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$2.class b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$2.class index 3180250..cd16444 100644 Binary files a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$2.class and b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask$2.class differ diff --git a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask.class b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask.class index aad29ea..3e63c00 100644 Binary files a/target/classes/me/dummyperson/weathereffect/WeatherEffectTask.class and b/target/classes/me/dummyperson/weathereffect/WeatherEffectTask.class differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index de56669..3a21049 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -1,7 +1,13 @@ name: WeatherEffect -version: 0.2 +version: 1.0-SNAPSHOT main: me.dummyperson.weathereffect.Main api-version: 1.17 authors: [ Dummyperson ] description: Generate Customizable Particle at certain biomes. Support for Datapack. website: www.breadstick.info + +commands: + weathereffect: + description: WeatherEffect reload command + permission: weathereffect.player + usage: / \ No newline at end of file diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index 9c88c59..15535de 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Thu Sep 16 21:54:46 AEST 2021 +#Fri Sep 17 02:16:18 AEST 2021 groupId=me.dummyperson -artifactId=weathereffect -version=0.2 +artifactId=WeatherEffect +version=0.4