shulker
This commit is contained in:
@@ -57,6 +57,8 @@ public final class OgreDupeAlias extends JavaPlugin {
|
||||
getCommand("recipespy").setTabCompleter(new RecipeSpyCommand());
|
||||
getCommand("irepair").setExecutor(new IRepairCommand());
|
||||
getCommand("irepair").setTabCompleter(new IRepairCommand());
|
||||
getCommand("message").setExecutor(new MessageCommand());
|
||||
getCommand("message").setTabCompleter(new MessageCommand());
|
||||
}
|
||||
|
||||
public void initConfig() {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package io.github.itzispyder.ogredupealias.commands.commands;
|
||||
|
||||
import io.github.itzispyder.ogredupealias.commands.CmdExHandler;
|
||||
import io.github.itzispyder.ogredupealias.commands.TabComplBuilder;
|
||||
import io.github.itzispyder.ogredupealias.utils.ArrayUtils;
|
||||
import io.github.itzispyder.ogredupealias.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MessageCommand implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
try {
|
||||
final Player messenger = (Player) sender;
|
||||
final Player recipient = Bukkit.getPlayer(args[0]);
|
||||
|
||||
args[0] = null;
|
||||
final String msg = String.join(" ", Arrays.stream(args).filter(Objects::nonNull).toList());
|
||||
|
||||
messenger.sendMessage(Text.builder("&7[&bPM&7] &3me &7to &3" + recipient.getName() + " &8>> &b&o" + msg).color().prefix().build());
|
||||
recipient.sendMessage(Text.builder("&7[&bPM&7] &3" + messenger.getName() + " &7to &3me &8>> &b&o" + msg).color().prefix().build());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
CmdExHandler handler = new CmdExHandler(ex,command);
|
||||
sender.sendMessage(handler.getHelp());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
return new TabComplBuilder(sender,command,label,args)
|
||||
.add(1, ArrayUtils.toNewList(Bukkit.getOnlinePlayers(), Player::getName))
|
||||
.add(2, new String[]{
|
||||
"[<message>]"
|
||||
},args.length >= 2 && args[1].isBlank())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,9 @@ public class CommandEventListener implements Listener {
|
||||
"/whisper",
|
||||
"/w",
|
||||
"/message",
|
||||
"/msg"
|
||||
"/msg",
|
||||
"/dm",
|
||||
"/pm"
|
||||
);
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -22,15 +22,15 @@ public class InteractionListener implements Listener {
|
||||
final Block b = e.getClickedBlock();
|
||||
final ItemStack item = e.getItem();
|
||||
|
||||
if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
|
||||
ShulkerUtils.onShulkerInteraction(e);
|
||||
}
|
||||
|
||||
if (PlacedStructures.isCustomTable(b)) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(InventoryPresets.createCustomTable());
|
||||
return;
|
||||
}
|
||||
|
||||
if (a == Action.RIGHT_CLICK_AIR || a == Action.RIGHT_CLICK_BLOCK) {
|
||||
ShulkerUtils.onShulkerInteraction(e);
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public abstract class ShulkerUtils {
|
||||
final ItemStack item = e.getItem();
|
||||
final Action a = e.getAction();
|
||||
|
||||
if (!e.isCancelled() && a == Action.RIGHT_CLICK_BLOCK) return;
|
||||
if (item == null || item.getType().isAir()) return;
|
||||
if (a != Action.RIGHT_CLICK_BLOCK && a != Action.RIGHT_CLICK_AIR) return;
|
||||
if (!item.getType().name().contains("SHULKER_BOX")) return;
|
||||
@@ -48,6 +49,7 @@ public abstract class ShulkerUtils {
|
||||
final Player p = (Player) e.getWhoClicked();
|
||||
|
||||
final ItemStack item = lastOpenedBox.get(p.getUniqueId());
|
||||
if (item == null || !item.getType().name().contains("SHULKER_BOX")) return;
|
||||
final BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
|
||||
final ShulkerBox box = (ShulkerBox) meta.getBlockState();
|
||||
|
||||
@@ -62,6 +64,7 @@ public abstract class ShulkerUtils {
|
||||
final Player p = (Player) e.getPlayer();
|
||||
|
||||
final ItemStack item = lastOpenedBox.get(p.getUniqueId());
|
||||
if (item == null || !item.getType().name().contains("SHULKER_BOX")) return;
|
||||
final BlockStateMeta meta = (BlockStateMeta) item.getItemMeta();
|
||||
final ShulkerBox box = (ShulkerBox) meta.getBlockState();
|
||||
|
||||
|
||||
@@ -94,3 +94,14 @@ commands:
|
||||
aliases:
|
||||
- ipearlrepair
|
||||
- irestock
|
||||
message:
|
||||
description: Private message a player
|
||||
usage: /message <player> [<message>]
|
||||
aliases:
|
||||
- msg
|
||||
- pm
|
||||
- dm
|
||||
- tell
|
||||
- whisper
|
||||
- w
|
||||
- message
|
||||
Reference in New Issue
Block a user