Skip to content

Commit

Permalink
🗜️ Shrink jar size 400kb
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Sep 29, 2020
1 parent 59520a3 commit 31de641
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ configurations.all {

val projectName = "WanderingTrades"
group = "xyz.jpenilla"
version = "1.6.4.1+${getLastCommitHash()}-SNAPSHOT"
version = "1.6.4.2+${getLastCommitHash()}-SNAPSHOT"

repositories {
mavenLocal()
Expand All @@ -44,11 +44,9 @@ dependencies {
compileOnly("com.sk89q.worldguard", "worldguard-bukkit", "7.0.2")
compileOnly("com.sk89q.worldedit", "worldedit-bukkit", "7.1.0")
compileOnly("com.github.Eunoians", "McRPG", "1.3.3.0-BETA")
implementation("xyz.jpenilla", "jmplib", "1.0.1+5-SNAPSHOT")
implementation("xyz.jpenilla", "jmplib", "1.0.1+7-SNAPSHOT")
implementation("co.aikar", "acf-paper", "0.5.0-SNAPSHOT")
implementation("org.bstats", "bstats-bukkit", "1.7")
implementation("commons-io", "commons-io", "2.7")
implementation("org.apache.commons", "commons-math3", "3.6.1")
}

spigot {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package xyz.jpenilla.wanderingtrades.gui;

import org.apache.commons.io.FileUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
Expand All @@ -14,6 +13,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -92,7 +92,9 @@ public void onClick(Player p, ItemStack i) {
.onConfirmText(this::onConfirmYesNo)
.onAccepted((player, s) -> {
try {
FileUtils.copyToFile(WanderingTrades.getInstance().getResource("trades/blank.yml"), new File(WanderingTrades.getInstance().getDataFolder() + "/trades/" + s + ".yml"));
Files.copy(WanderingTrades.getInstance().getResource("trades/blank.yml"),
new File(WanderingTrades.getInstance().getDataFolder() + "/trades/" + s + ".yml").toPath());

WanderingTrades.getInstance().getCfg().load();
WanderingTrades.getInstance().getChat().sendParsed(player, lang.get(Lang.MESSAGE_CREATE_CONFIG_SUCCESS));
} catch (IOException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.google.common.collect.ImmutableList;
import lombok.Getter;
import org.apache.commons.math3.distribution.EnumeratedDistribution;
import org.apache.commons.math3.util.Pair;
import org.bukkit.Bukkit;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.entity.EntityType;
Expand All @@ -16,6 +14,7 @@
import org.bukkit.inventory.MerchantRecipe;
import org.jetbrains.annotations.NotNull;
import xyz.jpenilla.jmplib.Crafty;
import xyz.jpenilla.jmplib.RandomCollection;
import xyz.jpenilla.wanderingtrades.WanderingTrades;

import java.lang.invoke.MethodHandle;
Expand Down Expand Up @@ -67,9 +66,9 @@ public void addTrades(WanderingTrader wanderingTrader, boolean refresh) {
}
});
} else {
List<Pair<String, Double>> weights = new ArrayList<>();
wanderingTrades.getCfg().getTradeConfigs().forEach((key, value) -> weights.add(new Pair<>(key, value.getChance())));
String chosenConfig = new EnumeratedDistribution<>(weights).sample();
RandomCollection<String> configNames = new RandomCollection<>();
wanderingTrades.getCfg().getTradeConfigs().forEach((key, value) -> configNames.add(value.getChance(), key));
String chosenConfig = configNames.next();
if (chosenConfig != null) {
newTrades.addAll(wanderingTrades.getCfg().getTradeConfigs().get(chosenConfig).getTrades(false));
}
Expand Down

0 comments on commit 31de641

Please sign in to comment.