Skip to content

Commit

Permalink
Fixed a *huge* bug that went unnoticed, where config values could be …
Browse files Browse the repository at this point in the history
…null. Also added "/bomblobbers config reset" to reset all config changes
  • Loading branch information
CoocooFroggy committed Aug 6, 2020
1 parent 6e6d1f3 commit d7eaf08
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 18 deletions.
Binary file modified out/artifacts/Bomb_Lobbers_jar/Bomb Lobbers.jar
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.
Binary file not shown.
19 changes: 12 additions & 7 deletions src/com/CoocooFroggy/bomblobbers/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -414,15 +415,19 @@ else if (args[1].equalsIgnoreCase("items")) {
return false;
}
}
// else if (args[1].equalsIgnoreCase("reset")) {
// //If "/bl config reset"
// Player player = (Player) sender;
// ManageItems.manageItems(player);
// return true;
// }
else if (args[1].equalsIgnoreCase("reset")) {
//If "/bl config reset"
//Delete the config and make a new one
File configFile = new File(plugin.getDataFolder(), "config.yml");
configFile.delete();
saveDefaultConfig();
reloadConfig();
sender.sendMessage("All config values reset.");
return true;
}
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");
sender.sendMessage(ChatColor.RED + "That is not a valid config. Options are: " + ChatColor.GOLD + "velocity, givetime, cooldown, directhitvelocity, directhitdamage, waterdamage, countdown, items, reset");
return false;
}
} else {
Expand Down
20 changes: 19 additions & 1 deletion src/com/CoocooFroggy/bomblobbers/StartGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

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

public class StartGame {
Expand Down Expand Up @@ -133,7 +136,22 @@ public void run() {
//Perform to all players
for (int i = 0; i < playerList.size(); i++) {
//Remove the pane placeholder
playerList.get(i).getInventory().removeItem(ManageItems.tntPlaceholder);
if (tntPlaceholder == null) {
//TNT placeholder itemstack
tntPlaceholder = new ItemStack(Material.RED_STAINED_GLASS_PANE, 1);
//TNT placeholder meta
ItemMeta tntPlaceholderMeta = tntPlaceholder.getItemMeta();
//TNT Display name
tntPlaceholderMeta.setDisplayName(ChatColor.RED + "TNT");
//TNT placeholder lore
List<String> tntPlaceholderLore = new ArrayList<>();
tntPlaceholderLore.add("TNT will always go in the first slot.");
//Set the lore to the Meta
tntPlaceholderMeta.setLore(tntPlaceholderLore);
//Set the Meta to the ItemStack
tntPlaceholder.setItemMeta(tntPlaceholderMeta);
}
playerList.get(i).getInventory().removeItem(tntPlaceholder);
}

//Start giving TNT asynchronously
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");
return Arrays.asList("velocity", "givetime", "cooldown", "directhitvelocity", "directhitdamage", "waterdamage", "countdown", "items", "reset");
}
}
}
Expand Down
38 changes: 29 additions & 9 deletions src/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
plugin:
enabled:
enabled: true
throw-velocity:
default: 1.5
current: 1.5
give-time:
default: 5
current: 5
cooldown:
default: 3
current: 3
direct-hit-velocity:
default: 3
current: 3
direct-hit-damage:
default: 6
current: 6
water-damage:
default: 3
current: 3
countdown:
default: 5
current: 5
current: 5
startingItems:
- ==: org.bukkit.inventory.ItemStack
v: 2567
type: RED_STAINED_GLASS_PANE
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: §cTNT
lore:
- TNT will always go in the first slot.
- ==: org.bukkit.inventory.ItemStack
v: 2567
type: SCAFFOLDING
amount: 64
- ==: org.bukkit.inventory.ItemStack
v: 2567
type: SCAFFOLDING
amount: 64
- ==: org.bukkit.inventory.ItemStack
v: 2567
type: ENDER_PEARL
amount: 3
- null
- null
- null
- null
- null

0 comments on commit d7eaf08

Please sign in to comment.