Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 399fe91

Browse files
committed
Updated stocks commands, made them a little easier to work with.
1 parent 72cc56a commit 399fe91

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed
0 Bytes
Binary file not shown.
441 Bytes
Binary file not shown.

bin/server/MapleStocks.class

167 Bytes
Binary file not shown.

dist/Commands.jar

200 Bytes
Binary file not shown.

dist/Orpheus.jar

255 Bytes
Binary file not shown.

src/client/command/PlayerCommands.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ License, or (at your option) any later version.
3333
import tools.DatabaseConnection;
3434
import tools.MapleLogger;
3535
import tools.MaplePacketCreator;
36+
import tools.Output;
3637
import tools.Pair;
3738
import client.MapleCharacter;
3839
import client.MapleClient;
@@ -448,11 +449,20 @@ public static boolean execute(MapleClient c, String[] sub, char heading) {
448449
chr.message(" check - one argument, ticker, checks value of a stock");
449450
chr.message(" portfolio - no arguments, checks your portfolio");
450451
}
451-
} catch (Exception e) {
452+
} catch (NumberFormatException e) {
453+
chr.message("Something went wrong! :(");
454+
chr.message("Usage: ");
455+
chr.message(" @stocks [option] [arguments]");
456+
chr.message("Type '@stocks help' to see the options.");
457+
} catch (IndexOutOfBoundsException e) {
452458
chr.message("Something went wrong! :(");
453459
chr.message("Usage: ");
454460
chr.message(" @stocks [option] [arguments]");
455461
chr.message("Type '@stocks help' to see the options.");
462+
} catch (Exception e) {
463+
chr.message("We apologize! Something went seriously wrong! D:");
464+
Output.print("MapleStocks experienced an error with " + chr.getName() + ".");
465+
MapleLogger.print(MapleLogger.EXCEPTION_CAUGHT, e);
456466
}
457467
} else if (!ServerConstants.USE_MAPLE_STOCKS) {
458468
chr.message("MapleStocks is disabled by the server.");

src/server/MapleStocks.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public String tickerOf(int id) {
6868
return stocks.get(id - 1).getTicker();
6969
}
7070

71-
public int idOf(String ticker) {
71+
public int indexOf(String ticker) {
7272
int n = 0;
7373
for (MapleStock ms : stocks) {
7474
if (ms.getTicker() == ticker) {
@@ -79,10 +79,18 @@ public int idOf(String ticker) {
7979
return -1;
8080
}
8181

82-
public int idOf(MapleStocks ms) {
82+
public int indexOf(MapleStock ms) {
8383
return stocks.indexOf(ms);
8484
}
8585

86+
public int idOf(String ticker) {
87+
return indexOf(ticker) + 1;
88+
}
89+
90+
public int idOf(MapleStock ms) {
91+
return indexOf(ms) + 1;
92+
}
93+
8694
public ArrayList<MapleStock> getStocks() {
8795
return stocks;
8896
}

0 commit comments

Comments
 (0)