From 43beadfcc185d3e36c18b6a85071d2a0ac5c31ea Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sun, 30 Oct 2016 00:46:14 -0400 Subject: [PATCH] Started commenting my code so that I can work on a javadoc --- src/alisolarflare/uhc/AddToUHC.java | 28 +++++++++++-- src/alisolarflare/uhc/UHCMatch.java | 7 +++- src/alisolarflare/uhc/UHCSubPlugin.java | 54 ++++++++++++------------- 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/src/alisolarflare/uhc/AddToUHC.java b/src/alisolarflare/uhc/AddToUHC.java index c0ae425..b084d4b 100644 --- a/src/alisolarflare/uhc/AddToUHC.java +++ b/src/alisolarflare/uhc/AddToUHC.java @@ -5,14 +5,34 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +/** + * This class handles the specific command /addToUHC which, in-game, + * adds a player to a specific UltraHardcore match, that is defined + * by the constructor: {@linkplain #AddToUHC(UHCMatch)} + * @author Alisolarflare + */ public class AddToUHC implements CommandExecutor{ - private UHCMemoryUnit generalMemory; + private UHCMatch generalMemory; - public AddToUHC(UHCSubPlugin uhcSubPlugin){ - this.generalMemory = uhcSubPlugin.generalMemory; + + /** + * Constructor for this AddToUHC + * @param generalMemory The Memory Unit for the current match + */ + public AddToUHC(UHCMatch generalMemory){ + this.generalMemory = generalMemory; } + + /** + * Activated function when /addtoUHC <> is typed in-game + * @param sender CommandSender which sent the command /addToUHC + * @param command Command object created when /addToUHC is called in-game + * @param label Name of the command called + * @param args Arguments passed onto /addToUHC by the player + */ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + //INPUT SANITATION if (!(sender instanceof Player)){ sender.sendMessage("You must be a player to use this command!"); return false; @@ -25,6 +45,8 @@ public class AddToUHC implements CommandExecutor{ if (args.length <= 1){ sender.sendMessage("You must supply at least one playername"); } + + //Adds players to memory for (int i = 0; i > args.length; i++){ generalMemory.addPlayerToMatch(player); } diff --git a/src/alisolarflare/uhc/UHCMatch.java b/src/alisolarflare/uhc/UHCMatch.java index 24a1e62..3eff51d 100644 --- a/src/alisolarflare/uhc/UHCMatch.java +++ b/src/alisolarflare/uhc/UHCMatch.java @@ -5,7 +5,12 @@ import java.util.List; import org.bukkit.entity.Player; -public class UHCMemoryUnit { +/** + * Class that contains the data for a single UltraHardcore Match, + * which represents a single game. + * @author Alisolarflare + */ +public class UHCMatch { private List matchPlayerUsernames = new ArrayList(); public void addPlayerToMatch(String playername){ diff --git a/src/alisolarflare/uhc/UHCSubPlugin.java b/src/alisolarflare/uhc/UHCSubPlugin.java index 1116633..3841da1 100644 --- a/src/alisolarflare/uhc/UHCSubPlugin.java +++ b/src/alisolarflare/uhc/UHCSubPlugin.java @@ -1,27 +1,27 @@ -package alisolarflare.uhc; - -import alisolarflare.AliPresents; - -public class UHCSubPlugin { - public AliPresents plugin; - public UHCMemoryUnit generalMemory; - - public UHCSubPlugin(AliPresents plugin){ - this.plugin = plugin; - } - public void register(){ - registerCommands(); - registerListeners(); - registerMemoryUnits(); - } - private void registerListeners() { - } - private void registerCommands() { - // TODO Auto-generated method stub - plugin.getCommand("addToUHC").setExecutor(new AddToUHC(this)); - } - private void registerMemoryUnits(){ - generalMemory = new UHCMemoryUnit(); - } - -} +package alisolarflare.uhc; + +import alisolarflare.AliPresents; + +public class UHCSubPlugin { + public AliPresents plugin; + public UHCMatch generalMemory; + + public UHCSubPlugin(AliPresents plugin){ + this.plugin = plugin; + } + public void register(){ + registerCommands(); + registerListeners(); + registerMemoryUnits(); + } + private void registerListeners() { + } + private void registerCommands() { + // TODO Auto-generated method stub + plugin.getCommand("addToUHC").setExecutor(new AddToUHC(this.generalMemory)); + } + private void registerMemoryUnits(){ + generalMemory = new UHCMatch(); + } + +}