From ad9d1f92350cc1f6185e9da4dc91456ebe1f90a2 Mon Sep 17 00:00:00 2001 From: joethei Date: Tue, 6 Dec 2016 19:47:49 +0100 Subject: [PATCH] + WorldReset and Downloader, even tought authentication is missing + command to test particle effects + first parts for hologram gui --- .gitignore | 3 +- Core.iml | 8 ++ pom.xml | 22 ++++- run-server.sh | 96 +++++++++++++++++++ src/main/java/eu/univento/core/Core.java | 26 ++--- .../java/eu/univento/core/api/Config.java | 4 +- .../java/eu/univento/core/api/Hologram.java | 10 +- .../eu/univento/core/api/game/GameTimer.java | 51 ---------- .../core/api/gui/hologram/HologramData.java | 36 +++++++ .../core/api/gui/hologram/HologramGUI.java | 17 ++++ .../components/ComponentPosition.java | 25 +++++ .../components/ComponentProperties.java | 27 ++++++ .../gui/hologram/components/GUIComponent.java | 45 +++++++++ .../api/gui/hologram/components/GUIPage.java | 45 +++++++++ .../gui/hologram/components/GUIPageModel.java | 14 +++ .../gui/hologram/components/IValueHolder.java | 14 +++ .../components/PlayerGUIComponent.java | 94 ++++++++++++++++++ .../hologram/components/PlayerGUIPage.java | 54 +++++++++++ .../components/PlayerGUIPageModel.java | 22 +++++ .../components/PlayerGUITextBoxComponent.java | 40 ++++++++ .../PlayerGUIValueBoxComponent.java | 25 +++++ .../components/StationaryPlayerGUIPage.java | 42 ++++++++ .../core/api/player/CustomPlayer.java | 6 ++ .../univento/core/api/world/WorldReset.java | 73 ++++++++++++++ .../core/commands/ParticleEffect.java | 89 +++++++++++++++++ .../java/eu/univento/core/listeners/Chat.java | 2 +- .../eu/univento/core/listeners/Events.java | 2 - .../core/listeners/PluginMessenger.java | 6 +- 28 files changed, 820 insertions(+), 78 deletions(-) create mode 100644 run-server.sh delete mode 100644 src/main/java/eu/univento/core/api/game/GameTimer.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/HologramData.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/HologramGUI.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/ComponentPosition.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/ComponentProperties.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/GUIComponent.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/GUIPage.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/GUIPageModel.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/IValueHolder.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIComponent.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPage.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPageModel.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUITextBoxComponent.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIValueBoxComponent.java create mode 100644 src/main/java/eu/univento/core/api/gui/hologram/components/StationaryPlayerGUIPage.java create mode 100644 src/main/java/eu/univento/core/api/world/WorldReset.java create mode 100644 src/main/java/eu/univento/core/commands/ParticleEffect.java diff --git a/.gitignore b/.gitignore index a1050df..9a9e56b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -/bin/ /target +/server +/build Core.iml \ No newline at end of file diff --git a/Core.iml b/Core.iml index e003791..6077546 100644 --- a/Core.iml +++ b/Core.iml @@ -31,13 +31,21 @@ + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 2eb77fe..b7a26b0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,6 +4,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + UTF-8 + + eu.univento Core 1.0-SNAPSHOT @@ -16,6 +20,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.6.0 1.8 1.8 @@ -48,12 +53,12 @@ - + univentoEU - http://dev.joethei.de:8081/repository/public/ + http://dev.joethei.de:8081/repository/univento-repo/ - + @@ -90,6 +95,17 @@ lombok 1.16.10 + + de.slikey + EffectLib + 5.2 + provided + + + co.aikar + taskchain-bukkit + 3.4.3 + \ No newline at end of file diff --git a/run-server.sh b/run-server.sh new file mode 100644 index 0000000..fbcad9c --- /dev/null +++ b/run-server.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +if [ ! -d "build" ]; then + echo "Spigot is not downloaded, downloading and building now.." + rm -rf build/ + mkdir build + cd build + + curl -O https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar + java -jar BuildTools.jar --rev 1.11 + + if [ ! -d "apache-maven-3.2.5" ]; then + echo "Maven is not downloaded, downloading now.." + curl -o apache-maven-3.2.5.zip http://mirror.metrocast.net/apache//maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip + unzip apache-maven-3.2.5.zip + rm apache-maven-3.2.5.zip + fi + + cd .. + + chmod +x ./build/apache-maven-3.2.5/bin/mvn # for some reason this isn't executable by default.. +fi + +if [ ! -d "server/plugins" ]; then + mkdir -p server/plugins +fi + +if [ ! -f "server/spigot.jar" ]; then + cp build/spigot-1.11.jar server/spigot.jar +fi + +if [ ! -f "server/eula.txt" ]; then + read -p "Do you accept the Mojang EULA? If not, then exit the program now. Otherwise, press Enter." + echo "eula=true" > server/eula.txt +fi + +_term() { + echo "stop" > /tmp/srv-input + exit +} + +if [[ ! $(uname) == MING* ]]; then + trap _term EXIT # only trap exit event if we're on unix +fi + +while true; do + if [ -f "build/apache-maven-3.2.5" ]; then + ./build/apache-maven-3.2.5/bin/mvn clean install # use the maven that spigot build tools downloaded + else + mvn clean install + fi + cp target/Core-1.0-SNAPSHOT-jar-with-dependencies.jar server/plugins/Core.jar + cd server + + if [[ $(uname) == MING* ]]; then + # we're running inside of git bash on windows, which doesn't support everything that unix systems do + # so just run the jar and ask the user if they want to continue running after it's done + java -jar spigot.jar + + read -n 1 -p "Do you want to recompile and restart the server? (y/n) " value + if [ "$value" == "n" ]; then + echo "Shutting down process.." + exit + fi + else + # set up out process + rm -f /tmp/srv-input + + mkfifo /tmp/srv-input + cat > /tmp/srv-input & + tail -f /tmp/srv-input | java -jar spigot.jar & + + running=true + while $running; do + read input + if [ "$input" == "stop" ]; then + running=false + echo "stop" > /tmp/srv-input + elif [ "$input" == "exit" ]; then + running=false + echo "stop" > /tmp/srv-input + sleep 2 + exit + else + echo "$input" > /tmp/srv-input + fi + + sleep 1 + done + fi + + cd .. + + echo "Rebuilding project.." + sleep 1 +done diff --git a/src/main/java/eu/univento/core/Core.java b/src/main/java/eu/univento/core/Core.java index 271906c..0291cf3 100644 --- a/src/main/java/eu/univento/core/Core.java +++ b/src/main/java/eu/univento/core/Core.java @@ -1,5 +1,7 @@ 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; @@ -14,6 +16,7 @@ import eu.univento.core.api.utils.NettyInjection; import eu.univento.core.commands.*; import eu.univento.core.listeners.*; import io.netty.channel.Channel; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -35,18 +38,15 @@ import java.util.List; */ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { - //TODO: rewrite database operations from sync MongoDB to async MongoDB + @Getter + private static EffectLib effectLib = (EffectLib) Bukkit.getPluginManager().getPlugin("EffectLib"); + @Getter private static Core instance; - - public static Core getInstance() { - return instance; - } - + @Getter private static Commons commons; - public static Commons getCommons() { - return commons; - } + @Getter + private static EffectManager effectManager; private ArrayList registeredPlugins = new ArrayList<>(); @@ -110,6 +110,7 @@ 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" + @@ -139,7 +140,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { "\n"); try { Config.writeDefault(); - } catch (IOException | ClassNotFoundException | SQLException e) { + } catch (IOException e) { e.printStackTrace(); } instance = this; @@ -159,7 +160,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { } AntiHack.registerListeners(); - new RunAs(this, "RunAs", "run commons as other player"); + new RunAs(this, "RunAs", "run commands as other players"); new SystemInfo(this, "SystemInfo", "gives info about the server system"); new Vanish(this, "vanish", "vanish/unvanish your self"); new GameMode(this, "gamemode", "sets your gamemode", "gm"); @@ -167,6 +168,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"); PluginMessenger pluginMessenger = new PluginMessenger(); NetworkData networkData = new NetworkData(); @@ -204,7 +206,7 @@ public class Core extends JavaPlugin implements NettyInjection.PacketHandler { } }, 5L); */ - this.injection = new NettyInjection(this, this.getName()); + this.injection = new NettyInjection(this, this.getName()); this.injection.addHandler("TIMEOUT", new NettyInjection.PacketHandler() { public Object onPacketIn(Player sender, Channel channel, Object packet) { getCommons().getLoggingHandler().getCore().info("PacketIN: " + sender.getName() + " | " + channel + " | " + packet); diff --git a/src/main/java/eu/univento/core/api/Config.java b/src/main/java/eu/univento/core/api/Config.java index bb364ad..fcc346b 100644 --- a/src/main/java/eu/univento/core/api/Config.java +++ b/src/main/java/eu/univento/core/api/Config.java @@ -27,10 +27,10 @@ public class Config { * @throws SQLException SQL server not available or throwing error * @throws IOException I/O failed */ - public static void writeDefault() throws ClassNotFoundException, SQLException, IOException { + public static void writeDefault() throws IOException { //editable messages will be set here, but do not edit this messages. - //seting the default MySQL config. + //setting the default MySQL config. cfg.addDefault("MySQL.Host", "hostname"); cfg.addDefault("MySQL.Port", "3306"); cfg.addDefault("MySQL.DB", "core"); diff --git a/src/main/java/eu/univento/core/api/Hologram.java b/src/main/java/eu/univento/core/api/Hologram.java index 93e4151..5962ebe 100644 --- a/src/main/java/eu/univento/core/api/Hologram.java +++ b/src/main/java/eu/univento/core/api/Hologram.java @@ -57,7 +57,7 @@ public class Hologram { } } - private void showAll() { + public void showAll() { for (CustomPlayer player : Core.getOnlinePlayers()) { for (EntityArmorStand armor : entitylist) { PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(armor); @@ -66,7 +66,7 @@ public class Hologram { } } - private void hideAll() { + public void hideAll() { for (CustomPlayer player : Core.getOnlinePlayers()) { for (EntityArmorStand armor : entitylist) { PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(armor.getId()); @@ -75,6 +75,12 @@ public class Hologram { } } + public void destroy() { + for(EntityArmorStand armorStand : entitylist) { + armorStand.die(); + } + } + private void create() { double DISTANCE = 0.25D; EntityArmorStand stand = new EntityArmorStand(((CraftWorld) this.location.getWorld()).getHandle(),this.location.getX(), this.location.getY(),this.location.getZ()); diff --git a/src/main/java/eu/univento/core/api/game/GameTimer.java b/src/main/java/eu/univento/core/api/game/GameTimer.java deleted file mode 100644 index 677ce8c..0000000 --- a/src/main/java/eu/univento/core/api/game/GameTimer.java +++ /dev/null @@ -1,51 +0,0 @@ -package eu.univento.core.api.game; - -import org.bukkit.plugin.Plugin; -import org.bukkit.scheduler.BukkitRunnable; - -/** - * @author joethei - * @version 0.1 - */ -public class GameTimer extends BukkitRunnable{ - - private Plugin plugin; - private int time; - private int minPlayers; - private GameTimer following; - - public GameTimer(Plugin plugin, GameTimer following, int time, int minPlayers) { - this.plugin = plugin; - this.following = following; - this.time = time; - this.minPlayers = minPlayers; - runTaskTimer(plugin, 20L, 20L); - } - - @Override - public void run() { - if(PlayerManager.size() >= minPlayers) { - time--; - - } - if(time == 0) { - if(PlayerManager.size() > minPlayers) { - this.cancel(); - following.run(); - }else { - this.cancel(); - //TODO: reset timer - this.run(); - } - } - } - - public int getTime() { - return time; - } - - public int getMinPlayers() { - return minPlayers; - } - -} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/HologramData.java b/src/main/java/eu/univento/core/api/gui/hologram/HologramData.java new file mode 100644 index 0000000..0baa14e --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/HologramData.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram; + +import eu.univento.core.api.gui.hologram.components.PlayerGUIPage; +import eu.univento.core.api.gui.hologram.components.PlayerGUIPageModel; +import eu.univento.core.api.gui.hologram.components.PlayerGUITextBoxComponent; +import eu.univento.core.api.player.CustomPlayer; +import lombok.Getter; + +/** + * @author joethei + * @version 0.1 + */ + +@Getter +public class HologramData { + + private CustomPlayer player; + private PlayerGUIPage playerGUIPage; + private PlayerGUIPageModel model; + private PlayerGUIPageModel prevModel; + private PlayerGUIPage playerPreviousGUIContainer; + private PlayerGUIPage playerFocusedContainer; + private PlayerGUITextBoxComponent textBoxEditor; + //private PlayerGUIValueScrollerComponent valueScrollerEditor; + private boolean isSneaking; + + public HologramData(CustomPlayer player) { + this.player = player; + } + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/HologramGUI.java b/src/main/java/eu/univento/core/api/gui/hologram/HologramGUI.java new file mode 100644 index 0000000..4d39879 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/HologramGUI.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram; + +/** + * @author joethei + * @version 0.1 + */ +public class HologramGUI { + + public HologramGUI() { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentPosition.java b/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentPosition.java new file mode 100644 index 0000000..c0a06d5 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentPosition.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import lombok.Data; + +/** + * @author joethei + * @version 0.1 + */ + +@Data +public class ComponentPosition { + + private double x; + private double y; + + public ComponentPosition(double x, double y) { + this.x = x; + this.y = y; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentProperties.java b/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentProperties.java new file mode 100644 index 0000000..1008100 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/ComponentProperties.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import lombok.AllArgsConstructor; +import lombok.Data; + +/** + * @author joethei + * @version 0.1 + */ + +@Data +@AllArgsConstructor +public class ComponentProperties { + + private String id; + private String pageId; + private ComponentPosition position; + private String label; + private double labelDistance; + private boolean showLabel; + private boolean hidden; +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/GUIComponent.java b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIComponent.java new file mode 100644 index 0000000..ec1cf09 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIComponent.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.Hologram; +import lombok.AllArgsConstructor; +import lombok.Data; +import org.bukkit.entity.Player; + +/** + * @author joethei + * @version 0.1 + */ + +@Data +@AllArgsConstructor +public abstract class GUIComponent { + protected String id; + protected String pageId; + protected ComponentPosition position; + protected String label; + protected double labelDistance; + protected boolean showLabel; + protected boolean hidden; + protected Hologram[] holograms; + + public abstract PlayerGUIComponent initPlayerGUIComponent(Player player); + + public abstract void updateIncrement(); + + public abstract String[] updateComponentLine(Player player); + + public abstract double getDisplayDistance(); + + public abstract double getLineHeight(); + + public abstract GUIComponent clone(); + + public ComponentProperties cloneProperties() { + return new ComponentProperties(this.id, this.pageId, this.position, this.label, this.labelDistance, this.showLabel, this.hidden); + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPage.java b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPage.java new file mode 100644 index 0000000..626cf0c --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPage.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; +import lombok.Getter; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; + +/** + * @author joethei + * @version 0.1 + */ + +@Getter +public class GUIPage { + + private HashMap components; + private String id; + private ItemStack item; + private String itemName; + private boolean closeOnPlayerMove; + private boolean closeOnPlayerItemSwitch; + + public GUIPage(HashMap components, String id, ItemStack item, String itemName, boolean closeOnPlayerMove, boolean closeOnPlayerItemSwitch) { + this.components = components; + this.id = id; + this.item = item; + this.itemName = itemName; + this.closeOnPlayerMove = closeOnPlayerMove; + this.closeOnPlayerItemSwitch = closeOnPlayerItemSwitch; + } + + public PlayerGUIPage getPlayerGUIPage(CustomPlayer player) { + PlayerGUIPage page = player.getHologramData().getPlayerGUIPage(); + if(page.getPage().getId().equals(id)) { + return page; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPageModel.java b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPageModel.java new file mode 100644 index 0000000..d0d41ca --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/GUIPageModel.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +/** + * @author joethei + * @version 0.1 + */ +public abstract class GUIPageModel { + +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/IValueHolder.java b/src/main/java/eu/univento/core/api/gui/hologram/components/IValueHolder.java new file mode 100644 index 0000000..61ba726 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/IValueHolder.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +/** + * @author joethei + * @version 0.1 + */ +public abstract interface IValueHolder { + public abstract String getValue(); +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIComponent.java b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIComponent.java new file mode 100644 index 0000000..8f6cf00 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIComponent.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.Hologram; +import eu.univento.core.api.player.CustomPlayer; +import lombok.Data; +import org.bukkit.Location; +import org.bukkit.util.Vector; + +/** + * @author joethei + * @version 0.1 + */ + +@Data +public abstract class PlayerGUIComponent { + protected CustomPlayer player; + protected GUIComponent component; + protected Location location; + protected String label; + protected boolean focused = false; + protected String[] lines; + protected int[] componentIds; + protected Location[] armorStandLocations; + protected boolean hidden; + + public PlayerGUIComponent(CustomPlayer player, GUIComponent component) { + this.player = player; + this.component = component; + this.hidden = component.isHidden(); + } + + public abstract void updateComponentLines(); + + public abstract void spawnEntities(Location location, boolean param); + + public abstract void updateLocation(Location location, boolean param); + + public void destroyArmorStands() { + for(Hologram hologram : component.getHolograms()) { + hologram.destroy(); + } + } + + public void renderLabel(Location location, Vector vector, boolean param) { + if(component.getLabel() != null) { + double distance = component.getLabelDistance(); + Location loc = player.getLocation(); + if(param) { + loc = this.location; + distance = 15.0D; + } + location = calculateArmorStandLocation(-1, loc, vector, distance, component.getLineHeight(), component.getPosition().getY(), component.getPosition().getX()); + if(param) { + this.location.setX(this.location.getX() + vector.getX() * -15.0D); + this.location.setY(this.location.getY() + vector.getY() * -15.0D); + } + String label = component.getLabel(); + + } + } + + protected void updateLabelText() { + + } + + protected void updateLabelLocation(Location location, Vector vector, boolean param) { + + } + + protected Location calculateArmorStandLocation(int param, Location location, Vector vector, double double1, double double2, double double3, double double4) { + return null; + } + + protected Vector customNormalize(Vector vector) { + return null; + } + + protected Vector rotateAboutYAxis(Vector vector, double param) { + return null; + } + + public void focusComponent(boolean param) { + + } + + public void unfocusComponent(boolean param) { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPage.java b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPage.java new file mode 100644 index 0000000..e593873 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPage.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; +import lombok.Getter; +import org.bukkit.Location; + +import java.util.HashMap; + +/** + * @author joethei + * @version 0.1 + */ + +@Getter +public class PlayerGUIPage { + protected CustomPlayer player; + protected GUIPage page; + protected Location location; + protected HashMap components; + protected HashMap guiComponents; + + public PlayerGUIPage(CustomPlayer player, HashMap components, Location location, GUIPage page) { + this.player = player; + this.components = components; + this.location = location; + this.page = page; + this.guiComponents = new HashMap<>(); + } + + public void updateIncrement() { + for(GUIComponent component : guiComponents.values()) { + component.updateIncrement(); + } + } + + public void renderComponent(GUIComponent component) { + PlayerGUIComponent playerGUIComponent = this.components.get(component.getId()); + if(playerGUIComponent != null) { + removeComponent(component.getId()); + } + PlayerGUIComponent guiComponent = component.initPlayerGUIComponent(player); + guiComponent.setHidden(false); + guiComponent.spawnEntities(location, this instanceof StationaryPlayerGUIPage); + } + + public void removeComponent(String param) { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPageModel.java b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPageModel.java new file mode 100644 index 0000000..f6fec98 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIPageModel.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author joethei + * @version 0.1 + */ + +@Getter +@AllArgsConstructor +public abstract class PlayerGUIPageModel { + protected GUIPage page; + protected CustomPlayer player; +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUITextBoxComponent.java b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUITextBoxComponent.java new file mode 100644 index 0000000..70a7466 --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUITextBoxComponent.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; +import org.bukkit.Location; + +/** + * @author joethei + * @version 0.1 + */ +public class PlayerGUITextBoxComponent extends PlayerGUIValueBoxComponent implements IValueHolder{ + + public PlayerGUITextBoxComponent(CustomPlayer player, GUIComponent component) { + super(player, component); + } + + @Override + public String getValue() { + return null; + } + + @Override + public void updateComponentLines() { + + } + + @Override + public void spawnEntities(Location location, boolean param) { + + } + + @Override + public void updateLocation(Location location, boolean param) { + + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIValueBoxComponent.java b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIValueBoxComponent.java new file mode 100644 index 0000000..731a0cd --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/PlayerGUIValueBoxComponent.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; + +/** + * @author joethei + * @version 0.1 + */ +public abstract class PlayerGUIValueBoxComponent extends PlayerGUIComponent{ + + public PlayerGUIValueBoxComponent(CustomPlayer player, GUIComponent component) { + super(player, component); + } + + public void focusComponent(boolean focus) { + if((component.getLabel() != null) && (!component.isShowLabel())) { + + } + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/gui/hologram/components/StationaryPlayerGUIPage.java b/src/main/java/eu/univento/core/api/gui/hologram/components/StationaryPlayerGUIPage.java new file mode 100644 index 0000000..022edff --- /dev/null +++ b/src/main/java/eu/univento/core/api/gui/hologram/components/StationaryPlayerGUIPage.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.gui.hologram.components; + +import eu.univento.core.api.player.CustomPlayer; +import lombok.Getter; +import org.bukkit.Location; + +import java.util.HashMap; + +/** + * @author joethei + * @version 0.1 + */ + +public class StationaryPlayerGUIPage extends PlayerGUIPage{ + + @Getter + private String stationaryDisplayID; + + public StationaryPlayerGUIPage(CustomPlayer player, HashMap components, Location location, GUIPage page, String param) { + super(player, components, location, page); + this.stationaryDisplayID = param; + } + + public void renderComponents() { + for(PlayerGUIComponent component : components.values()) { + component.spawnEntities(location, true); + } + } + + public boolean equals(Object object) { + if((object instanceof StationaryPlayerGUIPage)) { + StationaryPlayerGUIPage page = (StationaryPlayerGUIPage) object; + return page.getPage().getId().equals(this.getPage().getId()); + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/eu/univento/core/api/player/CustomPlayer.java b/src/main/java/eu/univento/core/api/player/CustomPlayer.java index 1fd6bde..548a382 100644 --- a/src/main/java/eu/univento/core/api/player/CustomPlayer.java +++ b/src/main/java/eu/univento/core/api/player/CustomPlayer.java @@ -11,11 +11,13 @@ import eu.univento.core.api.Utils; import eu.univento.core.api.chat.DefaultFontInfo; import eu.univento.core.api.effects.Blackscreen; import eu.univento.core.api.effects.Effects; +import eu.univento.core.api.gui.hologram.HologramData; import eu.univento.core.api.languages.Messages; import eu.univento.core.api.server.ServerSettings; import eu.univento.core.api.shop.ShopItem; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; +import lombok.Getter; import net.minecraft.server.v1_11_R1.*; import org.bukkit.*; import org.bukkit.Material; @@ -55,12 +57,16 @@ public class CustomPlayer extends CraftPlayer { private final GameProfile gameProfile; + @Getter + private HologramData hologramData; + private CustomPlayer(Player player) { super((CraftServer) Bukkit.getServer(), ((CraftPlayer) player).getHandle()); DATABASE_PLAYER = new DatabasePlayer(Core.getCommons(), player.getUniqueId()); PLAYERS.put(player.getUniqueId(), this); PLAYER = player; gameProfile = ((CraftPlayer) player).getProfile(); + hologramData = new HologramData(this); } public void onLeave() { diff --git a/src/main/java/eu/univento/core/api/world/WorldReset.java b/src/main/java/eu/univento/core/api/world/WorldReset.java new file mode 100644 index 0000000..05d33cc --- /dev/null +++ b/src/main/java/eu/univento/core/api/world/WorldReset.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016 univento.eu - All rights reserved + * You are not allowed to use, distribute or modify this code + */ + +package eu.univento.core.api.world; + +import org.apache.commons.io.FileUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.WorldCreator; +import org.bukkit.entity.Player; + +import java.io.File; +import java.io.IOException; + +/** + * @author joethei + * @version 0.1 + */ +public class WorldReset { + + private String name; + + public WorldReset(String name) { + this.name = name; + } + + public World reset() { + World world = Bukkit.getWorld(name); + if(world.getName().equals("world")) return null; + for(Player player : world.getPlayers()) + player.teleport(Bukkit.getWorld("world").getSpawnLocation()); + + Bukkit.unloadWorld(world, true); + try { + File file = new File(name); + FileUtils.deleteDirectory(file); + + CloseableHttpClient httpClient = HttpClients.createDefault(); + + HttpGet httpGet = new HttpGet("https://download.univento.eu/world" + name); + httpGet.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0"); + httpGet.addHeader("Referer", "https://www.google.com"); + + try { + CloseableHttpResponse httpResponse = httpClient.execute(httpGet); + HttpEntity fileEntity = httpResponse.getEntity(); + + if (fileEntity != null) { + FileUtils.copyInputStreamToFile(fileEntity.getContent(), new File(name)); + } + + } catch (IOException e) { + return null; + } + + httpGet.releaseConnection(); + + //FileUtils.copyURLToFile(new URL(""), file); + + } catch (IOException e) { + e.printStackTrace(); + } + return Bukkit.createWorld(new WorldCreator(name)); + } + +} \ 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 new file mode 100644 index 0000000..33e89c5 --- /dev/null +++ b/src/main/java/eu/univento/core/commands/ParticleEffect.java @@ -0,0 +1,89 @@ +/* + * 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 diff --git a/src/main/java/eu/univento/core/listeners/Chat.java b/src/main/java/eu/univento/core/listeners/Chat.java index b3329f9..d51c16d 100644 --- a/src/main/java/eu/univento/core/listeners/Chat.java +++ b/src/main/java/eu/univento/core/listeners/Chat.java @@ -11,7 +11,7 @@ import eu.univento.core.api.server.ServerSettings; import eu.univento.core.api.shop.ShopItem; import eu.univento.core.api.shop.ShopMenu; import eu.univento.core.api.shop.entity.ShopVillager; -import net.md_5.bungee.api.ChatColor; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Villager; diff --git a/src/main/java/eu/univento/core/listeners/Events.java b/src/main/java/eu/univento/core/listeners/Events.java index 64b5569..404eee2 100644 --- a/src/main/java/eu/univento/core/listeners/Events.java +++ b/src/main/java/eu/univento/core/listeners/Events.java @@ -75,7 +75,6 @@ public class Events implements Listener { final double dx = Math.abs(dir.getX()); final double dz = Math.abs(dir.getZ()); if ((dx == 0.0) && (dz == 0.0)) { - // Special case probably never happens dir.setX(0.001); } if ((dx < 3.0) && (dz < 3.0)) { @@ -84,7 +83,6 @@ public class Events implements Listener { newV.setY(0); orb.setVelocity(newV); if ((dx < 1.0) && (dz < 1.0)) { - // maybe oLoc orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), PlayerTeleportEvent.TeleportCause.PLUGIN); } if ((dx < 0.5) && (dz < 0.5)) { diff --git a/src/main/java/eu/univento/core/listeners/PluginMessenger.java b/src/main/java/eu/univento/core/listeners/PluginMessenger.java index 3656856..fc37c99 100644 --- a/src/main/java/eu/univento/core/listeners/PluginMessenger.java +++ b/src/main/java/eu/univento/core/listeners/PluginMessenger.java @@ -28,7 +28,7 @@ public class PluginMessenger implements PluginMessageListener { } assert string != null; if(string.endsWith("squidhq")) { - p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks"); + p.warn(WarnReason.SQUIDHQ, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks"); } if (channel.equals("WDL|INIT")) { @@ -57,8 +57,7 @@ public class PluginMessenger implements PluginMessageListener { p.sendPluginMessage(Core.getInstance(), "WDL|CONTROL", output.toByteArray()); } if (channel.equals("PERMISSIONSREPL") && string.contains("mod.worlddownloader")) { - //TODO: change to real warn reason - p.warn(WarnReason.SPAM, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks"); + p.warn(WarnReason.WDL, null, "https://players.univento.eu/" + p.getUniqueId().toString() + "/hacks"); p.sendMessage(p.getDatabasePlayer().getLanguage().getWord("Prefix") + p.getDatabasePlayer().getLanguage().getWord("Hack.WorldDownloader")); } if(channel.equals("5zig_Set")) { @@ -83,7 +82,6 @@ public class PluginMessenger implements PluginMessageListener { ByteArrayDataOutput output5 = ByteStreams.newDataOutput(); output5.write(0x10); p.sendPluginMessage(Core.getInstance(), "5zig_Set", output5.toByteArray()); - } } }