mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Special case for 1.21+ crops, fixes #2256
This commit is contained in:
parent
ba078ea7f8
commit
70119ad4ab
14
core/pom.xml
14
core/pom.xml
@ -170,8 +170,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
<artifactId>item-nbt-api-plugin</artifactId>
|
<artifactId>item-nbt-api</artifactId>
|
||||||
<version>2.12.4</version>
|
<version>2.13.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xyz.upperlevel.spigot.book</groupId>
|
<groupId>xyz.upperlevel.spigot.book</groupId>
|
||||||
@ -265,7 +265,7 @@
|
|||||||
<includes>
|
<includes>
|
||||||
<include>me.*</include>
|
<include>me.*</include>
|
||||||
<include>com.github.PikaMug:LocaleLib</include>
|
<include>com.github.PikaMug:LocaleLib</include>
|
||||||
<include>de.tr7zw:item-nbt-api-plugin</include>
|
<include>de.tr7zw:item-nbt-api</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>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
<include>xyz.upperlevel.spigot.book:spigot-book-api</include>
|
||||||
@ -285,12 +285,6 @@
|
|||||||
<exclude>plugin.yml</exclude>
|
<exclude>plugin.yml</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
<filter>
|
|
||||||
<artifact>de.tr7zw:item-nbt-api-plugin</artifact>
|
|
||||||
<excludes>
|
|
||||||
<exclude>plugin.yml</exclude>
|
|
||||||
</excludes>
|
|
||||||
</filter>
|
|
||||||
</filters>
|
</filters>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
@ -298,7 +292,7 @@
|
|||||||
<shadedPattern>me.pikamug.quests.libs.localelib</shadedPattern>
|
<shadedPattern>me.pikamug.quests.libs.localelib</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>de.tr7zw</pattern>
|
<pattern>de.tr7zw.changeme.nbtapi</pattern>
|
||||||
<shadedPattern>me.pikamug.quests.libs.nbtapi</shadedPattern>
|
<shadedPattern>me.pikamug.quests.libs.nbtapi</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
package me.pikamug.quests;
|
package me.pikamug.quests;
|
||||||
|
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBT;
|
||||||
import me.pikamug.localelib.LocaleManager;
|
import me.pikamug.localelib.LocaleManager;
|
||||||
import me.pikamug.quests.actions.Action;
|
import me.pikamug.quests.actions.Action;
|
||||||
import me.pikamug.quests.actions.BukkitActionFactory;
|
import me.pikamug.quests.actions.BukkitActionFactory;
|
||||||
@ -22,10 +23,17 @@ import me.pikamug.quests.convo.misc.QuestAcceptPrompt;
|
|||||||
import me.pikamug.quests.dependencies.BukkitDenizenTrigger;
|
import me.pikamug.quests.dependencies.BukkitDenizenTrigger;
|
||||||
import me.pikamug.quests.dependencies.BukkitDependencies;
|
import me.pikamug.quests.dependencies.BukkitDependencies;
|
||||||
import me.pikamug.quests.interfaces.ReloadCallback;
|
import me.pikamug.quests.interfaces.ReloadCallback;
|
||||||
import me.pikamug.quests.listeners.*;
|
import me.pikamug.quests.listeners.BukkitBlockListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitCitizensListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitCommandManager;
|
||||||
|
import me.pikamug.quests.listeners.BukkitConvoListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitItemListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitPartiesListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitPlayerListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitUniteListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitZnpcsApiListener;
|
||||||
|
import me.pikamug.quests.listeners.BukkitZnpcsListener;
|
||||||
import me.pikamug.quests.logging.BukkitQuestsLog4JFilter;
|
import me.pikamug.quests.logging.BukkitQuestsLog4JFilter;
|
||||||
import me.pikamug.quests.storage.implementation.jar.BukkitModuleJarStorage;
|
|
||||||
import me.pikamug.quests.storage.implementation.ModuleStorageImpl;
|
|
||||||
import me.pikamug.quests.module.CustomObjective;
|
import me.pikamug.quests.module.CustomObjective;
|
||||||
import me.pikamug.quests.module.CustomRequirement;
|
import me.pikamug.quests.module.CustomRequirement;
|
||||||
import me.pikamug.quests.module.CustomReward;
|
import me.pikamug.quests.module.CustomReward;
|
||||||
@ -36,9 +44,11 @@ import me.pikamug.quests.quests.Quest;
|
|||||||
import me.pikamug.quests.statistics.BukkitMetrics;
|
import me.pikamug.quests.statistics.BukkitMetrics;
|
||||||
import me.pikamug.quests.storage.BukkitStorageFactory;
|
import me.pikamug.quests.storage.BukkitStorageFactory;
|
||||||
import me.pikamug.quests.storage.QuesterStorage;
|
import me.pikamug.quests.storage.QuesterStorage;
|
||||||
|
import me.pikamug.quests.storage.implementation.ModuleStorageImpl;
|
||||||
import me.pikamug.quests.storage.implementation.file.BukkitActionYamlStorage;
|
import me.pikamug.quests.storage.implementation.file.BukkitActionYamlStorage;
|
||||||
import me.pikamug.quests.storage.implementation.file.BukkitConditionYamlStorage;
|
import me.pikamug.quests.storage.implementation.file.BukkitConditionYamlStorage;
|
||||||
import me.pikamug.quests.storage.implementation.file.BukkitQuestYamlStorage;
|
import me.pikamug.quests.storage.implementation.file.BukkitQuestYamlStorage;
|
||||||
|
import me.pikamug.quests.storage.implementation.jar.BukkitModuleJarStorage;
|
||||||
import me.pikamug.quests.tasks.BukkitNpcEffectThread;
|
import me.pikamug.quests.tasks.BukkitNpcEffectThread;
|
||||||
import me.pikamug.quests.tasks.BukkitPlayerMoveThread;
|
import me.pikamug.quests.tasks.BukkitPlayerMoveThread;
|
||||||
import me.pikamug.quests.util.BukkitLang;
|
import me.pikamug.quests.util.BukkitLang;
|
||||||
@ -152,6 +162,9 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
|||||||
conditionFactory = new BukkitConditionFactory(this);
|
conditionFactory = new BukkitConditionFactory(this);
|
||||||
depends = new BukkitDependencies(this);
|
depends = new BukkitDependencies(this);
|
||||||
trigger = new BukkitDenizenTrigger(this);
|
trigger = new BukkitDenizenTrigger(this);
|
||||||
|
if (!NBT.preloadApi()) {
|
||||||
|
getLogger().warning("NBT-API wasn't initialized properly");
|
||||||
|
}
|
||||||
|
|
||||||
// 3 - Load main config
|
// 3 - Load main config
|
||||||
configSettings.init();
|
configSettings.init();
|
||||||
@ -588,7 +601,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests {
|
|||||||
*
|
*
|
||||||
* @param resourcePath jar file location starting from resource folder, i.e. "lang/el-GR/strings.yml"
|
* @param resourcePath jar file location starting from resource folder, i.e. "lang/el-GR/strings.yml"
|
||||||
* @param outputPath file destination starting from Quests folder, i.e. "lang/el-GR/strings.yml"
|
* @param outputPath file destination starting from Quests folder, i.e. "lang/el-GR/strings.yml"
|
||||||
* @param replace whether or not to replace the destination file
|
* @param replace whether to replace the destination file
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveResourceAs(String resourcePath, final String outputPath, final boolean replace) {
|
public void saveResourceAs(String resourcePath, final String outputPath, final boolean replace) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
package me.pikamug.quests.listeners;
|
package me.pikamug.quests.listeners;
|
||||||
|
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBT;
|
||||||
import me.pikamug.quests.BukkitQuestsPlugin;
|
import me.pikamug.quests.BukkitQuestsPlugin;
|
||||||
import me.pikamug.quests.enums.ObjectiveType;
|
import me.pikamug.quests.enums.ObjectiveType;
|
||||||
import me.pikamug.quests.events.quester.BukkitQuesterPostUpdateObjectiveEvent;
|
import me.pikamug.quests.events.quester.BukkitQuesterPostUpdateObjectiveEvent;
|
||||||
@ -26,6 +27,7 @@ import me.pikamug.quests.util.BukkitLang;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.data.Ageable;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -403,7 +405,14 @@ public class BukkitBlockListener implements Listener {
|
|||||||
// https://github.com/PikaMug/Quests/issues/2243
|
// https://github.com/PikaMug/Quests/issues/2243
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return new ItemStack(block.getBlockData().getPlacementMaterial(), 1, durability);
|
// Should only happen on Paper 1.21+
|
||||||
|
final ItemStack item = new ItemStack(block.getBlockData().getPlacementMaterial());
|
||||||
|
if (block.getBlockData() instanceof Ageable) {
|
||||||
|
NBT.modify(item, nbt -> {
|
||||||
|
nbt.setShort("quests_age", (short) ((Ageable)block.getBlockData()).getAge());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return item;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// https://github.com/PikaMug/Quests/issues/2256
|
// https://github.com/PikaMug/Quests/issues/2256
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.alessiodp.parties.api.interfaces.Party;
|
|||||||
import com.alessiodp.parties.api.interfaces.PartyPlayer;
|
import com.alessiodp.parties.api.interfaces.PartyPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBT;
|
||||||
import io.github.znetworkw.znpcservers.npc.NPC;
|
import io.github.znetworkw.znpcservers.npc.NPC;
|
||||||
import lol.pyr.znpcsplus.api.npc.Npc;
|
import lol.pyr.znpcsplus.api.npc.Npc;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
@ -1827,6 +1828,19 @@ public class BukkitQuester implements Quester {
|
|||||||
// Age toBreak unspecified so ignore durability
|
// Age toBreak unspecified so ignore durability
|
||||||
goal = toBreak;
|
goal = toBreak;
|
||||||
}
|
}
|
||||||
|
} else if (Material.getMaterial("CRAFTER") != null && broken.getType().isEdible()) {
|
||||||
|
// Paper 1.21+ is special case
|
||||||
|
final short toBreakAge = NBT.get(toBreak, nbt -> (short) nbt.getShort("quests_age"));
|
||||||
|
final short brokenAge = NBT.get(broken, nbt -> (short) nbt.getShort("quests_age"));
|
||||||
|
if (toBreakAge > 0) {
|
||||||
|
// Age toBreak specified so check for durability
|
||||||
|
if (brokenAge == toBreakAge) {
|
||||||
|
goal = toBreak;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Age toBreak unspecified so ignore durability
|
||||||
|
goal = toBreak;
|
||||||
|
}
|
||||||
} else if (broken.getType().name().equals("RED_ROSE")) {
|
} else if (broken.getType().name().equals("RED_ROSE")) {
|
||||||
// Flowers are unique so check for durability
|
// Flowers are unique so check for durability
|
||||||
if (broken.getDurability() == toBreak.getDurability()) {
|
if (broken.getDurability() == toBreak.getDurability()) {
|
||||||
@ -3820,7 +3834,7 @@ public class BukkitQuester implements Quester {
|
|||||||
final Stage stage = getCurrentStage(quest);
|
final Stage stage = getCurrentStage(quest);
|
||||||
if (stage != null) {
|
if (stage != null) {
|
||||||
quest.updateCompass(this, stage);
|
quest.updateCompass(this, stage);
|
||||||
// TODO - decide whether or not to handle this
|
// TODO - decide whether to handle this
|
||||||
/*if (q.equals(quest) == false) {
|
/*if (q.equals(quest) == false) {
|
||||||
if (getPlayer() != null && getPlayer().isOnline()) {
|
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||||
quitQuest(quest, ChatColor.GOLD + Lang.get("questModified")
|
quitQuest(quest, ChatColor.GOLD + Lang.get("questModified")
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
package me.pikamug.quests.util;
|
package me.pikamug.quests.util;
|
||||||
|
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBT;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
@ -227,11 +228,17 @@ public class BukkitItemUtil {
|
|||||||
if (mat == null) {
|
if (mat == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
ItemStack item;
|
||||||
if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) {
|
if (mat.isBlock() && Material.getMaterial("CRAFTER") != null) {
|
||||||
// Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block)
|
// Paper 1.21+ does not allow ItemStack from unobtainable blocks (i.e. CARROTS block)
|
||||||
mat = mat.createBlockData().getPlacementMaterial();
|
item = new ItemStack(mat.createBlockData().getPlacementMaterial(), amount);
|
||||||
|
NBT.modify(item, nbt -> {
|
||||||
|
nbt.setShort("quests_age", durability);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
item = new ItemStack(mat, amount, durability);
|
||||||
}
|
}
|
||||||
return new ItemStack(mat, amount, durability);
|
return item;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
try {
|
try {
|
||||||
Bukkit.getLogger().warning(material + " x " + amount
|
Bukkit.getLogger().warning(material + " x " + amount
|
||||||
|
Loading…
Reference in New Issue
Block a user