Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>himajyun-repo</id>
<url>https://himajyun.github.io/mvn-repo/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -165,5 +169,11 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jp.jyn</groupId>
<artifactId>Jecon</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
13 changes: 7 additions & 6 deletions src/main/java/com/github/elic0de/thejpspit/TheJpsPit.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
import com.github.elic0de.thejpspit.database.MySqlDatabase;
import com.github.elic0de.thejpspit.database.SqLiteDatabase;
import com.github.elic0de.thejpspit.game.Game;
import com.github.elic0de.thejpspit.hook.EconomyHook;
import com.github.elic0de.thejpspit.hook.Hook;
import com.github.elic0de.thejpspit.hook.PlaceholderHook;
import com.github.elic0de.thejpspit.hook.VaultEconomyHook;
import com.github.elic0de.thejpspit.hook.*;
import com.github.elic0de.thejpspit.item.ItemManager;
import com.github.elic0de.thejpspit.leveler.Levels;
import com.github.elic0de.thejpspit.listener.BlockPlaceListener;
Expand All @@ -29,13 +26,15 @@
import com.github.elic0de.thejpspit.villager.villagers.ShopVillager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.logging.Level;

import net.william278.annotaml.Annotaml;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
Expand Down Expand Up @@ -95,7 +94,7 @@ public void onEnable() {
this.database = this.loadDatabase();
if (!database.hasLoaded()) {
Bukkit.getLogger().log(Level.SEVERE,
"Failed to load database! Please check your credentials! Disabling plugin...");
"Failed to load database! Please check your credentials! Disabling plugin...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
Expand Down Expand Up @@ -191,7 +190,9 @@ private void registerListener() {

private void registerHooks() {
final PluginManager plugins = Bukkit.getPluginManager();
if (plugins.getPlugin("Vault") != null) {
if (plugins.getPlugin("Jecon") != null) {
this.registerHook(new JeconEconomyHook(this));
} else if (plugins.getPlugin("Vault") != null) {
this.registerHook(new VaultEconomyHook(this));
}
if (plugins.getPlugin("PlaceholderAPI") != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.github.elic0de.thejpspit.hook;

import com.github.elic0de.thejpspit.TheJpsPit;
import com.github.elic0de.thejpspit.player.PitPlayer;
import jp.jyn.jecon.Jecon;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;

import java.math.BigDecimal;

public class JeconEconomyHook extends EconomyHook {

private Jecon jecon;

public JeconEconomyHook(TheJpsPit plugin) {
super(plugin, "Jecon");
}

@Override
protected void onEnable() throws IllegalStateException {
Plugin p = Bukkit.getPluginManager().getPlugin("Jecon");
if (p == null || !plugin.isEnabled()) {
throw new IllegalStateException("Could not find Jecon plugin");
}
this.jecon = (Jecon) p;
}

@Override
public BigDecimal getBalance(PitPlayer player) {
return jecon.getRepository().get(player.getUniqueId()).orElse(BigDecimal.ZERO);
}

@Override
public boolean hasMoney(PitPlayer player, BigDecimal amount) {
return jecon.getRepository().has(player.getUniqueId(), amount);
}

@Override
public void takeMoney(PitPlayer player, BigDecimal amount) {
jecon.getRepository().withdraw(player.getUniqueId(), amount);
player.getBoard().updateCoins();
}

@Override
public void giveMoney(PitPlayer player, BigDecimal amount) {
jecon.getRepository().deposit(player.getUniqueId(), amount);
player.getBoard().updateCoins();
}

@Override
public String formatMoney(BigDecimal amount) {
return jecon.getRepository().format(amount);
}

}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ softdepend:
- PlaceholderAPI
- Vault
- MysqlEcoBridge
- Jecon