Default to Quests Journal without item

This commit is contained in:
PikaMug 2022-04-01 04:07:49 -04:00
parent 81f7fb4d3c
commit 2db149067d
3 changed files with 49 additions and 26 deletions

View File

@ -134,6 +134,11 @@
<artifactId>LocaleLib</artifactId> <artifactId>LocaleLib</artifactId>
<version>12e12cbadc</version> <version>12e12cbadc</version>
</dependency> </dependency>
<dependency>
<groupId>xyz.upperlevel.spigot.book</groupId>
<artifactId>spigot-book-api</artifactId>
<version>1.6</version>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
@ -244,9 +249,10 @@
<include>me.*</include> <include>me.*</include>
<include>com.github.PikaMug:LocaleLib</include> <include>com.github.PikaMug:LocaleLib</include>
<include>com.zaxxer:HikariCP</include> <include>com.zaxxer:HikariCP</include>
<include>mysql</include>
<include>org.slf4j:slf4j-simple</include> <include>org.slf4j:slf4j-simple</include>
<include>org.slf4j:slf4j-api</include> <include>org.slf4j:slf4j-api</include>
<include>mysql</include> <include>xyz.upperlevel.spigot.book:spigot-book-api</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
@ -258,13 +264,17 @@
<pattern>com.zaxxer.hikari</pattern> <pattern>com.zaxxer.hikari</pattern>
<shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern> <shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.mysql</pattern>
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>org.slf4j</pattern> <pattern>org.slf4j</pattern>
<shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern> <shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern>
</relocation> </relocation>
<relocation> <relocation>
<pattern>com.mysql</pattern> <pattern>xyz.upperlevel.spigot.book</pattern>
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern> <shadedPattern>me.blackvein.quests.libs.bookutil</shadedPattern>
</relocation> </relocation>
</relocations> </relocations>
</configuration> </configuration>

View File

@ -35,6 +35,7 @@ public class Settings implements ISettings {
private int consoleLogging = 1; private int consoleLogging = 1;
private boolean disableCommandFeedback = true; private boolean disableCommandFeedback = true;
private boolean genFilesOnJoin = true; private boolean genFilesOnJoin = true;
private boolean giveJournalItem = false;
private boolean ignoreLockedQuests = false; private boolean ignoreLockedQuests = false;
private int killDelay = 0; private int killDelay = 0;
private int maxQuests = 0; private int maxQuests = 0;
@ -134,6 +135,12 @@ public class Settings implements ISettings {
public void setGenFilesOnJoin(final boolean genFilesOnJoin) { public void setGenFilesOnJoin(final boolean genFilesOnJoin) {
this.genFilesOnJoin = genFilesOnJoin; this.genFilesOnJoin = genFilesOnJoin;
} }
public boolean canGiveJournalItem() {
return giveJournalItem;
}
public void setGiveJournalItem(final boolean giveJournalItem) {
this.giveJournalItem = giveJournalItem;
}
public boolean canIgnoreLockedQuests() { public boolean canIgnoreLockedQuests() {
return ignoreLockedQuests; return ignoreLockedQuests;
} }

View File

@ -24,6 +24,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import xyz.upperlevel.spigot.book.BookUtil;
public class QuestsJournalCommand extends QuestsSubCommand { public class QuestsJournalCommand extends QuestsSubCommand {
@ -78,31 +79,36 @@ public class QuestsJournalCommand extends QuestsSubCommand {
return; return;
} }
final Inventory inv = player.getInventory(); if (!plugin.getSettings().canGiveJournalItem()) {
final int index = quester.getJournalIndex();
if (index != -1) {
inv.setItem(index, null);
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalPutAway")
.replace("<journal>", Lang.get(player, "journalTitle")));
} else if (player.getItemInHand().getType().equals(Material.AIR)) {
final QuestJournal journal = new QuestJournal(quester); final QuestJournal journal = new QuestJournal(quester);
player.setItemInHand(journal.toItemStack()); BookUtil.openPlayer(player, journal.toItemStack());
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
.replace("<journal>", Lang.get(player, "journalTitle")));
} else if (inv.firstEmpty() != -1) {
final ItemStack[] arr = inv.getContents();
for (int i = 0; i < arr.length; i++) {
if (arr[i] == null) {
final QuestJournal journal = new QuestJournal(quester);
inv.setItem(i, journal.toItemStack());
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
.replace("<journal>", Lang.get(player, "journalTitle")));
break;
}
}
} else { } else {
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalNoRoom") final Inventory inv = player.getInventory();
.replace("<journal>", Lang.get(player, "journalTitle"))); final int index = quester.getJournalIndex();
if (index != -1) {
inv.setItem(index, null);
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalPutAway")
.replace("<journal>", Lang.get(player, "journalTitle")));
} else if (player.getItemInHand().getType().equals(Material.AIR)) {
final QuestJournal journal = new QuestJournal(quester);
player.setItemInHand(journal.toItemStack());
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
.replace("<journal>", Lang.get(player, "journalTitle")));
} else if (inv.firstEmpty() != -1) {
final ItemStack[] arr = inv.getContents();
for (int i = 0; i < arr.length; i++) {
if (arr[i] == null) {
final QuestJournal journal = new QuestJournal(quester);
inv.setItem(i, journal.toItemStack());
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalTaken")
.replace("<journal>", Lang.get(player, "journalTitle")));
break;
}
}
} else {
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalNoRoom")
.replace("<journal>", Lang.get(player, "journalTitle")));
}
} }
} }
} }