Skip to content

Commit

Permalink
🐛 Players cannot place quest items as blocks anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
SkytAsul committed Dec 2, 2023
1 parent 062136d commit 718d193
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public enum Lang implements Locale {
QUEST_ITEM_DROP("msg.questItem.drop"),
QUEST_ITEM_CRAFT("msg.questItem.craft"),
QUEST_ITEM_EAT("msg.questItem.eat"),
QUEST_ITEM_PLACE("msg.questItem.place"),

STAGE_MOBSLIST("msg.stageMobs.listMobs"),

Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/fr/skytasul/quests/QuestsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent;
Expand Down Expand Up @@ -195,6 +196,14 @@ public void onDeath(PlayerDeathEvent e) {
if (BeautyQuests.getInstance().isRunningPaper()) Paper.handleDeathItems(e, Utils::isQuestItem);
}

@EventHandler
public void onPlace(BlockPlaceEvent e) {
if (Utils.isQuestItem(e.getItemInHand())) {
e.setCancelled(true);
Lang.QUEST_ITEM_PLACE.send(e.getPlayer());
}
}

@EventHandler(priority = EventPriority.HIGHEST)
public void onBreak(BlockBreakEvent e) {
if (e.isCancelled()) return;
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/resources/locales/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ msg:
noAvailable: §7There is no more quest available...
maxQuests: §cYou cannot have more than {pool_max_quests} quest(s) at the same time...
questItem:
drop: §cYou can't drop a quest item!
craft: §cYou can't use a quest item to craft!
drop: §cYou cannot drop a quest item!
craft: §cYou cannot use a quest item to craft!
eat: §cYou cannot eat a quest item!
place: §cYou cannot place a quest item!
stageMobs:
listMobs: §aYou must kill {mobs}.
writeNPCText: '§aWrite the dialog that will be said to the player by the NPC: (Write
Expand Down

0 comments on commit 718d193

Please sign in to comment.