Click to copy repeater
Also added translation for copying
This commit is contained in:
parent
1acfcd273d
commit
812b16e4be
3 changed files with 19 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
package eu.m724.tweaks.auth;
|
||||
|
||||
import eu.m724.tweaks.Language;
|
||||
import eu.m724.tweaks.TweaksConfig;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
@ -50,7 +51,7 @@ public class AuthCommands implements CommandExecutor {
|
|||
.underlined(true)
|
||||
.color(ChatColor.GRAY)
|
||||
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, hostname))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to copy")))
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Language.getString("clickToCopy"))))
|
||||
.build();
|
||||
sender.spigot().sendMessage(component);
|
||||
} else {
|
||||
|
|
|
@ -7,6 +7,12 @@
|
|||
package eu.m724.tweaks.redstone;
|
||||
|
||||
import eu.m724.tweaks.DebugLogger;
|
||||
import eu.m724.tweaks.Language;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
|
@ -45,13 +51,19 @@ public class RedstoneListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
if (event.getClickedBlock() == null) return;
|
||||
if (!event.getPlayer().isSneaking()) return;
|
||||
|
||||
var id = redstoneRepeaters.getId(event.getClickedBlock());
|
||||
if (id == Integer.MIN_VALUE) return;
|
||||
|
||||
// TODO find a less lame way of showing ID
|
||||
event.getPlayer().sendMessage("Repeater ID: " + id);
|
||||
var component = new ComponentBuilder("Repeater ID: ").color(ChatColor.GOLD)
|
||||
.append(String.valueOf(id)).color(ChatColor.AQUA)
|
||||
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Language.getString("clickToCopy"))))
|
||||
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, String.valueOf(id)))
|
||||
.build();
|
||||
|
||||
event.getPlayer().spigot().sendMessage(component);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
@ -30,4 +30,6 @@ authKickWrongKey = You're connecting to the wrong server address. You must conne
|
|||
# If force is enabled and player is not registered. Changing this reveals you're using this plugin
|
||||
authKickUnregistered = You are not whitelisted on this server!
|
||||
|
||||
retstoneBlockItem = Online redstone block
|
||||
retstoneBlockItem = Online redstone block
|
||||
|
||||
clickToCopy = Click to copy to clipboard
|
Loading…
Reference in a new issue