Skip to content

Commit

Permalink
Implemented config for custom water damage and custom countdown amount
Browse files Browse the repository at this point in the history
  • Loading branch information
CoocooFroggy committed Aug 5, 2020
1 parent 8555991 commit b710eb1
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 16 deletions.
Binary file modified out/artifacts/Bomb_Lobbers_jar/Bomb Lobbers.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 6 additions & 1 deletion src/com/CoocooFroggy/bomblobbers/DirectHitChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ public void trackTNT(Entity tntEntity, Player thrower) {

//Make player go brrr
currentPlayer.setVelocity(tntEntity.getVelocity().multiply(directHitVelocity));

//Get config damage to player
int directHitDamage = plugin.getConfig().getInt("direct-hit-damage.current");

//Damage player in a new task, since it cannot be run asynchronously
Player finalCurrentPlayer = currentPlayer;
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
finalCurrentPlayer.damage(6);
finalCurrentPlayer.damage(directHitDamage);
}
});
thrower.playSound(thrower.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
Expand Down
73 changes: 71 additions & 2 deletions src/com/CoocooFroggy/bomblobbers/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ else if (args[1].equalsIgnoreCase("cooldown")) {
getLogger().info("[Bomb Lobbers] Error: " + e);
return false;
}
//If "/bl config velocity [int]"
//If "/bl config cooldown [int]"
plugin.getConfig().set("cooldown.current", newCooldown);
plugin.saveConfig();
sender.sendMessage(ChatColor.GREEN + "Successfully set the new cooldown to " + ChatColor.GOLD + newCooldown + ChatColor.GREEN + "!");
Expand Down Expand Up @@ -297,9 +297,78 @@ else if (args[1].equalsIgnoreCase("directhitvelocity")) {
sender.sendMessage(ChatColor.GREEN + "Successfully set the new direct hit velocity to " + ChatColor.GOLD + newDirectHitVelocity + ChatColor.GREEN + "!");
return true;
}
else if (args[1].equalsIgnoreCase("directhitdamage")) {
if (args.length < 3) {
//If "/bl config directhitdamage"
sender.sendMessage(ChatColor.RED + "Specify the amount as an integer.");
return false;
}
//If "/bl config directhitdamage _"
int newDirectHitDamage;
try {
//If "/bl config directhitdamage [int]"
newDirectHitDamage = Integer.parseInt(args[2]);
} catch (Exception e) {
//If "/bl config directhitdamage [Not an int]"
sender.sendMessage(ChatColor.RED + "That is not a number. Please specify a number for the direct hit damage.");
getLogger().info("[Bomb Lobbers] Error: " + e);
return false;
}
//If "/bl config directhitdamage [int]"
plugin.getConfig().set("direct-hit-damage.current", newDirectHitDamage);
plugin.saveConfig();
sender.sendMessage(ChatColor.GREEN + "Successfully set the new direct hit damage to " + ChatColor.GOLD + newDirectHitDamage + ChatColor.GREEN + "!");
return true;
}
else if (args[1].equalsIgnoreCase("waterdamage")) {
if (args.length < 3) {
//If "/bl config waterdamage"
sender.sendMessage(ChatColor.RED + "Specify the amount as an integer.");
return false;
}
//If "/bl config waterdamage _"
int newWaterDamage;
try {
//If "/bl config waterdamage [int]"
newWaterDamage = Integer.parseInt(args[2]);
} catch (Exception e) {
//If "/bl config waterdamage [Not an int]"
sender.sendMessage(ChatColor.RED + "That is not a number. Please specify a number for the water damage.");
getLogger().info("[Bomb Lobbers] Error: " + e);
return false;
}
//If "/bl config directhitdamage [int]"
plugin.getConfig().set("water-damage.current", newWaterDamage);
plugin.saveConfig();
sender.sendMessage(ChatColor.GREEN + "Successfully set the new water damage to " + ChatColor.GOLD + newWaterDamage + ChatColor.GREEN + "!");
return true;
}
else if (args[1].equalsIgnoreCase("countdown")) {
if (args.length < 3) {
//If "/bl config countdown"
sender.sendMessage(ChatColor.RED + "Specify the amount as an integer.");
return false;
}
//If "/bl config countdown _"
int newCountdown;
try {
//If "/bl config countdown [int]"
newCountdown = Integer.parseInt(args[2]);
} catch (Exception e) {
//If "/bl config countdown [Not an int]"
sender.sendMessage(ChatColor.RED + "That is not a number. Please specify a number for the countdown.");
getLogger().info("[Bomb Lobbers] Error: " + e);
return false;
}
//If "/bl config countdown [int]"
plugin.getConfig().set("countdown.current", newCountdown);
plugin.saveConfig();
sender.sendMessage(ChatColor.GREEN + "Successfully set the new countdown to " + ChatColor.GOLD + newCountdown + ChatColor.GREEN + "!");
return true;
}
else {
//If "/bl config ____"
sender.sendMessage(ChatColor.RED + "That is not a valid config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity");
sender.sendMessage(ChatColor.RED + "That is not a valid config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown");
return false;
}
}
Expand Down
20 changes: 11 additions & 9 deletions src/com/CoocooFroggy/bomblobbers/StartGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.util.List;

