Skip to content

Commit

Permalink
Refactoring a bit and fixing some smaller bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Dec 5, 2014
1 parent 279eaad commit 520231d
Show file tree
Hide file tree
Showing 31 changed files with 2,277 additions and 2,498 deletions.
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/resources</directory>
<directory>src/main/resources</directory>
<includes>
<include>*.yml</include>
<include>README.md</include>
Expand All @@ -38,8 +38,6 @@
</includes>
</resource>
</resources>

<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -88,5 +86,11 @@
<type>jar</type>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
package us.talabrek.ultimateskyblock;

public class Challenge
{
public class Challenge {
private String name;
private long firstCompleted;
private int timesCompleted;
private int timesCompletedSinceTimer;

public Challenge(final String name) {
super();
this.name = name;
this.firstCompleted = 0L;
this.timesCompleted = 0;
}

public Challenge(final String name, final long firstCompleted, final int timesCompleted, final int timesCompletedSinceTimer) {
super();
this.name = name;
this.firstCompleted = firstCompleted;
this.timesCompleted = timesCompleted;
this.timesCompletedSinceTimer = timesCompletedSinceTimer;
}

public String getName() {
return this.name;
}

public long getFirstCompleted() {
return this.firstCompleted;
}

public int getTimesCompleted() {
return this.timesCompleted;
}

public int getTimesCompletedSinceTimer() {
return this.timesCompletedSinceTimer;
}

public void setFirstCompleted(final long newCompleted) {
this.firstCompleted = newCompleted;
this.timesCompletedSinceTimer = 0;
}

public void setTimesCompleted(final int newCompleted) {
this.timesCompleted = newCompleted;
this.timesCompletedSinceTimer = newCompleted;
}

public void addTimesCompleted() {
++this.timesCompleted;
++this.timesCompletedSinceTimer;
}

public void setName(final String name) {
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import org.bukkit.entity.*;
import org.bukkit.*;

public class ChallengesCommand implements CommandExecutor
{
public class ChallengesCommand implements CommandExecutor {
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] split) {
if (!(sender instanceof Player)) {
return false;
Expand All @@ -23,24 +22,21 @@ public boolean onCommand(final CommandSender sender, final Command command, fina
return true;
}
if (split.length == 0) {
player.openInventory(uSkyBlock.getInstance().displayChallengeGUI(player));
}
else if (split.length == 1) {
player.openInventory(uSkyBlock.getInstance().getMenu().displayChallengeGUI(player));
} else if (split.length == 1) {
if (split[0].equalsIgnoreCase("help") || split[0].equalsIgnoreCase("complete") || split[0].equalsIgnoreCase("c")) {
sender.sendMessage(ChatColor.YELLOW + "Use /c <name> to view information about a challenge.");
sender.sendMessage(ChatColor.YELLOW + "Use /c complete <name> to attempt to complete that challenge.");
sender.sendMessage(ChatColor.YELLOW + "Challenges will have different colors depending on if they are:");
sender.sendMessage(String.valueOf(Settings.challenges_challengeColor.replace('&', '\u00a7')) + "Incomplete " + Settings.challenges_finishedColor.replace('&', '\u00a7') + "Completed(not repeatable) " + Settings.challenges_repeatableColor.replace('&', '\u00a7') + "Completed(repeatable) ");
}
else if (uSkyBlock.getInstance().isRankAvailable(player, uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".rankLevel"))) {
sender.sendMessage(Settings.challenges_challengeColor.replace('&', '\u00a7') + "Incomplete " + Settings.challenges_finishedColor.replace('&', '\u00a7') + "Completed(not repeatable) " + Settings.challenges_repeatableColor.replace('&', '\u00a7') + "Completed(repeatable) ");
} else if (uSkyBlock.getInstance().isRankAvailable(player, uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".rankLevel"))) {
sender.sendMessage(ChatColor.YELLOW + "Challenge Name: " + ChatColor.WHITE + split[0].toLowerCase());
sender.sendMessage(ChatColor.YELLOW + uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".description"));
if (uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".type").equalsIgnoreCase("onPlayer")) {
if (uSkyBlock.getInstance().getConfig().getBoolean("options.challenges.challengeList." + split[0].toLowerCase() + ".takeItems")) {
sender.sendMessage(ChatColor.RED + "You will lose all required items when you complete this challenge!");
}
}
else if (uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".type").equalsIgnoreCase("onIsland")) {
} else if (uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".type").equalsIgnoreCase("onIsland")) {
sender.sendMessage(ChatColor.RED + "All required items must be placed on your island!");
}
if (Settings.challenges_ranks.length > 1) {
Expand All @@ -50,33 +46,28 @@ else if (uSkyBlock.getInstance().getConfig().getString("options.challenges.chall
sender.sendMessage(ChatColor.RED + "This Challenge is not repeatable!");
return true;
}
if (Settings.challenges_enableEconomyPlugin && VaultHandler.econ != null) {
if (Settings.challenges_enableEconomyPlugin && VaultHandler.hasEcon()) {
if (uSkyBlock.getInstance().getActivePlayers().get(player.getName()).checkChallenge(split[0].toLowerCase()) > 0) {
sender.sendMessage(ChatColor.YELLOW + "Repeat reward(s): " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatRewardText").replace('&', '\u00a7'));
player.sendMessage(ChatColor.YELLOW + "Repeat exp reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatXpReward"));
sender.sendMessage(ChatColor.YELLOW + "Repeat currency reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatCurrencyReward") + " " + VaultHandler.econ.currencyNamePlural());
}
else {
sender.sendMessage(ChatColor.YELLOW + "Repeat currency reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatCurrencyReward") + " " + VaultHandler.getEcon().currencyNamePlural());
} else {
sender.sendMessage(ChatColor.YELLOW + "Reward(s): " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".rewardText").replace('&', '\u00a7'));
player.sendMessage(ChatColor.YELLOW + "Exp reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".xpReward"));
sender.sendMessage(ChatColor.YELLOW + "Currency reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".currencyReward") + " " + VaultHandler.econ.currencyNamePlural());
sender.sendMessage(ChatColor.YELLOW + "Currency reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".currencyReward") + " " + VaultHandler.getEcon().currencyNamePlural());
}
}
else if (uSkyBlock.getInstance().getActivePlayers().get(player.getName()).checkChallenge(split[0].toLowerCase()) > 0) {
} else if (uSkyBlock.getInstance().getActivePlayers().get(player.getName()).checkChallenge(split[0].toLowerCase()) > 0) {
sender.sendMessage(ChatColor.YELLOW + "Repeat reward(s): " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatRewardText").replace('&', '\u00a7'));
player.sendMessage(ChatColor.YELLOW + "Repeat exp reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".repeatXpReward"));
}
else {
} else {
sender.sendMessage(ChatColor.YELLOW + "Reward(s): " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getString("options.challenges.challengeList." + split[0].toLowerCase() + ".rewardText").replace('&', '\u00a7'));
player.sendMessage(ChatColor.YELLOW + "Exp reward: " + ChatColor.WHITE + uSkyBlock.getInstance().getConfig().getInt("options.challenges.challengeList." + split[0].toLowerCase() + ".xpReward"));
}
sender.sendMessage(ChatColor.YELLOW + "To complete this challenge, use " + ChatColor.WHITE + "/c c " + split[0].toLowerCase());
}
else {
} else {
sender.sendMessage(ChatColor.RED + "Invalid challenge name! Use /c help for more information");
}
}
else if (split.length == 2 && (split[0].equalsIgnoreCase("complete") || split[0].equalsIgnoreCase("c")) && uSkyBlock.getInstance().checkIfCanCompleteChallenge(player, split[1].toLowerCase())) {
} else if (split.length == 2 && (split[0].equalsIgnoreCase("complete") || split[0].equalsIgnoreCase("c")) && uSkyBlock.getInstance().checkIfCanCompleteChallenge(player, split[1].toLowerCase())) {
uSkyBlock.getInstance().giveReward(player, split[1].toLowerCase());
}
return true;
Expand Down
Loading

0 comments on commit 520231d

Please sign in to comment.