Compare commits
No commits in common. "main" and "1.0-SNAPSHOT" have entirely different histories.
main
...
1.0-SNAPSH
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
41
README.MD
41
README.MD
|
@ -1,41 +0,0 @@
|
|||
# CustomBlockCMD
|
||||
|
||||
Something similar was requested [here](https://www.spigotmc.org/threads/clickable-items-command.492629/).
|
||||
|
||||
```#======================================================================================#
|
||||
# NVus PRISON SETUP #
|
||||
# by never2nv #
|
||||
# www.FNGnation.net #
|
||||
# Discord: FNGnation.net/discord #
|
||||
#======================================================================================#
|
||||
|
||||
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
|
||||
|
||||
```
|
|
@ -9,6 +9,7 @@ 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
|
||||
|
@ -26,18 +27,12 @@ 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", "");
|
||||
|
|
|
@ -6,32 +6,19 @@
|
|||
#======================================================================================#
|
||||
|
||||
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
|
||||
|
||||
...
|
||||
command: give @p emerald
|
Binary file not shown.
Binary file not shown.
|
@ -6,32 +6,19 @@
|
|||
#======================================================================================#
|
||||
|
||||
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
|
||||
|
||||
...
|
||||
command: give @p emerald
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue