Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
EconomyLite v1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Flibio committed Aug 11, 2015
1 parent 9ecfcd9 commit 93d516c
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>EconomyLite</groupId>
<artifactId>EconomyLite</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<name>EconomyLite</name>
<description>An economy plugin for Sponge</description>
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/Commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AddCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/Commands/BalanceCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BalanceCommand implements CommandExecutor{
private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BusinessDeleteCommand implements CommandExecutor {
private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BusinessInviteAcceptCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BusinessInviteCommand implements CommandExecutor {
private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BusinessLeaveCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BusinessOwnersCommand implements CommandExecutor{
private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BusinessRegisterCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class BusinessTransferCommand implements CommandExecutor{
private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
4 changes: 2 additions & 2 deletions src/me/Flibio/EconomyLite/Commands/PayCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public class PayCommand implements CommandExecutor{
private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
public CommandResult execute(final CommandSource source, final CommandContext args)
throws CommandException {
//Run in a seperate thread
taskBuilder.execute(new Runnable() {
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/Commands/PayOverrideCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PayOverrideCommand implements CommandExecutor{
private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private BusinessManager businessManager = new BusinessManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/Commands/RemoveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RemoveCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
2 changes: 1 addition & 1 deletion src/me/Flibio/EconomyLite/Commands/SetCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SetCommand implements CommandExecutor {

private TextUtils textUtils = new TextUtils();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Override
public CommandResult execute(CommandSource source, CommandContext args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class PlayerJoinListener {
private FileManager fileManager = new FileManager();
private ScoreboardUtils scoreboardUtils = new ScoreboardUtils();
private PlayerManager playerManager = new PlayerManager();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().getTaskBuilder();
private TaskBuilder taskBuilder = Main.access.game.getScheduler().createTaskBuilder();

@Subscribe
public void onPlayerJoin(PlayerJoinEvent event) {
Expand Down
11 changes: 9 additions & 2 deletions src/me/Flibio/EconomyLite/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import com.google.common.base.Optional;
import com.google.inject.Inject;

@Plugin(id = "EconomyLite", name = "EconomyLite", version = "1.0.1")
@Plugin(id = "EconomyLite", name = "EconomyLite", version = "1.0.2")
public class Main {

@Inject
Expand Down Expand Up @@ -113,7 +113,7 @@ public void onServerInitialize(InitializationEvent event) {
logger.error("Error enabling plugin metrics!");
}
//Reset business confirmations
game.getScheduler().getTaskBuilder().execute(new Runnable() {
game.getScheduler().createTaskBuilder().execute(new Runnable() {
public void run() {
fileManager.loadFile(FileType.BUSINESS_DATA);
ConfigurationNode root = fileManager.getFile(FileType.BUSINESS_DATA);
Expand All @@ -133,6 +133,8 @@ public void onServerStarted(ServerStartedEvent event) {
//Check for an update
String latest = httpUtils.requestData("https://api.github.com/repos/Flibio/EconomyLite/releases/latest");
String version = jsonUtils.getVersion(latest).replace("v", "");
String changes = httpUtils.requestData("https://flibio.github.io/EconomyLite/changelogs/"+version.replaceAll("\\.", "-")+".txt");
String[] iChanges = changes.split(";");
String url = jsonUtils.getUrl(latest);
boolean prerelease = jsonUtils.isPreRelease(latest);
//Make sure the latest update is not a prerelease
Expand All @@ -142,6 +144,11 @@ public void onServerStarted(ServerStartedEvent event) {
if(textUtils.versionCompare(version, currentVersion)>0) {
logger.info("EconomyLite v"+version+" is now available to download!");
logger.info(url);
for(String change : iChanges) {
if(!change.trim().isEmpty()) {
logger.info("+ "+change);
}
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/me/Flibio/EconomyLite/Runnables/UpdateRunnable.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.Flibio.EconomyLite.Runnables;


import me.Flibio.EconomyLite.Main;
import me.Flibio.EconomyLite.Utils.HttpUtils;
import me.Flibio.EconomyLite.Utils.JsonUtils;
Expand All @@ -25,6 +24,8 @@ public void run() {
//Get the data
String latest = httpUtils.requestData("https://api.github.com/repos/Flibio/EconomyLite/releases/latest");
String version = jsonUtils.getVersion(latest).replace("v", "");
String changes = httpUtils.requestData("https://flibio.github.io/EconomyLite/changelogs/"+version.replaceAll("\\.", "-")+".txt");
String[] iChanges = changes.split(";");
String url = jsonUtils.getUrl(latest);
boolean prerelease = jsonUtils.isPreRelease(latest);
//Make sure the latest update is not a prerelease
Expand All @@ -33,6 +34,11 @@ public void run() {
String currentVersion = Main.access.version;
if(textUtils.versionCompare(version, currentVersion)>0) {
player.sendMessage(textUtils.updateAvailable(version, url));
for(String change : iChanges) {
if(!change.trim().isEmpty()) {
player.sendMessage(textUtils.change(change));
}
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/me/Flibio/EconomyLite/Utils/ScoreboardUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public ScoreboardUtils() {
* @return Completed scoreboard
*/
public Scoreboard createScoreboard(String objectiveName, Text displayName, HashMap<Text, Integer> objectiveValues) {
Scoreboard board = game.getRegistry().getScoreboardBuilder().build();
Objective obj = game.getRegistry().getObjectiveBuilder().name(objectiveName).criterion(Criteria.DUMMY).displayName(displayName).build();
Scoreboard board = game.getRegistry().createScoreboardBuilder().build();
Objective obj = game.getRegistry().createObjectiveBuilder().name(objectiveName).criterion(Criteria.DUMMY).displayName(displayName).build();
for(Text name : objectiveValues.keySet()) {
int value = objectiveValues.get(name);
obj.getScore(name).setScore(value);
Expand Down
8 changes: 8 additions & 0 deletions src/me/Flibio/EconomyLite/Utils/TextUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ public Text owner(String owner) {
return text;
}

public Text change(String change) {
Text text = Texts.builder(" + ").color(TextColors.YELLOW).build();

text = text.builder().append(basicText(change,TextColors.GREEN)).build();

return text;
}

public String getDownloadUrl(String jsonRelease) {
return jsonRelease.split("browser_download_url")[1].split("}",2)[0].replaceAll("\"", "").replaceFirst(":", "").trim();
}
Expand Down

0 comments on commit 93d516c

Please sign in to comment.