Skip to content

Commit

Permalink
Fix menu item ordering [1-9,0]
Browse files Browse the repository at this point in the history
  • Loading branch information
GarethNZ committed Mar 20, 2011
1 parent a6a4519 commit 3cdf3c8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions bin/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: MenuMetaMod

main: com.shawlyne.mc.MenuMetaMod.MenuMetaMod

version: 0.1
19 changes: 14 additions & 5 deletions src/com/shawlyne/mc/MenuMetaMod/MenuMetaModPlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ public void onPlayerChat(PlayerChatEvent pe)
{
// Maybe a response
try{
int response = Integer.parseInt(pe.getMessage());
int response = Integer.parseInt(pe.getMessage()) - 1; // inputs 1-9,0
if( response < 0 ) response = 9; // 0 = the tenth
if( !menu.validResponse(response) )
{
pe.getPlayer().sendMessage(response +" is not a valid option");
pe.getPlayer().sendMessage("Invalid Option " + (response+1));
// Resend menu?
// skip for now (menu still active)
sendMenu(pe.getPlayer(), menu);
}
else
{
Expand Down Expand Up @@ -88,9 +89,17 @@ public void sendMenu(Player p, MetaModMenu menu)
{
playerMenus.put(p, menu);
p.sendMessage("Options: ");
for(int o = 0; o < menu.options.length; o++)
// Num. <OptionText>
// order is 1-9, 0
for(int o = 1; o < (menu.options.length+1); o++)
{
p.sendMessage((o)+". "+menu.options[o]);
if( o < 10 )
p.sendMessage((o)+". "+menu.options[o-1]);
else // Do not allow > 10... 1-9,0
{
p.sendMessage("0. "+menu.options[9]);
break;
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/com/shawlyne/mc/MenuMetaMod/MetaModMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public MetaModMenu(String[] options, String[] commands){// throws Exception {
this.sendTime = new Date().getTime();
}




/*
* Has the menu faded away / anything??
* TODO: remove? not used anyway
Expand Down

0 comments on commit 3cdf3c8

Please sign in to comment.