package gaiseric.zarhasar; import java.util.Iterator; 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.plugin.java.JavaPlugin; public final class ZarHasar extends JavaPlugin implements CommandExecutor { public void onEnable() { this.getLogger().info("ZarPlugin enabled!"); this.getCommand("zarhasar").setExecutor(this); } public void onDisable() { this.getLogger().info("ZarPlugin disabled!"); } public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!command.getName().equalsIgnoreCase("zarhasar")) { return false; } else { if (args.length == 1) { String diceNotation = args[0]; try { String[] parts = diceNotation.split("d"); int count = Integer.parseInt(parts[0]); int sides = Integer.parseInt(parts[1]); if (count > 0 && sides > 0) { int total = 0; for(int i = 0; i < count; ++i) { int roll = (int)(Math.random() * (double)sides) + 1; total += roll; } Iterator var14 = Bukkit.getOnlinePlayers().iterator(); while(var14.hasNext()) { Player player = (Player)var14.next(); Player p = (Player)sender; if (player.getLocation().distance(p.getLocation()) <= 5.0D) { player.sendMessage(total); } } } else { sender.sendMessage("Both count and sides must be positive integers."); } } catch (ArrayIndexOutOfBoundsException | NumberFormatException var13) { sender.sendMessage("Invalid dice notation."); } } else { sender.sendMessage("Usage: /zarhasar "); sender.sendMessage("Example: /zarhasar 2d6"); } return true; } } }