Skip to content

Commit

Permalink
Support for better commands in the extras-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
rlf committed Dec 26, 2014
1 parent 03d1252 commit 180b21d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/java/us/talabrek/ultimateskyblock/SkyBlockMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,10 @@ private boolean isExtraMenuAction(Player player, ItemStack currentItem) {
if (perm != null) {
boolean hasPerm = VaultHandler.checkPerm(player, perm, world);
if ((hasPerm && !not) || (!hasPerm && not)) {
player.performCommand(cmd);
skyBlock.execCommand(player, cmd);
}
} else {
player.performCommand(cmd);
skyBlock.execCommand(player, cmd);
}
} else {
uSkyBlock.log(Level.INFO, "\u00a7a[uSkyBlock] Malformed menu " + title + ", invalid command : " + command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,8 @@ private boolean giveReward(Player player, Challenge challenge) {
}
}
for (String cmd : reward.getCommands()) {
String command = cmd.replaceAll("\\{playerName\\}", player.getDisplayName())
.replaceAll("\\{position\\}", player.getLocation().toString()) // Figure out what this should be
.replaceAll("\\{challenge\\}", challengeName);
if (command.contains("{party}")) {
for (String member : skyBlock.getIslandInfo(playerInfo).getMembers()) {
skyBlock.execCommand(player, command.replaceAll("\\{party\\}", member));
}
} else {
skyBlock.execCommand(player, command);
}
String command = cmd.replaceAll("\\{challenge\\}", challengeName);
skyBlock.execCommand(player, command);
}
player.getInventory().addItem(reward.getItemReward().toArray(new ItemStack[0]));
playerInfo.completeChallenge(challengeName);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/us/talabrek/ultimateskyblock/uSkyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,20 @@ public void execCommand(Player player, String command) {
if (!isSkyAssociatedWorld(player.getWorld())) {
return;
}
command = command
.replaceAll("\\{playerName\\}", player.getDisplayName())
.replaceAll("\\{position\\}", player.getLocation().toString()); // Figure out what this should be
if (command.contains("{party}")) {
PlayerInfo playerInfo = getPlayerInfo(player);
for (String member : getIslandInfo(playerInfo).getMembers()) {
doExecCommand(player, command.replaceAll("\\{party\\}", member));
}
} else {
doExecCommand(player, command);
}
}

private void doExecCommand(Player player, String command) {
if (command.startsWith("op:")) {
if (player.isOp()) {
player.performCommand(command.substring(3).trim());
Expand Down

0 comments on commit 180b21d

Please sign in to comment.