diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/me/nvus/customblockcmd/CustomBlockCMD.java b/src/main/java/me/nvus/customblockcmd/CustomBlockCMD.java index a342309..c8ae7d5 100644 --- a/src/main/java/me/nvus/customblockcmd/CustomBlockCMD.java +++ b/src/main/java/me/nvus/customblockcmd/CustomBlockCMD.java @@ -9,7 +9,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.plugin.java.JavaPlugin; - public class CustomBlockCMD extends JavaPlugin implements Listener { @Override @@ -27,12 +26,18 @@ public class CustomBlockCMD extends JavaPlugin implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); + Material heldMaterial = player.getInventory().getItemInMainHand().getType(); if (event.getAction().toString().contains("RIGHT")) { Material clickedMaterial = event.getClickedBlock().getType(); FileConfiguration config = getConfig(); ConfigurationSection blockSection = config.getConfigurationSection(clickedMaterial.toString()); if (blockSection != null) { + String actionType = blockSection.getString("action-type", "hand"); + if (actionType.equalsIgnoreCase("hand") && !heldMaterial.equals(clickedMaterial)) { + return; // Skip if action-type is hand and the held item doesn't match the clicked block + } + String cmdType = blockSection.getString("cmd-type"); String command = blockSection.getString("command"); String message = blockSection.getString("message", ""); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 268a082..9f9b0a5 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,19 +6,32 @@ #======================================================================================# GOLD_BLOCK: + # Action type: hand or world. Hand means if the player has this block in their hand + # and right clicks it'll execute the command and optional message. + # world means if they right-click on this block anywhere in the world they see it + # it'll execute the command and optional message. + action-type: world + # Command type: player or server. Player means it'll execute the command as the player cmd-type: player + # Command to execute command: warp shop + # Optional message to send to the player. Leave "" for no message. message: "Teleporting to the shop..." DIAMOND_BLOCK: + action-type: hand cmd-type: server command: give @p diamond IRON_BLOCK: + action-type: hand cmd-type: player command: spawn message: "Teleporting to spawn..." EMERALD_BLOCK: + action-type: world cmd-type: server - command: give @p emerald \ No newline at end of file + command: give @p emerald + +... diff --git a/target/CustomBlockCMD-1.0-SNAPSHOT-shaded.jar b/target/CustomBlockCMD-1.0-SNAPSHOT-shaded.jar new file mode 100644 index 0000000..994cc76 Binary files /dev/null and b/target/CustomBlockCMD-1.0-SNAPSHOT-shaded.jar differ diff --git a/target/CustomBlockCMD-1.0-SNAPSHOT.jar b/target/CustomBlockCMD-1.0-SNAPSHOT.jar index 8d0ae24..994cc76 100644 Binary files a/target/CustomBlockCMD-1.0-SNAPSHOT.jar and b/target/CustomBlockCMD-1.0-SNAPSHOT.jar differ diff --git a/target/classes/config.yml b/target/classes/config.yml index 268a082..9f9b0a5 100644 --- a/target/classes/config.yml +++ b/target/classes/config.yml @@ -6,19 +6,32 @@ #======================================================================================# GOLD_BLOCK: + # Action type: hand or world. Hand means if the player has this block in their hand + # and right clicks it'll execute the command and optional message. + # world means if they right-click on this block anywhere in the world they see it + # it'll execute the command and optional message. + action-type: world + # Command type: player or server. Player means it'll execute the command as the player cmd-type: player + # Command to execute command: warp shop + # Optional message to send to the player. Leave "" for no message. message: "Teleporting to the shop..." DIAMOND_BLOCK: + action-type: hand cmd-type: server command: give @p diamond IRON_BLOCK: + action-type: hand cmd-type: player command: spawn message: "Teleporting to spawn..." EMERALD_BLOCK: + action-type: world cmd-type: server - command: give @p emerald \ No newline at end of file + command: give @p emerald + +... diff --git a/target/classes/me/nvus/customblockcmd/CustomBlockCMD.class b/target/classes/me/nvus/customblockcmd/CustomBlockCMD.class index f70a35d..776509c 100644 Binary files a/target/classes/me/nvus/customblockcmd/CustomBlockCMD.class and b/target/classes/me/nvus/customblockcmd/CustomBlockCMD.class differ diff --git a/target/original-CustomBlockCMD-1.0-SNAPSHOT.jar b/target/original-CustomBlockCMD-1.0-SNAPSHOT.jar index a7691b7..1d45a36 100644 Binary files a/target/original-CustomBlockCMD-1.0-SNAPSHOT.jar and b/target/original-CustomBlockCMD-1.0-SNAPSHOT.jar differ