Merge branch 'development'

This commit is contained in:
Brianna 2020-04-26 17:01:35 -04:00
commit 8b5ea2002b
5 changed files with 19 additions and 13 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateKits</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>2.6.2</version>
<version>2.6.3</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateKits-${project.version}</finalName>

View File

@ -90,7 +90,7 @@ public class Kit {
return items;
}
private boolean hasRoom(Player player) {
private boolean hasRoom(Player player, int itemAmount) {
int space = 0;
for (ItemStack content : player.getInventory().getContents()) {
@ -99,9 +99,8 @@ public class Kit {
}
}
int spaceNeeded = getItemContents().size();
return space >= spaceNeeded;
return space >= itemAmount;
}
public void processKeyUse(Player player) {
@ -286,7 +285,7 @@ public class Kit {
}
public boolean giveKit(Player player) {
return giveKit(player, -1, -1);
return giveKit(player, getItemContents().size(), -1);
}
private boolean giveKit(Player player, Key key) {
@ -298,7 +297,7 @@ public class Kit {
}
private boolean giveKit(Player player, int itemAmount, int kitAmount) {
if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player)) {
if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player, itemAmount)) {
plugin.getLocale().getMessage("event.claim.full").sendPrefixedMessage(player);
return false;
}
@ -323,7 +322,7 @@ public class Kit {
int canChoose = 0;
for (KitItem item : innerContents) {
if (itemGiveAmount == 0) break;
int ch = canChoose++ == forceSelect || item.getChance() == 0 ? 100 : item.getChance();
double ch = canChoose++ == forceSelect || item.getChance() == 0 ? 100 : item.getChance();
double rand = Math.random() * 100;
if (rand < ch || ch == 100) {

View File

@ -22,7 +22,7 @@ public class KitItem {
private KitContent content;
private String displayName, displayLore = null;
private Material displayItem = null;
private int chance = 0;
private double chance = 0;
public KitItem(String line) {
if (line.contains(";") && !line.startsWith("{")) {
@ -77,7 +77,8 @@ public class KitItem {
switch (option) {
case "chance":
chance = Integer.parseInt(value);
//chance = Integer.parseInt(value);
chance = Double.parseDouble(value);
break;
case "display-item":
displayItem = Material.valueOf(value);
@ -116,11 +117,11 @@ public class KitItem {
return compileOptions() + ";" + this.content.getSerialized();
}
public int getChance() {
public double getChance() {
return chance == 0 ? 100 : chance;
}
public void setChance(int chance) {
public void setChance(double chance) {
this.chance = chance;
}

View File

@ -108,7 +108,7 @@ public class InteractListeners implements Listener {
ItemStack item = event.getItem();
Player player = event.getPlayer();
if (!item.hasItemMeta() || !item.getItemMeta().hasLore()) return;
if (!item.hasItemMeta() || !item.getItemMeta().hasLore() || item.getItemMeta().getLore().size() == 0) return;
Kit kit = UltimateKits.getInstance().getKitManager().getKit(ChatColor.stripColor(item.getItemMeta().getLore().get(0).split(" ")[0]));

View File

@ -14,7 +14,13 @@ public class Settings {
static final Config config = UltimateKits.getInstance().getCoreConfig();
public static final ConfigSetting ONLY_SHOW_KITS_WITH_PERMS = new ConfigSetting(config, "Main.Only Show Players Kits They Have Permission To Use", false);
public static final ConfigSetting KITS_FREE_WITH_PERMS = new ConfigSetting(config, "Main.Allow Players To Receive Kits For Free If They Have Permission", true);
public static final ConfigSetting KITS_FREE_WITH_PERMS = new ConfigSetting(config, "Main.Allow Players To Receive Kits For Free If They Have Permission", true,
"I'm fully aware that this is a strange setting to have",
"enabled by default. The reason I do this is because a lot of our users",
"come from the plugin essentials where the user having permission to the",
"kit allows them to get the kit for free. So when they come to this plugin",
"they would often report this mechanic as a bug. So enabling this by default",
"king of made sense and we get a lot less tickets about this plugin because of that.");
public static final ConfigSetting DONT_PREVIEW_COMMANDS = new ConfigSetting(config, "Main.Dont Preview Commands In Kits", false);
public static final ConfigSetting HOLOGRAM_LAYOUT = new ConfigSetting(config, "Main.Hologram Layout", Arrays.asList("{TITLE}", "{LEFT-CLICK}", "{RIGHT-CLICK}"));
public static final ConfigSetting SOUNDS_ENABLED = new ConfigSetting(config, "Main.Sounds Enabled", true);