Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
0.1.1.8k
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Jul 25, 2019
1 parent 976f8d7 commit f2f71f3
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 40 deletions.
2 changes: 1 addition & 1 deletion TNE/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>com.github</groupId>
<artifactId>TNELib</artifactId>
<version>0.1.3.10</version>
<version>0.1.3.11</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
2 changes: 1 addition & 1 deletion TNE/src/net/tnemc/core/TNE.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class TNE extends TNELib {
//BukkitRunnable Workers
private SaveWorker saveWorker;

public static final String build = "1Beta118j";
public static final String build = "1Beta118k";

private boolean blacklisted = false;
public static boolean useMod = false;
Expand Down
12 changes: 7 additions & 5 deletions TNE/src/net/tnemc/core/common/utils/MISCUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,14 @@ public static void restore(CommandSender sender) {
});
TNE.manager().addAccount(account);
number++;
final boolean message = (number % frequency == 0);
try {
final boolean message = (number % frequency == 0);

if(message) {
final int progress = (int)(number * 100 / accounts.size());
TNE.logger().info("Restoration Progress: " + progress);
}
if (message) {
final int progress = (int) (number * 100 / accounts.size());
TNE.logger().info("Restoration Progress: " + progress);
}
} catch(Exception ignore) {}
}
}

Expand Down
7 changes: 5 additions & 2 deletions TNEConversion/src/net/tnemc/conversion/ConversionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.tnemc.conversion.impl.BOSEconomy;
import net.tnemc.conversion.impl.BasicEconomy;
import net.tnemc.conversion.impl.Blings;
import net.tnemc.conversion.impl.CMI;
import net.tnemc.conversion.impl.DevCoinSystem;
import net.tnemc.conversion.impl.ECEconomy;
import net.tnemc.conversion.impl.EasyCoins;
Expand Down Expand Up @@ -58,7 +59,7 @@
@ModuleInfo(
name = "Conversion",
author = "creatorfromhell",
version = "0.1.0"
version = "0.1.1"
)
public class ConversionModule extends Module {

Expand All @@ -82,7 +83,7 @@ public List<TNECommand> getCommands() {

public Converter getConverter(String name) {

switch(name) {
switch(name.toLowerCase()) {
case "advancedeconomy":
return new AdvancedEconomy();
case "basiceconomy":
Expand All @@ -95,6 +96,8 @@ public Converter getConverter(String name) {
return new Blings();
case "boseconomy":
return new BOSEconomy();
case "cmi":
return new CMI();
case "devcoinsystem":
return new DevCoinSystem();
case "easycoins":
Expand Down
8 changes: 7 additions & 1 deletion TNEConversion/src/net/tnemc/conversion/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.tnerevival.core.DataManager;
import com.github.tnerevival.core.db.DataProvider;
import com.github.tnerevival.core.db.sql.SQLite;
import net.tnemc.core.TNE;
import org.javalite.activejdbc.DB;

Expand Down Expand Up @@ -37,7 +38,12 @@ public void initialize(DataManager manager) {
DataProvider provider = TNE.saveManager().getDataManager().getProviders().get(manager.getFormat());

try {
db.open(provider.connector().getDriver(), provider.connector().getURL(manager.getFile(), manager.getHost(), manager.getPort(), manager.getDatabase()) + ((manager.getFormat().equalsIgnoreCase("mysql"))? "?useSSL=false" : ""), manager.getUser(), manager.getPassword());
if(manager.getFormat().equalsIgnoreCase("sqlite")) {
final SQLite sqlite = new SQLite(manager);
db.open(sqlite.getDriver(), sqlite.getURL(manager.getFile(), manager.getHost(), manager.getPort(), manager.getDatabase()), null);
} else {
db.open(provider.connector().getDriver(), provider.connector().getURL(manager.getFile(), manager.getHost(), manager.getPort(), manager.getDatabase()) + ((manager.getFormat().equalsIgnoreCase("mysql")) ? "?useSSL=false" : ""), manager.getUser(), manager.getPassword());
}
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down
94 changes: 94 additions & 0 deletions TNEConversion/src/net/tnemc/conversion/impl/CMI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package net.tnemc.conversion.impl;

import net.tnemc.conversion.ConversionModule;
import net.tnemc.conversion.Converter;
import net.tnemc.conversion.InvalidDatabaseImport;
import net.tnemc.core.TNE;
import net.tnemc.core.common.data.TNEDataManager;
import net.tnemc.core.economy.currency.Currency;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
* The New Economy Minecraft Server Plugin
* <p>
* Created by creatorfromhell on 7/24/2019.
* <p>
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
* Created by creatorfromhell on 06/30/2017.
*/
public class CMI extends Converter {

private File configFile = new File(TNE.instance().getDataFolder(), "../CMI/config.yml");
private FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);

@Override
public String name() {
return "CMI";
}

@Override
public String type() {
return config.getString("storage.method").toLowerCase();
}

@Override
public void mysql() throws InvalidDatabaseImport {

final String prefix = config.getString("mysql.tablePrefix");
final String table = prefix + "users";
final String[] workHost = config.getString("mysql.hostname").split(":");

initialize(new TNEDataManager(type(), workHost[0],
Integer.valueOf(workHost[1]), config.getString("mysql.database"),
config.getString("mysql.username"), config.getString("mysql.password"),
prefix, "cmi.sqlite",
false, false, 60, false));
open();
try(Connection connection = db.getConnection();
Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery("SELECT username, Balance FROM " + table + ";")) {

final Currency currency = TNE.manager().currencyManager().get(TNE.instance().defaultWorld);
while(results.next()) {
ConversionModule.convertedAdd(results.getString("username"),
TNE.instance().defaultWorld, currency.name(),
new BigDecimal(results.getDouble("Balance")));
}
} catch(SQLException ignore) {}
close();

}

@Override
public void sqlite() throws InvalidDatabaseImport {
try {

Class.forName("org.sqlite.JDBC");

try(Connection connection = DriverManager.getConnection("jdbc:sqlite:" + new File(TNE.instance().getDataFolder(), "../CMI/cmi.sqlite.db").getAbsolutePath());
Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery("SELECT username, Balance FROM users;")) {

final Currency currency = TNE.manager().currencyManager().get(TNE.instance().defaultWorld);
while(results.next()) {
ConversionModule.convertedAdd(results.getString("username"),
TNE.instance().defaultWorld, currency.name(),
new BigDecimal(results.getDouble("Balance")));
}
} catch(SQLException ignore) {}

} catch(Exception ignore) {}

}
}
30 changes: 0 additions & 30 deletions Web/src/net/tnemc/web/pages/helper/Balance.java

This file was deleted.

0 comments on commit f2f71f3

Please sign in to comment.