Skip to content

Commit

Permalink
v1.1 - ItemsAdder Support
Browse files Browse the repository at this point in the history
Added a check for ItemsAdder, allows for CustomStack that exists from ItemsAdder to be untouchable by this plugin.

This preserves ItemsAdder's existing functionality with custom blocks / items that are placed into the world using invisible item frames.
  • Loading branch information
Peashooter101 committed Mar 6, 2023
1 parent a80c63c commit ae90dbb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
target
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>adhdmc</groupId>
<artifactId>InvisibleFrames</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<name>InvisibleFrames</name>
Expand Down Expand Up @@ -62,6 +62,11 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<!-- ItemsAdder -->
<repository>
<id>jitpack-repo</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -71,5 +76,11 @@
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>api-itemsadder</artifactId>
<version>3.2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
3 changes: 3 additions & 0 deletions src/main/java/adhdmc/invisibleframes/ClickListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package adhdmc.invisibleframes;

import dev.lone.itemsadder.api.CustomStack;
import dev.lone.itemsadder.api.ItemsAdder;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
Expand All @@ -24,6 +26,7 @@ public void onItemFrameInteract(PlayerInteractEntityEvent event) {
Entity entity = event.getRightClicked();
if (!(entity instanceof ItemFrame itemFrame)) return;
if (itemFrame.getItem().getType().equals(Material.AIR) && !config.getBoolean("toggle-empty", false)) return;
if (InvisibleFrames.hasItemsAdder() && CustomStack.byItemStack(itemFrame.getItem()) != null) return;
if (!player.hasPermission("invisibleframes.toggleframes")) return;

event.setCancelled(true);
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/adhdmc/invisibleframes/InvisibleFrames.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public final class InvisibleFrames extends JavaPlugin {

private static InvisibleFrames instance;
private static boolean hasItemsAdder;

@Override
public void onEnable() {
Expand All @@ -14,9 +15,17 @@ public void onEnable() {
getConfig().addDefault("lock-frame", true);
getConfig().addDefault("toggle-empty", false);
instance = this;
hasItemsAdder = false;
try {
Class.forName("dev.lone.itemsadder.api.CustomBlock");
hasItemsAdder = true;
} catch (ClassNotFoundException e) {
this.getLogger().info("ItemsAdder API has not been found, ItemsAdder checks are disabled.");
}
}

public static InvisibleFrames getInstance() {
return instance;
}
public static boolean hasItemsAdder() { return hasItemsAdder; }
}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ api-version: 1.18
prefix: "[Invisible Frames]"
authors: [ _Rhythmic ]
description: Allows easy toggling of item frames from visible to invisible
softdepend: ["ItemsAdder"]
commands:
ifreload:
permission: invisibleframes.reload
Expand Down

0 comments on commit ae90dbb

Please sign in to comment.