Skip to content

Commit 7586ab2

Browse files
authored
Merge pull request #21 from JavaJava19/enchantment/jecon_support
Jecon Support
2 parents e09499e + aa15756 commit 7586ab2

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@
7878
<id>placeholderapi</id>
7979
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
8080
</repository>
81+
<repository>
82+
<id>himajyun-repo</id>
83+
<url>https://himajyun.github.io/mvn-repo/</url>
84+
</repository>
8185
</repositories>
8286

8387
<dependencies>
@@ -165,5 +169,11 @@
165169
<version>1.7</version>
166170
<scope>provided</scope>
167171
</dependency>
172+
<dependency>
173+
<groupId>jp.jyn</groupId>
174+
<artifactId>Jecon</artifactId>
175+
<version>2.2.1</version>
176+
<scope>provided</scope>
177+
</dependency>
168178
</dependencies>
169179
</project>

src/main/java/com/github/elic0de/thejpspit/TheJpsPit.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
import com.github.elic0de.thejpspit.database.MySqlDatabase;
1313
import com.github.elic0de.thejpspit.database.SqLiteDatabase;
1414
import com.github.elic0de.thejpspit.game.Game;
15-
import com.github.elic0de.thejpspit.hook.EconomyHook;
16-
import com.github.elic0de.thejpspit.hook.Hook;
17-
import com.github.elic0de.thejpspit.hook.PlaceholderHook;
18-
import com.github.elic0de.thejpspit.hook.VaultEconomyHook;
15+
import com.github.elic0de.thejpspit.hook.*;
1916
import com.github.elic0de.thejpspit.item.ItemManager;
2017
import com.github.elic0de.thejpspit.leveler.Levels;
2118
import com.github.elic0de.thejpspit.listener.BlockPlaceListener;
@@ -29,13 +26,15 @@
2926
import com.github.elic0de.thejpspit.villager.villagers.ShopVillager;
3027
import com.google.gson.Gson;
3128
import com.google.gson.GsonBuilder;
29+
3230
import java.io.File;
3331
import java.io.IOException;
3432
import java.lang.reflect.InvocationTargetException;
3533
import java.util.ArrayList;
3634
import java.util.List;
3735
import java.util.Optional;
3836
import java.util.logging.Level;
37+
3938
import net.william278.annotaml.Annotaml;
4039
import org.bukkit.Bukkit;
4140
import org.bukkit.GameRule;
@@ -95,7 +94,7 @@ public void onEnable() {
9594
this.database = this.loadDatabase();
9695
if (!database.hasLoaded()) {
9796
Bukkit.getLogger().log(Level.SEVERE,
98-
"Failed to load database! Please check your credentials! Disabling plugin...");
97+
"Failed to load database! Please check your credentials! Disabling plugin...");
9998
Bukkit.getPluginManager().disablePlugin(this);
10099
return;
101100
}
@@ -191,7 +190,9 @@ private void registerListener() {
191190

192191
private void registerHooks() {
193192
final PluginManager plugins = Bukkit.getPluginManager();
194-
if (plugins.getPlugin("Vault") != null) {
193+
if (plugins.getPlugin("Jecon") != null) {
194+
this.registerHook(new JeconEconomyHook(this));
195+
} else if (plugins.getPlugin("Vault") != null) {
195196
this.registerHook(new VaultEconomyHook(this));
196197
}
197198
if (plugins.getPlugin("PlaceholderAPI") != null) {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.github.elic0de.thejpspit.hook;
2+
3+
import com.github.elic0de.thejpspit.TheJpsPit;
4+
import com.github.elic0de.thejpspit.player.PitPlayer;
5+
import jp.jyn.jecon.Jecon;
6+
import org.bukkit.Bukkit;
7+
import org.bukkit.plugin.Plugin;
8+
9+
import java.math.BigDecimal;
10+
11+
public class JeconEconomyHook extends EconomyHook {
12+
13+
private Jecon jecon;
14+
15+
public JeconEconomyHook(TheJpsPit plugin) {
16+
super(plugin, "Jecon");
17+
}
18+
19+
@Override
20+
protected void onEnable() throws IllegalStateException {
21+
Plugin p = Bukkit.getPluginManager().getPlugin("Jecon");
22+
if (p == null || !plugin.isEnabled()) {
23+
throw new IllegalStateException("Could not find Jecon plugin");
24+
}
25+
this.jecon = (Jecon) p;
26+
}
27+
28+
@Override
29+
public BigDecimal getBalance(PitPlayer player) {
30+
return jecon.getRepository().get(player.getUniqueId()).orElse(BigDecimal.ZERO);
31+
}
32+
33+
@Override
34+
public boolean hasMoney(PitPlayer player, BigDecimal amount) {
35+
return jecon.getRepository().has(player.getUniqueId(), amount);
36+
}
37+
38+
@Override
39+
public void takeMoney(PitPlayer player, BigDecimal amount) {
40+
jecon.getRepository().withdraw(player.getUniqueId(), amount);
41+
player.getBoard().updateCoins();
42+
}
43+
44+
@Override
45+
public void giveMoney(PitPlayer player, BigDecimal amount) {
46+
jecon.getRepository().deposit(player.getUniqueId(), amount);
47+
player.getBoard().updateCoins();
48+
}
49+
50+
@Override
51+
public String formatMoney(BigDecimal amount) {
52+
return jecon.getRepository().format(amount);
53+
}
54+
55+
}

src/main/resources/plugin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ softdepend:
77
- PlaceholderAPI
88
- Vault
99
- MysqlEcoBridge
10+
- Jecon

0 commit comments

Comments
 (0)