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

Commit

Permalink
Beta 1.1.5 for 1.13+
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Nov 1, 2018
1 parent da32a21 commit d7bfb5a
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 34 deletions.
6 changes: 6 additions & 0 deletions TNE/src/net/tnemc/core/TNE.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,16 @@ private void saveConfigurations(boolean check) {
}

private void setConfigurationDefaults() throws UnsupportedEncodingException {
Reader currenciesStream = new InputStreamReader(this.getResource("currency.yml"), "UTF8");
Reader itemsStream = new InputStreamReader(this.getResource("items.yml"), "UTF8");
Reader messagesStream = new InputStreamReader(this.getResource("messages.yml"), "UTF8");
Reader playersStream = new InputStreamReader(this.getResource("players.yml"), "UTF8");
Reader worldsStream = new InputStreamReader(this.getResource("worlds.yml"), "UTF8");
if (currenciesStream != null && !currencies.exists()) {
YamlConfiguration config = YamlConfiguration.loadConfiguration(currenciesStream);
currencyConfigurations.setDefaults(config);
}

if (itemsStream != null && !items.exists()) {
YamlConfiguration config = YamlConfiguration.loadConfiguration(itemsStream);
itemConfigurations.setDefaults(config);
Expand Down
40 changes: 24 additions & 16 deletions TNE/src/net/tnemc/core/commands/admin/AdminReportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
final int year = now.getYear();
final int month = now.getMonthValue();
final int day = now.getDayOfMonth();
final int minute = now.getMinute();

StringBuilder content = new StringBuilder();
String name = "";

name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-server.txt";
TNE.instance().getLogger().info("Logging report.");
name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-" + minute + "-server.txt";
try (BufferedReader br = new BufferedReader(new FileReader(new File(TNE.instance().getDataFolder(),"../../logs/latest.log")))){
String line;
while ((line = br.readLine()) != null) {
Expand All @@ -76,41 +78,47 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
} catch (Exception e) {
TNE.debug(e);
}
serverLog = MISCUtils.pastebinUpload(name, content);
serverLog = MISCUtils.pastebinUpload(name, "yaml", content);

name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-config.txt";
content = new StringBuilder();
name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-" + minute + "-config.txt";
try (BufferedReader br = new BufferedReader(new FileReader(new File(TNE.instance().getDataFolder(),"config.yml")))){
String line;
while ((line = br.readLine()) != null) {
if(line.contains("Database")) continue;
if(line.toLowerCase().contains("mysql") || line.toLowerCase().contains("host") ||
line.toLowerCase().contains("user") || line.toLowerCase().contains("pass") ||
line.toLowerCase().contains("port")) continue;
content.append(line + System.getProperty("line.separator"));
}
} catch (Exception e) {
TNE.debug(e);
}
configLog = MISCUtils.pastebinUpload(name, content);
configLog = MISCUtils.pastebinUpload(name, "yaml", content);

System.out.println("ConfigLog: " + configLog);
System.out.println("serverLog: " + serverLog);

if(!serverLog.contains("pastebin.com") ||
!configLog.contains("pastebin.com")) {
if(!configLog.contains("pastebin.com")) {
sender.sendMessage(ChatColor.RED + "Something went wrong while preparing your report.");
return false;
}

content = new StringBuilder();
name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-report.txt";
content.append("Report Description: " + String.join(" ", arguments));
content.append("TNE Version: " + TNE.instance().getDescription().getVersion());
content.append("TNE Build: " + TNE.build);
content.append("Modules Loaded: " + String.join(", ", TNE.loader().getModules().keySet()));
content.append("API: " + Bukkit.getName());
content.append("API Version: " + Bukkit.getVersion());
content.append("Online Mode: " + Bukkit.getOnlineMode());
content.append("config.yml: " + configLog);
content.append("Report Description: " + String.join(" ", arguments) + System.getProperty("line.separator"));
content.append("TNE Version: " + TNE.instance().getDescription().getVersion() + System.getProperty("line.separator"));
content.append("TNE Build: " + TNE.build + System.getProperty("line.separator"));
content.append("Modules Loaded: " + String.join(", ", TNE.loader().getModules().keySet()) + System.getProperty("line.separator"));
content.append("API: " + Bukkit.getName() + System.getProperty("line.separator"));
content.append("API Version: " + Bukkit.getVersion() + System.getProperty("line.separator"));
content.append("Online Mode: " + Bukkit.getOnlineMode() + System.getProperty("line.separator"));
content.append("config.yml: " + configLog + System.getProperty("line.separator"));
content.append("latest.log: " + serverLog);

reportLog = MISCUtils.pastebinUpload(name, content);
reportLog = MISCUtils.pastebinUpload(name, "yaml", content);

succeeded = reportLog.contains("pastebin.com");
System.out.println("reportLog: " + reportLog);

if(succeeded) {
sender.sendMessage(ChatColor.WHITE + "Report URL: " + reportLog);
Expand Down
4 changes: 2 additions & 2 deletions TNE/src/net/tnemc/core/commands/admin/AdminUploadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
} catch (Exception e) {
TNE.debug(e);
}
serverLog = MISCUtils.pastebinUpload(name, content);
serverLog = MISCUtils.pastebinUpload(name, "yaml", content);

content = new StringBuilder();
name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-debug.txt";
Expand All @@ -87,7 +87,7 @@ public boolean execute(CommandSender sender, String command, String[] arguments)
} catch (Exception e) {
TNE.debug(e);
}
debugLog = MISCUtils.pastebinUpload(name, content);
debugLog = MISCUtils.pastebinUpload(name, "yaml", content);

succeeded = serverLog.contains("pastebin.com") || debugLog.contains("pastebin.com");

Expand Down
4 changes: 2 additions & 2 deletions TNE/src/net/tnemc/core/common/CurrencyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void loadBasic() {
}

private void loadBasicTiers(TNECurrency currency, FileConfiguration configuration, boolean item) {
final String baseNode = "Core.Currency.Basic" + ((item)? "Items" : "Virtual");
final String baseNode = "Core.Currency.Basic." + ((item)? "Items" : "Virtual");
Set<String> tiers = configuration.getConfigurationSection(baseNode).getKeys(false);

for (String tierName : tiers) {
Expand Down Expand Up @@ -159,7 +159,7 @@ private void loadBasicTiers(TNECurrency currency, FileConfiguration configuratio
}

private void loadCurrency(FileConfiguration configuration, boolean world, String worldName) {
String curBase = ((world)? "Worlds." + worldName : "Core") + ".Currencies";
String curBase = ((world)? "Worlds." + worldName + "." : "") + "Currencies";
if(configuration.contains(curBase)) {

Set<String> currencies = configuration.getConfigurationSection(curBase).getKeys(false);
Expand Down
14 changes: 8 additions & 6 deletions TNE/src/net/tnemc/core/common/currency/CurrencyFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,22 @@ private static BigDecimal parseWeight(TNECurrency currency, BigDecimal decimal)

private static String shorten(TNECurrency currency, BigDecimal balance) {
final BigInteger wholeNum = balance.toBigInteger();
if (wholeNum.compareTo(new BigInteger("1000")) == 0) {
if (wholeNum.compareTo(new BigInteger("1009")) <= 0) {
return "" + wholeNum.toString();
}
final String whole = wholeNum.toString();
final int pos = ((whole.length() - 1) / 3) - 1;
final int posInclude = ((whole.length() % 3) == 0)? 3 : whole.length() % 3;
String wholeSub = whole.substring(0, posInclude);

String extra = whole.substring(posInclude, posInclude + 2);
if(Integer.valueOf(extra) > 0) {
if(extra.endsWith("0")) {
extra = extra.substring(0, extra.length() - 1);
if(whole.length() > 3) {
String extra = whole.substring(posInclude, posInclude + 2);
if (Integer.valueOf(extra) > 0) {
if (extra.endsWith("0")) {
extra = extra.substring(0, extra.length() - 1);
}
wholeSub = wholeSub + "." + extra;
}
wholeSub = wholeSub + "." + extra;
}

return wholeSub + currency.getPrefixes().charAt(pos);
Expand Down
10 changes: 5 additions & 5 deletions TNE/src/net/tnemc/core/common/utils/MISCUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static void idExtract(CommandSender sender) throws SQLException {
}));

String name = TNE.instance().getServerName() + "-" + year + "-" + month + "-" + day + "-idextracted";
String pasteURL = MISCUtils.pastebinUpload(name, content);
String pasteURL = MISCUtils.pastebinUpload(name, "yaml", content);

String result = "Successfully extracted ECOIDS data." + ((pasteURL.contains("pastebin.com"))? " Uploaded backup to " + pasteURL : "");
sender.sendMessage(result);
Expand Down Expand Up @@ -249,7 +249,7 @@ public static void extract(CommandSender sender) throws SQLException {
} catch (Exception e) {
TNE.debug(e);
}
String pasteURL = MISCUtils.pastebinUpload(name, content);
String pasteURL = MISCUtils.pastebinUpload(name, "yaml", content);

String result = "Successfully extracted player balance data." + ((pasteURL.contains("pastebin.com"))? " Uploaded backup to " + pasteURL : "");
sender.sendMessage(result);
Expand All @@ -272,7 +272,7 @@ public static void idTest(Player player, CommandSender sender) {
for(int i = 0; i < 40; i++) {
builder.append(IDFinder.getID(player.getName()).toString() + System.getProperty("line.separator"));
}
player.sendMessage("IDFinder Test Results: " + pastebinUpload("IDFinder Test", builder));
player.sendMessage("IDFinder Test Results: " + pastebinUpload("IDFinder Test", "yaml", builder));
}

public static void commandTest(Player player) {
Expand Down Expand Up @@ -358,14 +358,14 @@ public static String md5(String toDigest) {
return toReturn;
}

public static String pastebinUpload(String name, StringBuilder content) {
public static String pastebinUpload(String name, String format, StringBuilder content) {
final String base = "https://pastebin.com/api/api_post.php";
final String devKey = "b73948f0d7d8cb449085dc90168a5deb";
final String format = "txt";
final String expiration = "N";
final String privateCode = "1";

String parameters = "api_option=paste&api_paste_private=" + privateCode +
"&api_paste_format=" + format +
"&api_expire_date=" + expiration +
"&api_dev_key=" + devKey;

Expand Down
5 changes: 2 additions & 3 deletions TNE/src/net/tnemc/core/listeners/ConnectionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.tnemc.core.economy.transaction.result.TransactionResult;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -137,11 +136,11 @@ public void onJoin(final PlayerJoinEvent event) {
}
TNE.manager().addAccount(account);

if(TNE.instance().developers.contains(player.getUniqueId().toString())) {
/*if(TNE.instance().developers.contains(player.getUniqueId().toString())) {
Bukkit.getOnlinePlayers().forEach((p)->{
p.playSound(p.getLocation(), Sound.ENTITY_WITHER_SPAWN, 10f, 1f);
});
}
}*/
//final String uuidString = id.toString();

/*if(TNE.useMod) {
Expand Down

0 comments on commit d7bfb5a

Please sign in to comment.