~ made the holgram system even better

+ hologram management command
This commit is contained in:
Johannes Theiner 2017-04-08 21:20:12 +02:00
parent c5ad06d15d
commit d31acecb91
7 changed files with 115 additions and 101 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module com.demonwav.mcdev.MinecraftModuleTypes="PAPER_MODULE_TYPE" org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
@ -20,7 +20,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.slikey:EffectLib:5.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.11-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
@ -79,7 +78,6 @@
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: com.github.nsp:JSkills:master-0.9.0-g8b333ec-15" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.slikey:EffectLib:5.2" level="project" />
<orderEntry type="library" name="Maven: co.aikar:taskchain-bukkit:3.4.3" level="project" />
</component>
</module>

View File

@ -95,12 +95,6 @@
<artifactId>lombok</artifactId>
<version>1.16.10</version>
</dependency>
<dependency>
<groupId>de.slikey</groupId>
<artifactId>EffectLib</artifactId>
<version>5.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>taskchain-bukkit</artifactId>

View File

@ -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();

View File

@ -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<EntityArmorStand> 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() {

View File

@ -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<String, Hologram> 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);
}
}

View File

@ -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<Core> {
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 <Name> <Nachricht>");
p.sendMessage("/hologram remove <Name>");
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<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}

View File

@ -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<Core> {
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<String> tabComplete(CommandSender sender, String label, String[] args) {
return null;
}
}