Skip to content

Commit

Permalink
- Implemented death messages + config
Browse files Browse the repository at this point in the history
  • Loading branch information
CoocooFroggy committed Aug 6, 2020
1 parent 64c69d4 commit 166652b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 4 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 modified out/production/Bomb Lobbers/com/CoocooFroggy/bomblobbers/Main.class
Binary file not shown.
Binary file not shown.
19 changes: 18 additions & 1 deletion src/com/CoocooFroggy/bomblobbers/DeathListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.HashMap;
import java.util.List;

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

public class DeathListener implements Listener {
Expand Down Expand Up @@ -46,7 +47,7 @@ public void onPlayerDeath(EntityDamageEvent event) {
//Heals them to full
player.setHealth(20);

//Respawns them
//Respawns them if they died under Y 0
if (player.getLocation().getY() < 0) {
Location spawn = player.getWorld().getSpawnLocation();
player.teleport(spawn);
Expand All @@ -57,6 +58,22 @@ public void onPlayerDeath(EntityDamageEvent event) {

//Tells them they died
player.sendTitle(ChatColor.RED + "You died!", null, 8, 30, 8);

//Tells everyone they died
//Get their team and color
ChatColor deadColor = ChatColor.GRAY;
if (currentTeam.equalsIgnoreCase("blue")) {
deadColor = ChatColor.BLUE;
} else if (currentTeam.equalsIgnoreCase("red")) {
deadColor = ChatColor.RED;
} else if (currentTeam.equalsIgnoreCase("green")) {
deadColor = ChatColor.GREEN;
}
if (plugin.getConfig().getBoolean("death-messages.current")) {
for (Player currentPlayer : player.getServer().getOnlinePlayers()) {
currentPlayer.sendMessage(deadColor + "" + ChatColor.BOLD + player.getDisplayName() + ChatColor.RESET + " " + ChatColor.RED + "died!");
}
}
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions src/com/CoocooFroggy/bomblobbers/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public boolean configCommand(CommandSender sender, Command command, String label
if (sender.hasPermission("bomblobbers.config")) {
if (args.length < 2) {
//If "/bl config"
sender.sendMessage(ChatColor.RED + "Specify what to config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown, items, reset");
sender.sendMessage(ChatColor.RED + "Specify what to config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown, items, deathmessages, reset");
return false;
}
if (args[1].equalsIgnoreCase("velocity")) {
Expand Down Expand Up @@ -415,6 +415,21 @@ else if (args[1].equalsIgnoreCase("items")) {
return false;
}
}
else if (args[1].equalsIgnoreCase("deathmessages")) {
//If "/bl config deathmessages"
if (args.length > 3) {
sender.sendMessage(ChatColor.RED + "Usage: " + ChatColor.GOLD + "/bomblobbers config deathmessages");
}
boolean deathMessages = !plugin.getConfig().getBoolean("death-messages.current");
plugin.getConfig().set("death-messages.current", deathMessages);
if (deathMessages) {
sender.sendMessage(ChatColor.GREEN + "Enabled death messages");
} else {
sender.sendMessage(ChatColor.RED + "Disabled death messages");
}
plugin.saveConfig();
return true;
}
else if (args[1].equalsIgnoreCase("reset")) {
//If "/bl config reset"
//Delete the config and make a new one
Expand All @@ -427,7 +442,7 @@ else if (args[1].equalsIgnoreCase("reset")) {
}
else {
//If "/bl config ____"
sender.sendMessage(ChatColor.RED + "That is not a valid config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown, items, reset");
sender.sendMessage(ChatColor.RED + "That is not a valid config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown, items, deathmessages, reset");
return false;
}
} else {
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", "directhitdamage", "waterdamage", "countdown", "items", "reset");
return Arrays.asList("velocity", "givetime", "cooldown", "directhitvelocity", "directhitdamage", "waterdamage", "countdown", "items", "reset", "deathmessages");
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ water-damage:
current: 3
countdown:
current: 5
death-messages:
current: true
startingItems:
- ==: org.bukkit.inventory.ItemStack
v: 2567
Expand Down

0 comments on commit 166652b

Please sign in to comment.