As soon as it hits the first element in the array, it's terminating.
There are a ton of ways to do it, this is just one.Code:if (System.binarySearch(COIN_SPAWN, itemId) == -1 { //spawn item }
|
Fixed.
As soon as it hits the first element in the array, it's terminating.
There are a ton of ways to do it, this is just one.Code:if (System.binarySearch(COIN_SPAWN, itemId) == -1 { //spawn item }
Code:import java.util.stream.IntStream;Code:try { int[] COINS_SPAWN = {4151, 11802}; int itemId = Integer.parseInt(args[0]); int amount = Misc.stringToInt(args[1]); boolean PERMITTED = IntStream.of(COINS_SPAWN).anyMatch(r -> r == itemId); if(itemId > 15101) { c.sendMessage("This item does not exist!"); return; } if (!PERMITTED) { c.sendMessage("You are not allowed to spawn this item."); return; } c.getItems().addItem(itemId, amount); } catch (NumberFormatException nfe) { c.sendMessage("Improper use of the command; '::item itemid amount'."); } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |