mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 12:15:59 +01:00
Default to Quests Journal without item
This commit is contained in:
parent
81f7fb4d3c
commit
2db149067d
16
core/pom.xml
16
core/pom.xml
@ -134,6 +134,11 @@
|
||||
<artifactId>LocaleLib</artifactId>
|
||||
<version>12e12cbadc</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.upperlevel.spigot.book</groupId>
|
||||
<artifactId>spigot-book-api</artifactId>
|
||||
<version>1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
@ -244,9 +249,10 @@
|
||||
<include>me.*</include>
|
||||
<include>com.github.PikaMug:LocaleLib</include>
|
||||
<include>com.zaxxer:HikariCP</include>
|
||||
<include>mysql</include>
|
||||
<include>org.slf4j:slf4j-simple</include>
|
||||
<include>org.slf4j:slf4j-api</include>
|
||||
<include>mysql</include>
|
||||
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
@ -258,13 +264,17 @@
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.mysql</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.slf4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.mysql</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.mysql</shadedPattern>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>me.blackvein.quests.libs.bookutil</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
|
@ -35,6 +35,7 @@ public class Settings implements ISettings {
|
||||
private int consoleLogging = 1;
|
||||
private boolean disableCommandFeedback = true;
|
||||
private boolean genFilesOnJoin = true;
|
||||
private boolean giveJournalItem = false;
|
||||
private boolean ignoreLockedQuests = false;
|
||||
private int killDelay = 0;
|
||||
private int maxQuests = 0;
|
||||
@ -134,6 +135,12 @@ public class Settings implements ISettings {
|
||||
public void setGenFilesOnJoin(final boolean genFilesOnJoin) {
|
||||
this.genFilesOnJoin = genFilesOnJoin;
|
||||
}
|
||||
public boolean canGiveJournalItem() {
|
||||
return giveJournalItem;
|
||||
}
|
||||
public void setGiveJournalItem(final boolean giveJournalItem) {
|
||||
this.giveJournalItem = giveJournalItem;
|
||||
}
|
||||
public boolean canIgnoreLockedQuests() {
|
||||
return ignoreLockedQuests;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class QuestsJournalCommand extends QuestsSubCommand {
|
||||
|
||||
@ -78,31 +79,36 @@ public class QuestsJournalCommand extends QuestsSubCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final Inventory inv = player.getInventory();
|
||||
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)) {
|
||||
if (!plugin.getSettings().canGiveJournalItem()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
BookUtil.openPlayer(player, journal.toItemStack());
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "journalNoRoom")
|
||||
.replace("<journal>", Lang.get(player, "journalTitle")));
|
||||
final Inventory inv = player.getInventory();
|
||||
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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user