diff --git a/Core.iml b/Core.iml index 4a2df32..5039352 100644 --- a/Core.iml +++ b/Core.iml @@ -1,5 +1,5 @@ - + @@ -20,7 +20,6 @@ - @@ -79,7 +78,6 @@ - \ No newline at end of file diff --git a/pom.xml b/pom.xml index b7a26b0..52e5d39 100644 --- a/pom.xml +++ b/pom.xml @@ -95,12 +95,6 @@ lombok 1.16.10 - - de.slikey - EffectLib - 5.2 - provided - co.aikar taskchain-bukkit diff --git a/src/main/java/eu/univento/core/Core.java b/src/main/java/eu/univento/core/Core.java index 350cad2..62bbf50 100644 --- a/src/main/java/eu/univento/core/Core.java +++ b/src/main/java/eu/univento/core/Core.java @@ -153,7 +153,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { new GlobalMute(this, "globalmute", "mutes the server"); new ChatClear(this, "chatclear", "clears the chat", "cc"); new Timeout(this, "timeout", "timeout other players"); - new ParticleEffect(this, "particleeffect", "plays particle effects", "pe"); + new Hologram(this, "hologram", "manages holograms"); PluginMessenger pluginMessenger = new PluginMessenger(); NetworkData networkData = new NetworkData(); diff --git a/src/main/java/eu/univento/core/api/hologram/Hologram.java b/src/main/java/eu/univento/core/api/hologram/Hologram.java index 3402426..81d05d8 100644 --- a/src/main/java/eu/univento/core/api/hologram/Hologram.java +++ b/src/main/java/eu/univento/core/api/hologram/Hologram.java @@ -8,6 +8,7 @@ package eu.univento.core.api.hologram; import eu.univento.core.Core; import eu.univento.core.api.events.HologramClickEvent; import eu.univento.core.api.player.CustomPlayer; +import lombok.Getter; import net.minecraft.server.v1_11_R1.EntityArmorStand; import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving; @@ -28,12 +29,15 @@ import java.util.List; */ public class Hologram implements Listener{ + private final String name; private final List stands = new ArrayList<>(); private final String[] text; - private final Location location; + @Getter private final Location location; private int count; - public Hologram(String[] text, Location location) { + public Hologram(String name, String[] text, Location location) { + this.name = name; + HologramManager.addHologram(name, this); this.text = text; this.location = location; create(); @@ -56,6 +60,7 @@ public class Hologram implements Listener{ for(EntityArmorStand armorStand : stands) { armorStand.die(); } + HologramManager.removeHologram(name); } private void create() { diff --git a/src/main/java/eu/univento/core/api/hologram/HologramManager.java b/src/main/java/eu/univento/core/api/hologram/HologramManager.java new file mode 100644 index 0000000..4d865e8 --- /dev/null +++ b/src/main/java/eu/univento/core/api/hologram/HologramManager.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.hologram; + +import lombok.Getter; + +import java.util.HashMap; + +/** + * @author joethei + * @version 0.1 + */ +public class HologramManager { + + @Getter private static HashMap holograms = new HashMap<>(); + + public static Hologram getHologram(String name) { + return holograms.get(name); + } + + static void addHologram(String name, Hologram hologram) { + holograms.put(name, hologram); + } + + static void removeHologram(String name) { + holograms.remove(name); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/commands/Hologram.java b/src/main/java/eu/univento/core/commands/Hologram.java new file mode 100644 index 0000000..4479575 --- /dev/null +++ b/src/main/java/eu/univento/core/commands/Hologram.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.commands; + +import eu.univento.commons.player.language.MessageConstant; +import eu.univento.commons.player.rank.Rank; +import eu.univento.commons.utils.Strings; +import eu.univento.core.Core; +import eu.univento.core.api.AutoCommand; +import eu.univento.core.api.hologram.HologramManager; +import eu.univento.core.api.languages.Messages; +import eu.univento.core.api.player.CustomPlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * @author joethei + * @version 0.1 + */ +public class Hologram extends AutoCommand { + + public Hologram(Core plugin, String command, String description, String... aliases) { + super(plugin, command, description, aliases); + } + + @Override + public boolean execute(CommandSender sender, String label, String[] args) { + if(sender instanceof Player) { + CustomPlayer p = CustomPlayer.getPlayer(((Player) sender)); + if(p.getDatabasePlayer().isAllowed(Rank.JrBuilder)) { + if(args.length == 0) { + p.sendMessage("/hologram add "); + p.sendMessage("/hologram remove "); + p.sendMessage("/hologram list"); + } + if(args.length == 1) { + if(args[0].equalsIgnoreCase("list")) { + HologramManager.getHolograms().forEach((s, hologram) -> p.sendMessage("§6" + s + hologram.getLocation().toString())); + } + } + if(args.length == 2) { + if(args[0].equalsIgnoreCase("remove")) { + if(HologramManager.getHologram(args[1]) != null) { + HologramManager.getHologram(args[1]).destroy(); + }else p.sendMessage("Dieses Hologram gibt es nicht"); + } + }else { + if (args[0].equalsIgnoreCase("add")) { + if(HologramManager.getHologram(args[1]) != null) { + p.sendMessage("Dieses Hologram gibt es schon"); + }else { + String name = args[1]; + args = Strings.remove(args, "add"); + args = Strings.remove(args, name); + new eu.univento.core.api.hologram.Hologram(name, args, p.getLocation()); + } + } + } + }else { + p.getDatabasePlayer().getLanguage().getMessage(MessageConstant.COMMAND_NO_PERMS); + } + }else sender.sendMessage(Messages.Console.NOT_A_PLAYER); + return true; + } + + @Override + public List tabComplete(CommandSender sender, String label, String[] args) { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/commands/ParticleEffect.java b/src/main/java/eu/univento/core/commands/ParticleEffect.java deleted file mode 100644 index 33e89c5..0000000 --- a/src/main/java/eu/univento/core/commands/ParticleEffect.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2016 univento.eu - All rights reserved - * You are not allowed to use, distribute or modify this code - */ - -package eu.univento.core.commands; - -import de.slikey.effectlib.effect.*; -import eu.univento.core.Core; -import eu.univento.core.api.AutoCommand; -import eu.univento.core.api.languages.Messages; -import eu.univento.core.api.player.CustomPlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; - -/** - * @author joethei - * @version 0.1 - */ -public class ParticleEffect extends AutoCommand { - - public ParticleEffect(Core plugin, String command, String description, String... aliases) { - super(plugin, command, description, aliases); - } - - @Override - public boolean execute(CommandSender sender, String label, String[] args) { - if(sender instanceof Player) { - CustomPlayer p = CustomPlayer.getPlayer((Player) sender); - if(args.length == 0) p.sendMessage("§cNot enough arguments"); - if(args.length == 1) { - String arg = args[0]; - if(arg.equalsIgnoreCase("ball")) { - AnimatedBallEffect effect = new AnimatedBallEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("arc")) { - ArcEffect effect = new ArcEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("atom")) { - AtomEffect effect = new AtomEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("bigbang")) { - BigBangEffect effect = new BigBangEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("bleed")) { - BleedEffect effect = new BleedEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("circle")) { - CircleEffect effect = new CircleEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("cloud")) { - CloudEffect effect = new CloudEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.start(); - } - if(arg.equalsIgnoreCase("text")) { - TextEffect effect = new TextEffect(Core.getEffectManager()); - effect.setLocation(p.getLocation()); - effect.text = "Hallo du da"; - effect.start(); - } - - } - }else { - sender.sendMessage(Messages.Console.NOT_A_PLAYER); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String label, String[] args) { - return null; - } -} \ No newline at end of file