mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-11-21 17:45:51 +01:00
SaneEconomyOnlineTime + version bump
This commit is contained in:
parent
c7f58edf44
commit
686b9ef871
@ -19,6 +19,7 @@ I decided that it was time for a change. I wanted a working, updated economy plu
|
||||
* SaneEconomyCore - The main economy provider.
|
||||
* SaneEconomySignShop - A side project written for a specific server. Unsupported.
|
||||
* SaneEconomyMobKills - Another side project for the same server. Unsupported.
|
||||
* SaneEconomyOnlineTime - A replacement for the old plugin TimeIsMoney. Unsupported for now.
|
||||
|
||||
## Development
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
<parent>
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>SaneEconomyCore</artifactId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<groupId>org.appledash</groupId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomyCore</artifactId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
77
SaneEconomyOnlineTime/pom.xml
Normal file
77
SaneEconomyOnlineTime/pom.xml
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<groupId>org.appledash</groupId>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>SaneEconomyOnlineTime</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomyCore</artifactId>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>org.appledash:sanelib</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.appledash.sanelib</pattern>
|
||||
<shadedPattern>org.appledash.saneeconomysignshop.shaded.sanelib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<outputDirectory>../out/</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,46 @@
|
||||
package org.appledash.saneeconomy.onlinetime;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by appledash on 7/13/17.
|
||||
* Blackjack is best pony.
|
||||
*/
|
||||
public class Payout {
|
||||
private final int secondsInterval;
|
||||
private final double amount;
|
||||
private final String message;
|
||||
private String permission;
|
||||
private long reportInterval;
|
||||
|
||||
public Payout(int secondsInterval, double amount, String message, long reportInterval) {
|
||||
this.secondsInterval = secondsInterval;
|
||||
this.amount = amount;
|
||||
this.message = message;
|
||||
this.reportInterval = reportInterval;
|
||||
}
|
||||
|
||||
public int getSecondsInterval() {
|
||||
return secondsInterval;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static Payout fromConfigMap(Map<?, ?> values) {
|
||||
return new Payout(Integer.valueOf(String.valueOf(values.get("seconds"))), Double.valueOf(String.valueOf(values.get("amount"))), String.valueOf(values.get("message")), Long.valueOf(String.valueOf(values.get("report_interval"))));
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
public long getReportInterval() {
|
||||
return reportInterval;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package org.appledash.saneeconomy.onlinetime;
|
||||
|
||||
import org.appledash.saneeconomy.SaneEconomy;
|
||||
import org.appledash.saneeconomy.economy.economable.Economable;
|
||||
import org.appledash.saneeconomy.economy.transaction.Transaction;
|
||||
import org.appledash.saneeconomy.economy.transaction.TransactionReason;
|
||||
import org.appledash.sanelib.SanePlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by appledash on 7/13/17.
|
||||
* Blackjack is best pony.
|
||||
*/
|
||||
public class SaneEconomyOnlineTime extends SanePlugin implements Listener {
|
||||
private Map<UUID, Long> onlineSeconds = new HashMap<>();
|
||||
private Map<UUID, Double> reportingAmounts = new HashMap<>();
|
||||
private List<Payout> payouts = new ArrayList<>();
|
||||
private SaneEconomy saneEconomy;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
this.saneEconomy = (SaneEconomy) this.getServer().getPluginManager().getPlugin("SaneEconomy");
|
||||
this.saveDefaultConfig();
|
||||
|
||||
this.getConfig().getMapList("payouts").forEach(map -> {
|
||||
this.payouts.add(Payout.fromConfigMap(map));
|
||||
});
|
||||
|
||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
for (Player player : this.getServer().getOnlinePlayers()) {
|
||||
long onlineSeconds = this.onlineSeconds.getOrDefault(player.getUniqueId(), 0L);
|
||||
|
||||
onlineSeconds++;
|
||||
|
||||
this.onlineSeconds.put(player.getUniqueId(), onlineSeconds);
|
||||
|
||||
for (Payout payout : payouts) {
|
||||
if (payout.getPermission() != null && !player.hasPermission(payout.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((onlineSeconds % payout.getSecondsInterval()) == 0) {
|
||||
if (this.reportingAmounts.containsKey(player.getUniqueId())) {
|
||||
this.reportingAmounts.put(player.getUniqueId(), this.reportingAmounts.get(player.getUniqueId()) + payout.getAmount());
|
||||
} else {
|
||||
this.reportingAmounts.put(player.getUniqueId(), payout.getAmount());
|
||||
}
|
||||
|
||||
this.saneEconomy.getEconomyManager().transact(new Transaction(Economable.PLUGIN, Economable.wrap(player), payout.getAmount(), TransactionReason.PLUGIN_GIVE));
|
||||
}
|
||||
|
||||
if ((onlineSeconds % payout.getReportInterval()) == 0) {
|
||||
this.getMessenger().sendMessage(player, payout.getMessage(), this.saneEconomy.getEconomyManager().getCurrency().formatAmount(this.reportingAmounts.getOrDefault(player.getUniqueId(), 0D)), payout.getReportInterval());
|
||||
this.reportingAmounts.put(player.getUniqueId(), 0D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},0, 20);
|
||||
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent evt) {
|
||||
if (this.onlineSeconds.containsKey(evt.getPlayer().getUniqueId())) {
|
||||
this.onlineSeconds.remove(evt.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
if (this.reportingAmounts.containsKey(evt.getPlayer().getUniqueId())) {
|
||||
this.reportingAmounts.remove(evt.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
9
SaneEconomyOnlineTime/src/main/resources/config.yml
Normal file
9
SaneEconomyOnlineTime/src/main/resources/config.yml
Normal file
@ -0,0 +1,9 @@
|
||||
chat:
|
||||
prefix: '&b[&OnlineTime&b]&r '
|
||||
silent: false
|
||||
|
||||
payouts:
|
||||
- seconds: 10
|
||||
amount: 1000
|
||||
message: 'You have been paid {1} in the past {2} seconds of being online!'
|
||||
report_interval: 30
|
6
SaneEconomyOnlineTime/src/main/resources/plugin.yml
Normal file
6
SaneEconomyOnlineTime/src/main/resources/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
||||
name: SaneEconomyOnlineTime
|
||||
main: org.appledash.saneeconomy.onlinetime.SaneEconomyOnlineTime
|
||||
description: Pays players for being online!
|
||||
author: AppleDash
|
||||
version: 0.1.0
|
||||
depend: [SaneEconomy]
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<groupId>org.appledash</groupId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<dependency>
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomyCore</artifactId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
3
pom.xml
3
pom.xml
@ -6,13 +6,14 @@
|
||||
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<version>0.12.4-SNAPSHOT</version>
|
||||
<version>0.12.5-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>SaneEconomyCore</module>
|
||||
<module>SaneEconomySignShop</module>
|
||||
<module>SaneEconomyMobKills</module>
|
||||
<module>SaneEconomyOnlineTime</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
|
Loading…
Reference in New Issue
Block a user