v1.0-SNAPSHOT
This commit is contained in:
parent
9df37fa7f5
commit
4214b562bf
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -9,7 +9,6 @@ import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
public class CustomBlockCMD extends JavaPlugin implements Listener {
|
public class CustomBlockCMD extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,12 +26,18 @@ public class CustomBlockCMD extends JavaPlugin implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
Material heldMaterial = player.getInventory().getItemInMainHand().getType();
|
||||||
if (event.getAction().toString().contains("RIGHT")) {
|
if (event.getAction().toString().contains("RIGHT")) {
|
||||||
Material clickedMaterial = event.getClickedBlock().getType();
|
Material clickedMaterial = event.getClickedBlock().getType();
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
|
|
||||||
ConfigurationSection blockSection = config.getConfigurationSection(clickedMaterial.toString());
|
ConfigurationSection blockSection = config.getConfigurationSection(clickedMaterial.toString());
|
||||||
if (blockSection != null) {
|
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 cmdType = blockSection.getString("cmd-type");
|
||||||
String command = blockSection.getString("command");
|
String command = blockSection.getString("command");
|
||||||
String message = blockSection.getString("message", "");
|
String message = blockSection.getString("message", "");
|
||||||
|
|
|
@ -6,19 +6,32 @@
|
||||||
#======================================================================================#
|
#======================================================================================#
|
||||||
|
|
||||||
GOLD_BLOCK:
|
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
|
cmd-type: player
|
||||||
|
# Command to execute
|
||||||
command: warp shop
|
command: warp shop
|
||||||
|
# Optional message to send to the player. Leave "" for no message.
|
||||||
message: "Teleporting to the shop..."
|
message: "Teleporting to the shop..."
|
||||||
|
|
||||||
DIAMOND_BLOCK:
|
DIAMOND_BLOCK:
|
||||||
|
action-type: hand
|
||||||
cmd-type: server
|
cmd-type: server
|
||||||
command: give @p diamond
|
command: give @p diamond
|
||||||
|
|
||||||
IRON_BLOCK:
|
IRON_BLOCK:
|
||||||
|
action-type: hand
|
||||||
cmd-type: player
|
cmd-type: player
|
||||||
command: spawn
|
command: spawn
|
||||||
message: "Teleporting to spawn..."
|
message: "Teleporting to spawn..."
|
||||||
|
|
||||||
EMERALD_BLOCK:
|
EMERALD_BLOCK:
|
||||||
|
action-type: world
|
||||||
cmd-type: server
|
cmd-type: server
|
||||||
command: give @p emerald
|
command: give @p emerald
|
||||||
|
|
||||||
|
...
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -6,19 +6,32 @@
|
||||||
#======================================================================================#
|
#======================================================================================#
|
||||||
|
|
||||||
GOLD_BLOCK:
|
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
|
cmd-type: player
|
||||||
|
# Command to execute
|
||||||
command: warp shop
|
command: warp shop
|
||||||
|
# Optional message to send to the player. Leave "" for no message.
|
||||||
message: "Teleporting to the shop..."
|
message: "Teleporting to the shop..."
|
||||||
|
|
||||||
DIAMOND_BLOCK:
|
DIAMOND_BLOCK:
|
||||||
|
action-type: hand
|
||||||
cmd-type: server
|
cmd-type: server
|
||||||
command: give @p diamond
|
command: give @p diamond
|
||||||
|
|
||||||
IRON_BLOCK:
|
IRON_BLOCK:
|
||||||
|
action-type: hand
|
||||||
cmd-type: player
|
cmd-type: player
|
||||||
command: spawn
|
command: spawn
|
||||||
message: "Teleporting to spawn..."
|
message: "Teleporting to spawn..."
|
||||||
|
|
||||||
EMERALD_BLOCK:
|
EMERALD_BLOCK:
|
||||||
|
action-type: world
|
||||||
cmd-type: server
|
cmd-type: server
|
||||||
command: give @p emerald
|
command: give @p emerald
|
||||||
|
|
||||||
|
...
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue