mirror of
https://github.com/Auxilor/Reforges.git
synced 2026-01-03 22:26:33 +00:00
Added open sound
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.willfp.reforges.commands;
|
||||
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.TabCompleteHandler;
|
||||
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.reforges.gui.ReforgeGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandOpen extends PluginCommand {
|
||||
/**
|
||||
* Instantiate a new command handler.
|
||||
*
|
||||
* @param plugin The plugin for the commands to listen for.
|
||||
*/
|
||||
public CommandOpen(@NotNull final EcoPlugin plugin) {
|
||||
super(plugin, "open", "reforges.command.open", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("needs-player"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args.get(0));
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-player"));
|
||||
return;
|
||||
}
|
||||
|
||||
player.playSound(
|
||||
player.getLocation(),
|
||||
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.open-sound.id").toUpperCase()),
|
||||
1f,
|
||||
(float) this.getPlugin().getConfigYml().getDouble("gui.open-sound.pitch")
|
||||
);
|
||||
ReforgeGUI.getMenu().open(player);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabCompleteHandler getTabCompleter() {
|
||||
return (sender, args) -> {
|
||||
List<String> completions = new ArrayList<>();
|
||||
|
||||
if (args.size() == 1) {
|
||||
StringUtil.copyPartialMatches(args.get(0), Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()), completions);
|
||||
return completions;
|
||||
}
|
||||
|
||||
return new ArrayList<>(0);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||
import com.willfp.reforges.gui.ReforgeGUI;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -21,7 +22,15 @@ public class CommandReforge extends PluginCommand {
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
ReforgeGUI.getMenu().open((Player) sender);
|
||||
Player player = (Player) sender;
|
||||
|
||||
player.playSound(
|
||||
player.getLocation(),
|
||||
Sound.valueOf(this.getPlugin().getConfigYml().getString("gui.open-sound.id").toUpperCase()),
|
||||
1f,
|
||||
(float) this.getPlugin().getConfigYml().getDouble("gui.open-sound.pitch")
|
||||
);
|
||||
ReforgeGUI.getMenu().open(player);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ public class CommandReforges extends PluginCommand {
|
||||
super(plugin, "reforges", "reforges.command.reforges", false);
|
||||
|
||||
this.addSubcommand(new CommandReload(plugin))
|
||||
.addSubcommand(new CommandGive(plugin));
|
||||
.addSubcommand(new CommandGive(plugin))
|
||||
.addSubcommand(new CommandOpen(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -229,8 +229,7 @@ public class ReforgeGUI {
|
||||
).onLeftClick((event, slot) -> {
|
||||
event.getWhoClicked().closeInventory();
|
||||
}).build()
|
||||
)
|
||||
.build();
|
||||
).build();
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -47,6 +47,10 @@ gui:
|
||||
id: BLOCK_ANVIL_USE
|
||||
pitch: 1
|
||||
|
||||
open-sound:
|
||||
id: BLOCK_ANVIL_PLACE
|
||||
pitch: 0.8
|
||||
|
||||
stone-sound:
|
||||
id: ENTITY_ENDER_DRAGON_HURT
|
||||
pitch: 0.5
|
||||
|
||||
@@ -32,6 +32,7 @@ permissions:
|
||||
reforges.command.reforges: true
|
||||
reforges.command.reforge: true
|
||||
reforges.command.give: true
|
||||
reforges.command.open: true
|
||||
|
||||
reforges.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -41,7 +42,10 @@ permissions:
|
||||
default: true
|
||||
reforges.command.reforge:
|
||||
description: Allows the user of /reforge.
|
||||
default: op
|
||||
default: true
|
||||
reforges.command.give:
|
||||
description: Allows the user of /reforges give.
|
||||
default: op
|
||||
reforges.command.open:
|
||||
description: Allows the user of /reforges open.
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user