Skip to content

Commit

Permalink
Creative check
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenoyia committed Apr 25, 2017
1 parent b21e388 commit 5892c70
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/main/java/com/xpgaming/xPBottles/BottleXP.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,29 @@ public class BottleXP implements CommandExecutor {
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if(src instanceof Player) {
Player player = (Player) src;
int totalEXP = player.get(Keys.TOTAL_EXPERIENCE).orElseGet(() -> 0);
if(totalEXP >= 11) {
double bottlesNeeded = Math.ceil(totalEXP / 11);
createBottles(bottlesNeeded, player);
player.sendMessage(Text.of("§f[§axP//§f] §aSuccessfully exchanged your EXP for §2" + bottlesNeeded + "§a bottles!"));
player.offer(Keys.TOTAL_EXPERIENCE, 0);
} else {
player.sendMessage(Text.of("§f[§cxP//§f] §cYou need at least 11 XP to convert to bottles!"));
}
return CommandResult.success();
} else {
src.sendMessage(Text.of("[xP//] You need to be a player to run this command!"));
return CommandResult.success();
if(player.gameMode().get() == GameModes.SURVIVAL) {
int totalEXP = player.get(Keys.TOTAL_EXPERIENCE).orElseGet(() -> 0);
if(totalEXP >= 11) {
double bottlesNeeded = Math.ceil(totalEXP / 11);
createBottles(bottlesNeeded, player);
if(bottlesNeeded == 1) {
player.sendMessage(Text.of("§f[§axP//§f] §aSuccessfully exchanged your EXP for §2" + (int)bottlesNeeded + "§a bottle!"));
} else player.sendMessage(Text.of("§f[§axP//§f] §aSuccessfully exchanged your EXP for §2" + (int)bottlesNeeded + "§a bottles!"));
player.offer(Keys.TOTAL_EXPERIENCE, 0);
} else {
player.sendMessage(Text.of("§f[§cxP//§f] §cYou need at least 11 XP to convert to bottles!"));
}
return CommandResult.success();
} else {
player.sendMessage(Text.of("§f[§cxP//§f] §cYou need to be in Survival mode to use this!"));
return CommandResult.success();
}
}
else {
src.sendMessage(Text.of("[xP//] You need to be a player to run this command!"));
return CommandResult.success();
}
}
}

public void createBottles(double amount, Player player) {
double stacks = 0;
Expand Down

0 comments on commit 5892c70

Please sign in to comment.