diff --git a/Core.iml b/Core.iml index 6077546..4a2df32 100644 --- a/Core.iml +++ b/Core.iml @@ -1,6 +1,15 @@ - + + + + + PAPER + + + + + @@ -11,6 +20,7 @@ + @@ -28,11 +38,35 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -43,7 +77,7 @@ - + diff --git a/src/main/java/eu/univento/core/Core.java b/src/main/java/eu/univento/core/Core.java index 0291cf3..350cad2 100644 --- a/src/main/java/eu/univento/core/Core.java +++ b/src/main/java/eu/univento/core/Core.java @@ -1,7 +1,5 @@ package eu.univento.core; -import de.slikey.effectlib.EffectLib; -import de.slikey.effectlib.EffectManager; import eu.univento.commons.Commons; import eu.univento.commons.server.TPS; import eu.univento.core.antihack.AntiHack; @@ -24,7 +22,6 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import java.io.IOException; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; @@ -38,15 +35,10 @@ import java.util.List; */ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { - @Getter - private static EffectLib effectLib = (EffectLib) Bukkit.getPluginManager().getPlugin("EffectLib"); - @Getter private static Core instance; @Getter private static Commons commons; - @Getter - private static EffectManager effectManager; private ArrayList registeredPlugins = new ArrayList<>(); @@ -78,12 +70,6 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { return list; } - public static void broadcast(String key) { - for (CustomPlayer players : getOnlinePlayers()) { - players.sendMessage(players.getDatabasePlayer().getLanguage().getWord(key)); - } - } - /* @Override public void onLoad() { @@ -110,7 +96,6 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { public void onEnable() { commons = new Commons(); registerPlugin(this); - effectManager = new EffectManager(this); commons.getLoggingHandler().getCore().info("\n" + "\n" + " \n" + diff --git a/src/main/java/eu/univento/core/api/Hologram.java b/src/main/java/eu/univento/core/api/Hologram.java index 5962ebe..86a6e86 100644 --- a/src/main/java/eu/univento/core/api/Hologram.java +++ b/src/main/java/eu/univento/core/api/Hologram.java @@ -15,6 +15,8 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; +@Deprecated + public class Hologram { private final List entitylist = new ArrayList<>(); @@ -31,15 +33,15 @@ public class Hologram { } - public void showPlayerTemp(final CustomPlayer p, int Time){ + public void showPlayerTemp(final CustomPlayer p, int time){ showPlayer(p); - Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> hidePlayer(p), Time); + Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> hidePlayer(p), time); } - public void showAllTemp(int Time){ + public void showAllTemp(int time){ showAll(); - Bukkit.getScheduler().runTaskLater(Core.getInstance(), this::hideAll, Time); + Bukkit.getScheduler().runTaskLater(Core.getInstance(), this::hideAll, time); } public void showPlayer(CustomPlayer p) { diff --git a/src/main/java/eu/univento/core/api/events/BorderLeaveEvent.java b/src/main/java/eu/univento/core/api/events/BorderLeaveEvent.java index c655169..3f1e453 100644 --- a/src/main/java/eu/univento/core/api/events/BorderLeaveEvent.java +++ b/src/main/java/eu/univento/core/api/events/BorderLeaveEvent.java @@ -14,18 +14,11 @@ public class BorderLeaveEvent extends PlayerEvent { public BorderLeaveEvent(Player who) { super(who); } - public static HandlerList handlers; + public static HandlerList handlers = new HandlerList(); - static { - handlers = new HandlerList(); - } @Override public HandlerList getHandlers() { return handlers; } - public static HandlerList getHandlerList() { - return handlers; - } - } diff --git a/src/main/java/eu/univento/core/api/events/HologramClickEvent.java b/src/main/java/eu/univento/core/api/events/HologramClickEvent.java new file mode 100644 index 0000000..7154416 --- /dev/null +++ b/src/main/java/eu/univento/core/api/events/HologramClickEvent.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.events; + +import eu.univento.core.api.player.CustomPlayer; +import org.bukkit.entity.ArmorStand; +import org.bukkit.event.HandlerList; +import org.bukkit.event.player.PlayerInteractEntityEvent; + +/** + * @author joethei + * @version 0.1 + */ +public class HologramClickEvent extends PlayerInteractEntityEvent{ + + + public static HandlerList handlers = new HandlerList(); + + public HologramClickEvent(CustomPlayer player, ArmorStand armorStand) { + super(player, armorStand); + } + + @Override + public HandlerList getHandlers() { + return handlers; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/hologram/Hologram.java b/src/main/java/eu/univento/core/api/hologram/Hologram.java new file mode 100644 index 0000000..3402426 --- /dev/null +++ b/src/main/java/eu/univento/core/api/hologram/Hologram.java @@ -0,0 +1,90 @@ +/* + * 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 eu.univento.core.Core; +import eu.univento.core.api.events.HologramClickEvent; +import eu.univento.core.api.player.CustomPlayer; +import net.minecraft.server.v1_11_R1.EntityArmorStand; +import net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_11_R1.PacketPlayOutSpawnEntityLiving; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.craftbukkit.v1_11_R1.CraftWorld; +import org.bukkit.entity.ArmorStand; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerInteractEntityEvent; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author joethei + * @version 1.0 + */ +public class Hologram implements Listener{ + + private final List stands = new ArrayList<>(); + private final String[] text; + private final Location location; + private int count; + + public Hologram(String[] text, Location location) { + this.text = text; + this.location = location; + create(); + Bukkit.getPluginManager().registerEvents(this, Core.getInstance()); + } + + public void show(CustomPlayer p) { + for(EntityArmorStand stand : stands) { + p.sendPacket(new PacketPlayOutSpawnEntityLiving(stand)); + } + } + + public void hide(CustomPlayer p) { + for(EntityArmorStand stand : stands) { + p.sendPacket(new PacketPlayOutEntityDestroy(stand.getId())); + } + } + + public void destroy() { + for(EntityArmorStand armorStand : stands) { + armorStand.die(); + } + } + + private void create() { + double DISTANCE = 0.25D; + for (String text : this.text) { + EntityArmorStand entity = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ()); + entity.setCustomName(text); + entity.setCustomNameVisible(true); + entity.setInvisible(true); + entity.setNoGravity(true); + stands.add(entity); + this.location.subtract(0, DISTANCE, 0); + count++; + } + + for (int i = 0; i < count; i++) { + this.location.add(0, DISTANCE, 0); + } + this.count = 0; + } + + @EventHandler + public void onEntityInteract(PlayerInteractEntityEvent e) { + CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer()); + if(e.getRightClicked() instanceof EntityArmorStand) { + if(stands.contains(e.getRightClicked())) { + ArmorStand stand = (ArmorStand) e.getRightClicked(); + Bukkit.getPluginManager().callEvent(new HologramClickEvent(p, stand)); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/listeners/Chat.java b/src/main/java/eu/univento/core/listeners/Chat.java index d51c16d..26fdc24 100644 --- a/src/main/java/eu/univento/core/listeners/Chat.java +++ b/src/main/java/eu/univento/core/listeners/Chat.java @@ -1,6 +1,6 @@ package eu.univento.core.listeners; -import eu.univento.commons.player.Rank; +import eu.univento.commons.player.rank.Rank; import eu.univento.commons.player.warn.WarnReason; import eu.univento.core.Core; import eu.univento.core.api.blocks.MiniBlock; @@ -44,71 +44,77 @@ public class Chat implements Listener { @EventHandler public void onChat(AsyncPlayerChatEvent e) { CustomPlayer p = CustomPlayer.getPlayer(e.getPlayer().getName()); - assert p != null; - //TODO: remove this, used for debugging - if (e.getMessage().equalsIgnoreCase("bestswordever")) { - new BestSwordEver(p).addItem(); - } - if (e.getMessage().equalsIgnoreCase("shopvillager")) { - ShopMenu menu = new ShopMenu(Core.getInstance(), "Shop Villager", ShopItem.TestItem); - new ShopVillager(Core.getInstance(), "Shop Villager", p.getLocation(), Villager.Profession.LIBRARIAN, menu); - } - if (e.getMessage().equalsIgnoreCase("miniblock")) { - new MiniBlock(p.getLocation(), new ItemStack(Material.GRASS), 1); - new MiniBlock(p.getEyeLocation(), new ItemStack(Material.DIAMOND_SWORD), 2); - new MiniBlock(p.getWorld().getSpawnLocation(), new ItemStack(Material.WOOL), 3); - } - Messages msgs = p.getMessages(); - if (ServerSettings.isMute()) { - if (!p.getDatabasePlayer().isAllowed(Rank.Sound)) { - e.setCancelled(true); + e.setCancelled(true); + p.getDatabasePlayer().isMuted().whenComplete((aBoolean, throwable) -> { + if (aBoolean) { p.sendMessage(msgs.PREFIX() + msgs.Core_SERVER_MUTED()); + } else { + + //TODO: remove this, used for debugging + if (e.getMessage().equalsIgnoreCase("bestswordever")) { + new BestSwordEver(p).addItem(); + } + if (e.getMessage().equalsIgnoreCase("shopvillager")) { + ShopMenu menu = new ShopMenu(Core.getInstance(), "Shop Villager", ShopItem.TestItem); + new ShopVillager(Core.getInstance(), "Shop Villager", p.getLocation(), Villager.Profession.LIBRARIAN, menu); + } + if (e.getMessage().equalsIgnoreCase("miniblock")) { + new MiniBlock(p.getLocation(), new ItemStack(Material.GRASS), 1); + new MiniBlock(p.getEyeLocation(), new ItemStack(Material.DIAMOND_SWORD), 2); + new MiniBlock(p.getWorld().getSpawnLocation(), new ItemStack(Material.WOOL), 3); + } + + if (ServerSettings.isMute()) { + if (!p.getDatabasePlayer().isAllowed(Rank.Sound)) { + e.setCancelled(true); + p.sendMessage(msgs.PREFIX() + msgs.Core_SERVER_MUTED()); + } + } + if (players.contains(p)) { + e.setCancelled(true); + p.sendMessage("§cDu musst dich bewegen bevor du chatten kannst"); + } + if (System.currentTimeMillis() - spam.get(p) < 5 * 20L) { + e.setCancelled(true); + p.sendMessage("Nicht spammen"); + spamPlayers.put(p, spamPlayers.get(p) + 1); + } + if (spamPlayers.get(p) > 100) { + p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/chatlog"); + } + + char[] parts = e.getMessage().toCharArray(); + + int sum = 0; + for (char part : parts) { + sum += part; + } + double ratio = sum / parts.length; + int percent = (int) (100.0D * ratio); + + if (percent < 50) { + e.setCancelled(true); + p.sendMessage("§cKeine Caps verwenden"); + } + + String message = e.getMessage(); + if (e.getFormat().contains("%")) message = message.replace("%", "%%"); + if (p.getDatabasePlayer().isAllowed(Rank.VIP)) { + if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) { + e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + ChatColor.translateAlternateColorCodes('&', message)); + for(CustomPlayer player : Core.getOnlinePlayers()) player.sendMessage(e.getMessage()); + } else { + e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + ChatColor.translateAlternateColorCodes('&', message)); + for(CustomPlayer player : Core.getOnlinePlayers()) player.sendMessage(e.getMessage()); + } + } else { + e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + message); + for(CustomPlayer player : Core.getOnlinePlayers()) player.sendMessage(e.getMessage()); + Core.getOnlinePlayers().stream().filter(player -> e.getMessage().toLowerCase().contains(player.getDisplayName().toLowerCase()) || e.getMessage().toLowerCase().contains(player.getName().toLowerCase())).forEach(player -> player.playSound(p.getEyeLocation(), Sound.BLOCK_NOTE_PLING, 100.0F, 1.0F)); + } } - } - if (p.getDatabasePlayer().isMuted()) { - e.setCancelled(true); - p.sendMessage(msgs.PREFIX() + msgs.Core_SERVER_MUTED()); - } - if (players.contains(p)) { - e.setCancelled(true); - p.sendMessage("§cDu musst dich bewegen bevor du chatten kannst"); - } - if (System.currentTimeMillis() - spam.get(p) < 5 * 20L) { - e.setCancelled(true); - p.sendMessage("Nicht spammen"); - spamPlayers.put(p, spamPlayers.get(p) + 1); - } - if (spamPlayers.get(p) > 100) { - p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/chatlog"); - } - - char[] parts = e.getMessage().toCharArray(); - - int sum = 0; - for (char part : parts) { - sum += part; - } - double ratio = sum / parts.length; - int percent = (int) (100.0D * ratio); - - if (percent < 50) { - e.setCancelled(true); - p.sendMessage("§cKeine Caps verwenden"); - } - - String message = e.getMessage(); - if (e.getFormat().contains("%")) message = message.replace("%", "%%"); - if (p.getDatabasePlayer().isAllowed(Rank.Partner)) { - if (p.getDatabasePlayer().getSettings().isNicked() && !ServerSettings.isLobby()) { - e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDatabasePlayer().getRank().getColor() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + ChatColor.translateAlternateColorCodes('&', message)); - }else{ - e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + ChatColor.translateAlternateColorCodes('&', message)); - } - }else{ - e.setFormat(p.getDatabasePlayer().getRank().getPrefix() + p.getDisplayName() + p.getDatabasePlayer().getRank().getSuffix() + message); - Core.getOnlinePlayers().stream().filter(player -> e.getMessage().toLowerCase().contains(player.getDisplayName().toLowerCase()) || e.getMessage().toLowerCase().contains(player.getName().toLowerCase())).forEach(player -> player.playSound(p.getEyeLocation(), Sound.BLOCK_NOTE_PLING, 100.0F, 1.0F)); - } + }); } @EventHandler