-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04db794
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PayDay is a Sponge plugin made by HassanS6000. | ||
|
||
You can check out PayDay's forum posting on Sponge: https://forums.spongepowered.org/ | ||
And the developer's website, NEGAFINITY: http://negafinity.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package io.github.hsyyid.payday; | ||
|
||
import java.io.File; | ||
import java.math.BigDecimal; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import ninja.leaping.configurate.commented.CommentedConfigurationNode; | ||
import ninja.leaping.configurate.loader.ConfigurationLoader; | ||
|
||
import org.slf4j.Logger; | ||
import org.spongepowered.api.Game; | ||
import org.spongepowered.api.entity.player.Player; | ||
import org.spongepowered.api.event.Subscribe; | ||
import org.spongepowered.api.event.state.ServerStartedEvent; | ||
import org.spongepowered.api.plugin.Plugin; | ||
import org.spongepowered.api.service.config.DefaultConfig; | ||
import org.spongepowered.api.service.permission.Subject; | ||
import org.spongepowered.api.service.permission.option.OptionSubject; | ||
import org.spongepowered.api.service.scheduler.SchedulerService; | ||
import org.spongepowered.api.service.scheduler.TaskBuilder; | ||
import org.spongepowered.api.text.Texts; | ||
import org.spongepowered.api.text.format.TextColors; | ||
|
||
import com.erigitic.config.AccountManager; | ||
import com.erigitic.main.TotalEconomy; | ||
import com.google.inject.Inject; | ||
|
||
@Plugin(id = "PayDay", name = "PayDay", version = "0.1", dependencies = "required-after:TotalEconomy") | ||
public class Main | ||
{ | ||
public static Game game = null; | ||
|
||
@Inject | ||
private Logger logger; | ||
|
||
public Logger getLogger() | ||
{ | ||
return logger; | ||
} | ||
|
||
@Inject | ||
@DefaultConfig(sharedRoot = true) | ||
private File dConfig; | ||
|
||
@Inject | ||
@DefaultConfig(sharedRoot = true) | ||
private ConfigurationLoader<CommentedConfigurationNode> confManager; | ||
|
||
@Subscribe | ||
public void onServerStart(ServerStartedEvent event) | ||
{ | ||
getLogger().info("PayDay loading..."); | ||
|
||
game = event.getGame(); | ||
|
||
SchedulerService scheduler = game.getScheduler(); | ||
TaskBuilder taskBuilder = scheduler.createTaskBuilder(); | ||
|
||
taskBuilder.execute(new Runnable() | ||
{ | ||
public void run() | ||
{ | ||
for(Player player : game.getServer().getOnlinePlayers()) | ||
{ | ||
Subject subject = player.getContainingCollection().get(player.getIdentifier()); | ||
|
||
if (subject instanceof OptionSubject) | ||
{ | ||
OptionSubject optionSubject = (OptionSubject) subject; | ||
double pay = Double.parseDouble(optionSubject.getOption("pay").or("")); | ||
|
||
player.sendMessage(Texts.of(TextColors.GOLD, "[PayDay]: ", TextColors.GRAY, "It's PayDay! Here is your salary of " + pay + " dollars! Enjoy!")); | ||
|
||
TotalEconomy totalEconomy = (TotalEconomy) game.getPluginManager().getPlugin("TotalEconomy").get().getInstance(); | ||
AccountManager accountManager = totalEconomy.getAccountManager(); | ||
BigDecimal amount = new BigDecimal(pay); | ||
accountManager.addToBalance(player.getUniqueId(), amount, true); | ||
} | ||
} | ||
} | ||
}).interval(1, TimeUnit.HOURS).name("PayDay - Pay").submit(game.getPluginManager().getPlugin("PayDay").get().getInstance()); | ||
|
||
getLogger().info("-----------------------------"); | ||
getLogger().info("PayDay was made by HassanS6000!"); | ||
getLogger().info("Please post all errors on the Sponge Thread or on GitHub!"); | ||
getLogger().info("Have fun, and enjoy! :D"); | ||
getLogger().info("-----------------------------"); | ||
getLogger().info("PayDay loaded!"); | ||
} | ||
} |