Add files via upload

This commit is contained in:
ImproperIssues
2023-01-15 11:53:29 -08:00
committed by GitHub
parent 9b84b6d1e2
commit 9d3153dfd8
26 changed files with 350 additions and 20 deletions

Binary file not shown.

View File

@@ -2,19 +2,23 @@ package me.improper.explosionscontrol;
import me.improper.explosionscontrol.commands.Commands; import me.improper.explosionscontrol.commands.Commands;
import me.improper.explosionscontrol.commands.Tabs; import me.improper.explosionscontrol.commands.Tabs;
import me.improper.explosionscontrol.data.Config;
import me.improper.explosionscontrol.data.ExplosionConfigFile; import me.improper.explosionscontrol.data.ExplosionConfigFile;
import me.improper.explosionscontrol.data.ExplosionToggle; import me.improper.explosionscontrol.data.ExplosionToggle;
import me.improper.explosionscontrol.events.OnExplode; import me.improper.explosionscontrol.events.OnExplode;
import me.improper.explosionscontrol.events.OnInventory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public final class ExplosionsControl extends JavaPlugin { public final class ExplosionsControl extends JavaPlugin {
public static String STARTER = Config.getPluginPrefix();
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
Bukkit.broadcastMessage(""); Bukkit.broadcastMessage(STARTER + "aExplosionsControls has loaded!");
ExplosionConfigFile.setup(); ExplosionConfigFile.setup();
ExplosionToggle.setup(); ExplosionToggle.setup();
@@ -24,6 +28,7 @@ public final class ExplosionsControl extends JavaPlugin {
// Events // Events
Bukkit.getPluginManager().registerEvents(new OnExplode(),this); Bukkit.getPluginManager().registerEvents(new OnExplode(),this);
Bukkit.getPluginManager().registerEvents(new OnInventory(),this);
// Commands // Commands
getCommand("explosions").setExecutor(new Commands()); getCommand("explosions").setExecutor(new Commands());
@@ -35,6 +40,8 @@ public final class ExplosionsControl extends JavaPlugin {
@Override @Override
public void onDisable() { public void onDisable() {
// Plugin shutdown logic // Plugin shutdown logic
Bukkit.broadcastMessage(STARTER + "cExplosionsControls has disabled! If this isn't a reload please consider restarting" +
" as your server is no longer being protected from explosions!");
} }
public static Plugin getInstance() { public static Plugin getInstance() {

View File

@@ -1,8 +1,11 @@
package me.improper.explosionscontrol.commands; package me.improper.explosionscontrol.commands;
import me.improper.explosionscontrol.ExplosionsControl;
import me.improper.explosionscontrol.data.ExplosionConfigFile; import me.improper.explosionscontrol.data.ExplosionConfigFile;
import me.improper.explosionscontrol.data.ExplosionToggle; import me.improper.explosionscontrol.data.ExplosionToggle;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -21,11 +24,13 @@ public class Commands implements CommandExecutor {
} }
case "loadworlds" -> { case "loadworlds" -> {
ExplosionConfigFile.setup(); ExplosionConfigFile.setup();
sender.sendMessage(ExplosionsControl.STARTER + "6Reloaded all world explosions configurations!");
for (World world : Bukkit.getWorlds()) sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.YELLOW + world.getName());
return true; return true;
} }
} }
} catch (Exception exception) { } catch (Exception exception) {
String message = ChatColor.DARK_RED + "Command error: " + ChatColor.RED; String message = ExplosionsControl.STARTER + ChatColor.DARK_RED + "Command error: " + ChatColor.RED;
if (exception instanceof NullPointerException) message += "Command contains a null value!"; if (exception instanceof NullPointerException) message += "Command contains a null value!";
else if (exception instanceof IndexOutOfBoundsException) message += "Incomplete command! Not enough information was provided!"; else if (exception instanceof IndexOutOfBoundsException) message += "Incomplete command! Not enough information was provided!";
else message += exception.getMessage(); else message += exception.getMessage();

View File

@@ -0,0 +1,19 @@
package me.improper.explosionscontrol.data;
import me.improper.explosionscontrol.ExplosionsControl;
import org.bukkit.configuration.file.FileConfiguration;
public class Config {
private static FileConfiguration CONFIG = ExplosionsControl.getInstance().getConfig();
/**
* This will return the current plugin prefix set
* in the plugin's configuration file.
*
* @return The plugin prefix
*/
public static String getPluginPrefix() {
return CONFIG.getString("config.plugin.prefix");
}
}

View File

@@ -9,9 +9,36 @@ public enum ExplosionMode implements Serializable {
DYNAMIC(2), DYNAMIC(2),
NONE(3); NONE(3);
/**
* Attempts to get an explosion mode from the index value provided.
*
* @param index int
* @return An explosion mode from the index value.
*/
public static ExplosionMode fromIndex(int index) {
for (ExplosionMode mode : ExplosionMode.values()) if (index == mode.getIndex()) return mode;
return fromIndex(0);
}
private final int index; private final int index;
/**
* Constructs an explosion mode from the index provided.
*
* @param index int
*/
ExplosionMode(int index) { ExplosionMode(int index) {
this.index = index; this.index = index;
} }
/**
* Returns the index of the current explosion mode value.
* A number out of bounds will be read as 0!
*
* @return The index of the current value
*/
public int getIndex() {
if (index >= ExplosionMode.values().length || index < 0) return 0;
return index;
}
} }

View File

@@ -1,12 +1,17 @@
package me.improper.explosionscontrol.data; package me.improper.explosionscontrol.data;
import me.improper.explosionscontrol.ExplosionsControl;
import me.improper.explosionscontrol.other.Item; import me.improper.explosionscontrol.other.Item;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.List;
public class ExplosionToggle { public class ExplosionToggle {
public static Inventory EXPLOSIONMENU; public static Inventory EXPLOSIONMENU;
@@ -17,19 +22,83 @@ public class ExplosionToggle {
* through this menu! * through this menu!
*/ */
public static void setup() { public static void setup() {
Inventory menu = Bukkit.createInventory(null,54,"Explosions"); Inventory menu = Bukkit.createInventory(null,54, ExplosionsControl.STARTER + "eConfigurations");
Item reload = new Item(new ItemStack(Material.COMPASS)); Item reload = new Item(new ItemStack(Material.COMPASS));
reload.setDisplayName(ChatColor.AQUA + "Load Worlds"); reload.setDisplayName(ChatColor.AQUA + "Load Worlds");
Item blank = new Item(new ItemStack(Material.DARK_OAK_SIGN));
blank.setDisplayName(ChatColor.DARK_GRAY + "" + ChatColor.ITALIC + "Blank World");
Item b = new Item(new ItemStack(Material.BLACK_STAINED_GLASS_PANE));
b.setDisplayName(" ");
Item o = new Item(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE));
o.setDisplayName(" ");
Item y = new Item(new ItemStack(Material.YELLOW_STAINED_GLASS_PANE));
y.setDisplayName(" ");
Item a = new Item(new ItemStack(Material.AIR));
menu.setContents(new ItemStack[]{ menu.setContents(new ItemStack[]{
y,y,y,y,y,y,y,y,reload,
b,b,b,b,b,b,b,b,b,
o,a,a,a,a,a,a,a,o,
o,a,a,a,a,a,a,a,o,
o,a,a,a,a,a,a,a,o,
o,o,o,o,o,o,o,o,o
}); });
menu.addItem(reload); for (World world : Bukkit.getWorlds()) {
Item worldIcon = new Item(new ItemStack(Material.OAK_SIGN));
worldIcon.setDisplayName(ChatColor.GRAY + world.getName());
worldIcon.setLore(List.of(ChatColor.DARK_GRAY + "" + ChatColor.ITALIC + "(Click to config)"));
menu.setItem(menu.firstEmpty(),worldIcon);
}
while (menu.firstEmpty() != -1) menu.setItem(menu.firstEmpty(),blank);
EXPLOSIONMENU = menu; EXPLOSIONMENU = menu;
} }
public static void openToggleMenu(Player player, World world) {
Inventory menu = Bukkit.createInventory(null,54, ExplosionsControl.STARTER + "eEditing " + world.getName());
ExplosionConfiguration configuration = new ExplosionConfiguration(world);
Item b = new Item(new ItemStack(Material.BLACK_STAINED_GLASS_PANE));
b.setDisplayName(" ");
Item o = new Item(new ItemStack(Material.ORANGE_STAINED_GLASS_PANE));
o.setDisplayName(" ");
Item y = new Item(new ItemStack(Material.YELLOW_STAINED_GLASS_PANE));
y.setDisplayName(" ");
Item blank = new Item(new ItemStack(Material.LIGHT_GRAY_STAINED_GLASS_PANE));
blank.setDisplayName(" ");
Item a = new Item(new ItemStack(Material.AIR));
Item back = new Item(new ItemStack(Material.ARROW));
back.setDisplayName("<< Back to world menu");
// toggles
Item creeper = new Item(new ItemStack(Material.CREEPER_HEAD));
creeper.setDisplayName(configuration.getAllowCreeper().name());
Item crystal = new Item(new ItemStack(Material.END_CRYSTAL));
crystal.setDisplayName(configuration.getAllowCrystal().name());
Item tnt = new Item(new ItemStack(Material.TNT));
tnt.setDisplayName(configuration.getAllowTnt().name());
Item minecart = new Item(new ItemStack(Material.TNT_MINECART));
minecart.setDisplayName(configuration.getAllowMinecart().name());
Item anchor = new Item(new ItemStack(Material.RESPAWN_ANCHOR));
anchor.setDisplayName(configuration.getAllowBlock().name());
Item fireball = new Item(new ItemStack(Material.FIRE_CHARGE));
fireball.setDisplayName(configuration.getAllowFireball().name());
Item wither = new Item(new ItemStack(Material.WITHER_SKELETON_SKULL));
wither.setDisplayName(configuration.getAllowWither().name());
menu.setContents(new ItemStack[]{
back,y,y,y,y,y,y,y,y,
b,b,b,b,b,b,b,b,b,
o,a,a,a,a,a,a,a,o,
o,creeper,crystal,tnt,minecart,anchor,fireball,wither,o,
o,a,a,a,a,a,a,a,o,
o,o,o,o,o,o,o,o,o
});
while (menu.firstEmpty() != -1) menu.setItem(menu.firstEmpty(),blank);
player.openInventory(menu);
}
} }

View File

@@ -3,10 +3,7 @@ package me.improper.explosionscontrol.events;
import me.improper.explosionscontrol.data.ExplosionConfiguration; import me.improper.explosionscontrol.data.ExplosionConfiguration;
import me.improper.explosionscontrol.data.ExplosionMode; import me.improper.explosionscontrol.data.ExplosionMode;
import me.improper.explosionscontrol.other.ServerSound; import me.improper.explosionscontrol.other.ServerSound;
import org.bukkit.Location; import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
@@ -26,14 +23,13 @@ public class OnExplode implements Listener {
Location loc = e.getLocation(); Location loc = e.getLocation();
World world = loc.getWorld(); World world = loc.getWorld();
ExplosionConfiguration configuration = new ExplosionConfiguration(world); ExplosionConfiguration configuration = new ExplosionConfiguration(world);
ServerSound explosion = new ServerSound(e.getLocation(),Sound.ENTITY_GENERIC_EXPLODE,10,0.7F);
switch (entity.getType()) { switch (entity.getType()) {
case PRIMED_TNT -> { case PRIMED_TNT -> {
switch (configuration.getAllowTnt()) { switch (configuration.getAllowTnt()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -47,7 +43,7 @@ public class OnExplode implements Listener {
switch (configuration.getAllowFireball()) { switch (configuration.getAllowFireball()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -61,7 +57,7 @@ public class OnExplode implements Listener {
switch (configuration.getAllowCreeper()) { switch (configuration.getAllowCreeper()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -75,7 +71,7 @@ public class OnExplode implements Listener {
switch (configuration.getAllowCrystal()) { switch (configuration.getAllowCrystal()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -89,7 +85,7 @@ public class OnExplode implements Listener {
switch (configuration.getAllowMinecart()) { switch (configuration.getAllowMinecart()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -103,7 +99,7 @@ public class OnExplode implements Listener {
switch (configuration.getAllowWither()) { switch (configuration.getAllowWither()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -122,12 +118,11 @@ public class OnExplode implements Listener {
Location loc = block.getLocation(); Location loc = block.getLocation();
World world = loc.getWorld(); World world = loc.getWorld();
ExplosionConfiguration configuration = new ExplosionConfiguration(world); ExplosionConfiguration configuration = new ExplosionConfiguration(world);
ServerSound explosion = new ServerSound(block.getLocation(),Sound.ENTITY_GENERIC_EXPLODE,10,0.7F);
switch (configuration.getAllowBlock()) { switch (configuration.getAllowBlock()) {
case DISABLED -> { case DISABLED -> {
e.setCancelled(true); e.setCancelled(true);
explosion.playWithin(5000); fakeExplode(loc);
} }
case NONE -> { case NONE -> {
e.setCancelled(true); e.setCancelled(true);
@@ -205,4 +200,17 @@ public class OnExplode implements Listener {
fb.setVelocity(vector); fb.setVelocity(vector);
block.setType(Material.AIR); block.setType(Material.AIR);
} }
/**
* Plays a sound and displays the explosion particles at the provided world location.
*
* @param location Location
*/
public static void fakeExplode(Location location) {
ServerSound explosion = new ServerSound(location,Sound.ENTITY_GENERIC_EXPLODE,10,0.7F);
explosion.playWithin(5000);
location.getWorld().spawnParticle(Particle.EXPLOSION_LARGE,location,1,1,1,1,0);
location.getWorld().spawnParticle(Particle.EXPLOSION_HUGE,location,1,1,1,1,0);
location.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL,location,5,1,1,1,0);
}
} }

View File

@@ -0,0 +1,118 @@
package me.improper.explosionscontrol.events;
import me.improper.explosionscontrol.ExplosionsControl;
import me.improper.explosionscontrol.data.ExplosionConfigFile;
import me.improper.explosionscontrol.data.ExplosionConfiguration;
import me.improper.explosionscontrol.data.ExplosionMode;
import me.improper.explosionscontrol.data.ExplosionToggle;
import me.improper.explosionscontrol.other.Item;
import me.improper.explosionscontrol.other.ServerSound;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
public class OnInventory implements Listener {
@EventHandler
public static void InventoryClickEvent(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
Inventory inv = e.getClickedInventory();
String title = e.getView().getTitle();
try {
Item item = new Item(e.getCurrentItem());
ServerSound reload = new ServerSound(p.getLocation(),Sound.BLOCK_ENCHANTMENT_TABLE_USE,10,10);
ServerSound click = new ServerSound(p.getLocation(),Sound.UI_BUTTON_CLICK,10,1);
ServerSound edit = new ServerSound(p.getLocation(),Sound.ITEM_DYE_USE,10,10);
if (title.contains(ExplosionsControl.STARTER + "eConfigurations")) {
if (inv.getType().equals(InventoryType.PLAYER)) return;
e.setCancelled(true);
if (item.getDisplayName().equals(" ")) return;
if (item.getDisplayName().equals(ChatColor.AQUA + "Load Worlds")) {
p.closeInventory();
ExplosionConfigFile.setup();
ExplosionToggle.setup();
p.openInventory(ExplosionToggle.EXPLOSIONMENU);
reload.play(p);
return;
}
if (item.getType().equals(Material.DARK_OAK_SIGN)) return;
if (item.getType().equals(Material.OAK_SIGN)) {
World world = Bukkit.getWorld(item.getDisplayName().replaceAll(ChatColor.GRAY + "",""));
ExplosionToggle.openToggleMenu(p,world);
click.play(p);
}
}
if (title.contains(ExplosionsControl.STARTER + "eEditing ")) {
if (inv.getType().equals(InventoryType.PLAYER)) return;
e.setCancelled(true);
if (item.getDisplayName().equals(" ")) return;
if (item.getType().equals(Material.DARK_OAK_SIGN)) return;
if (item.getDisplayName().equals("<< Back to world menu")) {
p.openInventory(ExplosionToggle.EXPLOSIONMENU);
click.play(p);
return;
}
World world = Bukkit.getWorld(title.substring((ExplosionsControl.STARTER + "eEditing ").length()));
ExplosionConfiguration configuration = new ExplosionConfiguration(world);
switch (item.getType()) {
case FIRE_CHARGE -> {
configuration.setAllowFireball(ExplosionMode.fromIndex(configuration.getAllowFireball().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case CREEPER_HEAD -> {
configuration.setAllowCreeper(ExplosionMode.fromIndex(configuration.getAllowCreeper().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case TNT -> {
configuration.setAllowTnt(ExplosionMode.fromIndex(configuration.getAllowTnt().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case TNT_MINECART -> {
configuration.setAllowMinecart(ExplosionMode.fromIndex(configuration.getAllowMinecart().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case WITHER_SKELETON_SKULL -> {
configuration.setAllowWither(ExplosionMode.fromIndex(configuration.getAllowWither().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case END_CRYSTAL -> {
configuration.setAllowCrystal(ExplosionMode.fromIndex(configuration.getAllowCrystal().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
case RESPAWN_ANCHOR -> {
configuration.setAllowBlock(ExplosionMode.fromIndex(configuration.getAllowBlock().getIndex() + 1));
configuration.save();
ExplosionToggle.setup();
ExplosionToggle.openToggleMenu(p,world);
edit.play(p);
}
}
}
} catch (Exception exception) {}
}
}

View File

@@ -14,6 +14,16 @@ public class ServerSound {
private float volume; private float volume;
private float pitch; private float pitch;
/**
* Constructs a new sound, this aims to add more methods to
* the Bukkit APIs Sound class, as they don't have many
* methods to use.
*
* @param location Location
* @param sound Sound
* @param volume float
* @param pitch float
*/
public ServerSound(Location location, Sound sound, float volume, float pitch) { public ServerSound(Location location, Sound sound, float volume, float pitch) {
this.location = location; this.location = location;
this.sound = sound; this.sound = sound;
@@ -22,14 +32,29 @@ public class ServerSound {
} }
/**
* Plays a sound to a player but at the store location
*
* @param player Player
*/
public void play(Player player) { public void play(Player player) {
player.playSound(this.location,this.sound,this.volume,this.pitch); player.playSound(this.location,this.sound,this.volume,this.pitch);
} }
/**
* Plays a sound to a player but at the player's location
*
* @param player Player
*/
public void playAt(Player player) { public void playAt(Player player) {
player.playSound(player.getLocation(),this.sound,this.volume,this.pitch); player.playSound(player.getLocation(),this.sound,this.volume,this.pitch);
} }
/**
* Plays the sound to all players within a distance, but at the stored location.
*
* @param distance double
*/
public void playWithin(double distance) { public void playWithin(double distance) {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (p != null && p.getWorld() == this.location.getWorld() && p.getLocation().distanceSquared(this.location) < distance) { if (p != null && p.getWorld() == this.location.getWorld() && p.getLocation().distanceSquared(this.location) < distance) {
@@ -38,6 +63,11 @@ public class ServerSound {
} }
} }
/**
* Plays the sound to all players within a distance, but at the players' location.
*
* @param distance double
*/
public void playWithinAt(double distance) { public void playWithinAt(double distance) {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
if (p != null && p.getWorld() == this.location.getWorld() && p.getLocation().distanceSquared(this.location) < distance) { if (p != null && p.getWorld() == this.location.getWorld() && p.getLocation().distanceSquared(this.location) < distance) {
@@ -46,14 +76,28 @@ public class ServerSound {
} }
} }
/**
* Plays the sound to all players on the server, but at the stored location.
*/
public void playAll() { public void playAll() {
for (Player p : Bukkit.getOnlinePlayers()) p.playSound(this.location,this.sound,this.volume,this.pitch); for (Player p : Bukkit.getOnlinePlayers()) p.playSound(this.location,this.sound,this.volume,this.pitch);
} }
/**
* Plays the sound to all players on the server, but at the players' location.
*/
public void playAllAt() { public void playAllAt() {
for (Player p : Bukkit.getOnlinePlayers()) p.playSound(p.getLocation(),this.sound,this.volume,this.pitch); for (Player p : Bukkit.getOnlinePlayers()) p.playSound(p.getLocation(),this.sound,this.volume,this.pitch);
} }
/**
* Repeats a sound to a player, but at the stored location.
*
* @param player Player
* @param times int
* @param tickDelay int
*/
public void repeat(Player player, int times, int tickDelay) { public void repeat(Player player, int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;
@@ -69,6 +113,13 @@ public class ServerSound {
}.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay); }.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay);
} }
/**
* Repeats a sound to a player, but at the player's location.
*
* @param player Player
* @param times int
* @param tickDelay int
*/
public void repeatAt(Player player, int times, int tickDelay) { public void repeatAt(Player player, int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;
@@ -84,6 +135,12 @@ public class ServerSound {
}.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay); }.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay);
} }
/**
* Repeats a sound to all players on the server, but at the stored location.
*
* @param times int
* @param tickDelay int
*/
public void repeatAll(int times, int tickDelay) { public void repeatAll(int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;
@@ -99,6 +156,12 @@ public class ServerSound {
}.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay); }.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay);
} }
/**
* Repeats a sound to all players on the server, but at the players' location.
*
* @param times int
* @param tickDelay int
*/
public void repeatAllAt(int times, int tickDelay) { public void repeatAllAt(int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;
@@ -114,6 +177,13 @@ public class ServerSound {
}.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay); }.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay);
} }
/**
* Repeats a sound to all players within a radius, but at the stored location.
*
* @param radius double
* @param times int
* @param tickDelay int
*/
public void repeatAll(double radius,int times, int tickDelay) { public void repeatAll(double radius,int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;
@@ -129,6 +199,13 @@ public class ServerSound {
}.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay); }.runTaskTimer(ExplosionsControl.getInstance(),0,tickDelay);
} }
/**
* Repeats a sound to all players within a radius, but at the players' location.
*
* @param distance double
* @param times int
* @param tickDelay int
*/
public void repeatAllAt(double distance, int times, int tickDelay) { public void repeatAllAt(double distance, int times, int tickDelay) {
new BukkitRunnable() { new BukkitRunnable() {
int i = 0; int i = 0;