diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index 248c8ff..f93fa5b 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -21,6 +21,7 @@ import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityInteractEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.server.ServerListPingEvent; @@ -52,6 +53,7 @@ public final class Main extends JavaPlugin implements Listener { getCommand("msg").setExecutor(new MessageCommand()); getCommand("menu").setExecutor(new MenuCommand()); getCommand("rank").setExecutor(new RankCommand(this)); + getCommand("hologram").setExecutor(new HologramCommand()); bossbar = Bukkit.createBossBar( ChatColor.GOLD + "Kuudra", BarColor.RED, @@ -130,6 +132,11 @@ public final class Main extends JavaPlugin implements Listener { } } - +// For hologram clicks to change page +// @EventHandler +// public void onEntityInteract(EntityInteractEvent e) { +// System.out.println(e.getEntity().getLocation()); +// e.getEntity().setCustomName(ChatColor.RED + "Changed name since you ust clicked lol"); +// } } diff --git a/src/main/java/com/night/nullvalkyrie/SideBar/SideBarListener.java b/src/main/java/com/night/nullvalkyrie/SideBar/SideBarListener.java index a7bc5ea..73ff4b8 100644 --- a/src/main/java/com/night/nullvalkyrie/SideBar/SideBarListener.java +++ b/src/main/java/com/night/nullvalkyrie/SideBar/SideBarListener.java @@ -7,9 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scoreboard.*; import java.util.HashMap; diff --git a/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java b/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java new file mode 100644 index 0000000..1b1490b --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/HologramCommand.java @@ -0,0 +1,35 @@ +package com.night.nullvalkyrie.commands; + +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +public class HologramCommand implements CommandExecutor { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(sender instanceof Player) { + Player player = (Player) sender; + String[] ar = new String[]{ + ChatColor.AQUA + "Hi", + ChatColor.DARK_PURPLE + "What", + ChatColor.GOLD + "Hello World" + }; + Location location = player.getLocation(); + for(String line: ar) { + ArmorStand stand = (ArmorStand) player.getWorld().spawnEntity(location.subtract(0,0.3,0), EntityType.ARMOR_STAND); + stand.setInvisible(true); + stand.setGravity(false); + stand.setInvulnerable(true); + stand.setCustomNameVisible(true); + stand.setCustomName(line); + } + } + + return false; + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java b/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java index 7fdbc71..6b8bc2e 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/RankCommand.java @@ -1,5 +1,7 @@ package com.night.nullvalkyrie.commands; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import com.night.nullvalkyrie.Main; import com.night.nullvalkyrie.RankSys.Rank; import org.bukkit.Bukkit; @@ -9,17 +11,22 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; + +import java.util.UUID; +import java.util.concurrent.TimeUnit; + //92.0.69.141:25565 public class RankCommand implements CommandExecutor { private Main main; public RankCommand(Main main) { this.main = main; } + private Cache cooldown = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.SECONDS).build(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player) { Player player = (Player) sender; - if(player.isOp()) { + if(!cooldown.asMap().containsKey(player.getUniqueId())) {if(player.isOp()) { if(args.length == 2) { if(Bukkit.getOfflinePlayer(args[0]).hasPlayedBefore()) { OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); @@ -43,6 +50,11 @@ public class RankCommand implements CommandExecutor { } else { player.sendMessage(ChatColor.RED + "You must be server operator to use this command"); } + cooldown.put(player.getUniqueId(), System.currentTimeMillis() + 5000); + } else { + long distance = cooldown.asMap().get(player.getUniqueId()) - System.currentTimeMillis(); + player.sendMessage(ChatColor.RED + "You are on a " + TimeUnit.MILLISECONDS.toSeconds(distance) + " seconds cooldown to use the command again"); + } } return false; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b69ed6c..59985af 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -19,4 +19,6 @@ commands: menu: description: "Open the menu" rank: - description: "Set rank of players" \ No newline at end of file + description: "Set rank of players" + hologram: + description: "Spawn a hologram" \ No newline at end of file