import static com.CoocooFroggy.bomblobbers.Main.plugin;
import static org.bukkit.Bukkit.getLogger;

public class StartGame {
Expand Down Expand Up @@ -56,7 +57,7 @@ public boolean startGame(Player player) {
ItemStack enderPearlItemStack = new ItemStack(Material.ENDER_PEARL, 3);

//Put everyone in adventure, clear their inventories (except for armor), give them items
Bukkit.getScheduler().runTask(Main.plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
for (Player currentPlayer : playerList) {
Expand All @@ -79,12 +80,13 @@ public void run() {
}
});

//MARK: Countdown
//Get countdown amount
int countdown = plugin.getConfig().getInt("countdown.current");


//Countdown code
for (int j = 5; j > 0; j--) {
for (int j = countdown; j > 0; j--) {
for (int i = 0; i < playerList.size(); i++) {
if (j == 5) {
if (j == countdown) {
playerList.get(i).sendTitle("Game starting in", null, 10, 25, 0);
playerList.get(i).sendTitle(null, j + "", 10, 25, 0);
} else {
Expand All @@ -105,7 +107,7 @@ public void run() {
}

//Put everyone in survival
Bukkit.getScheduler().runTask(Main.plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
for (Player currentPlayer : playerList) {
Expand All @@ -124,7 +126,7 @@ public void run() {
WinDetector.winnerFound = false;

//Start up WinDetector asynchronously
Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
WinDetector.winDetector();
Expand All @@ -138,7 +140,7 @@ public void run() {
}

//Start giving TNT asynchronously
Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, new Runnable() {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
TNTDistributor.distribute();
Expand Down Expand Up @@ -191,7 +193,7 @@ public void run() {
DeathListener.teamsAndAliveCount.put("green", 0);

//Put everyone in creative, clear their inventories (except for armor)
Bukkit.getScheduler().runTask(Main.plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
for (Player currentPlayer : playerList) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/CoocooFroggy/bomblobbers/TabCompleter.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
return Arrays.asList("enable", "disable", "start", "stop", "changeteam", "config");
} else if (args.length == 2) {
if (args[0].contains("config")) {
return Arrays.asList("velocity", "givetime", "cooldown", "directhitvelocity");
return Arrays.asList("velocity", "givetime", "cooldown", "directhitvelocity", "directhitdamage", "waterdamage", "countdown");
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/com/CoocooFroggy/bomblobbers/WaterListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import static com.CoocooFroggy.bomblobbers.Main.plugin;

public class WaterListener implements Listener {
@EventHandler
public boolean onWater(PlayerMoveEvent event) {
Expand All @@ -23,8 +25,11 @@ public boolean onWater(PlayerMoveEvent event) {
Material currentBlock = event.getPlayer().getLocation().getBlock().getType();
//If that block is water
if (currentBlock == Material.WATER) {
//Damage then for 1 1/2 hearts (3 hp)
event.getPlayer().damage(3);
//Get config water damage
int waterDamage = plugin.getConfig().getInt("water-damage.current");

//Damage them for config amount
event.getPlayer().damage(waterDamage);
}
return true;
}
Expand Down
11 changes: 10 additions & 1 deletion src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ cooldown:
current: 3
direct-hit-velocity:
default: 3
current: 3
current: 3
direct-hit-damage:
default: 6
current: 6
water-damage:
default: 3
current: 3
countdown:
default: 5
current: 5

0 comments on commit b710eb1

Please sign in to comment.