Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit 48e7a83

Browse files
committed
Invisible item frames support - 1.2.0
1 parent a554718 commit 48e7a83

4 files changed

Lines changed: 31 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
bin/
2-
.classpath
3-
.project
4-
.settings
2+
build/
3+
.idea/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package fr.peaceandcube.pacpi.event;
2+
3+
import org.bukkit.Material;
4+
import org.bukkit.entity.ItemFrame;
5+
import org.bukkit.event.EventHandler;
6+
import org.bukkit.event.Listener;
7+
import org.bukkit.event.hanging.HangingPlaceEvent;
8+
import org.bukkit.inventory.ItemStack;
9+
10+
public class PlayerEventHandler implements Listener {
11+
12+
@EventHandler
13+
public void onItemFramePlace(HangingPlaceEvent event) {
14+
if (event.getPlayer() != null && event.getEntity() instanceof ItemFrame) {
15+
ItemStack handItem = event.getPlayer().getInventory().getItemInMainHand();
16+
ItemFrame itemFrame = (ItemFrame) event.getEntity();
17+
18+
if (handItem.getType() == Material.ITEM_FRAME && handItem.getItemMeta().getDisplayName().equalsIgnoreCase("invisible")) {
19+
itemFrame.setVisible(false);
20+
}
21+
}
22+
}
23+
}

src/fr/peaceandcube/pacpi/pAcPI.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.peaceandcube.pacpi;
22

3+
import fr.peaceandcube.pacpi.event.PlayerEventHandler;
34
import org.bukkit.plugin.java.JavaPlugin;
45

56
import fr.peaceandcube.pacpi.command.ChronoCommand;
@@ -11,5 +12,7 @@ public class pAcPI extends JavaPlugin {
1112
public void onEnable() {
1213
this.getCommand("removealltags").setExecutor(new RemoveAllTagsCommand());
1314
this.getCommand("chrono").setExecutor(new ChronoCommand());
15+
16+
this.getServer().getPluginManager().registerEvents(new PlayerEventHandler(), this);
1417
}
1518
}

src/plugin.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
main: fr.peaceandcube.pacpi.pAcPI
22
name: pAcPI
3-
version: 1.1.0
4-
author: Yanis48
3+
version: 1.2.0
4+
author: YanisBft
5+
website: https://github.com/PeaceAndCubeMC/pAcPI
56
api-version: 1.13
67

78
commands:

0 commit comments

Comments
 (0)