Skip to content

Commit

Permalink
Added project
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Aug 28, 2015
0 parents commit 04db794
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.txt
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
90 changes: 90 additions & 0 deletions src/main/java/io/github/hsyyid/payday/Main.java
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!");
}
}

0 comments on commit 04db794

Please sign in to comment.