diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/xyz/soukup/informator/Informator.java b/src/main/java/xyz/soukup/informator/Informator.java index ce16f3d..0f62e78 100644 --- a/src/main/java/xyz/soukup/informator/Informator.java +++ b/src/main/java/xyz/soukup/informator/Informator.java @@ -1,32 +1,61 @@ package xyz.soukup.informator; - -import org.bukkit.Color; +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; +import xyz.soukup.informator.handlers.AnimationHandler; +import xyz.soukup.informator.handlers.ConfigHandler; +import xyz.soukup.informator.handlers.clockHandler; +import java.io.IOException; import java.util.logging.Logger; public final class Informator extends JavaPlugin { + private static Informator instance; @Override public void onEnable() { + instance = this; Logger logger = Informator.getPlugin(Informator.class).getLogger(); - logger.info( "\u001B[34m \n"+ - " ____ ____ __ \n" + - " / _/___ / __/___ _________ ___ ____ _/ /_____ _____\n" + - " / // __ \\/ /_/ __ \\/ ___/ __ `__ \\/ __ `/ __/ __ \\/ ___/\n" + - " _/ // / / / __/ /_/ / / / / / / / / /_/ / /_/ /_/ / / \n" + - "/___/_/ /_/_/ \\____/_/ /_/ /_/ /_/\\__,_/\\__/\\____/_/ \n" + - " \n" + - "\u001B[33m===========================================================\n\n" + - "\u001B[34m Plugin version:\u001B[37m " + getDescription().getVersion() + - "\n\u001B[34m Author:\u001B[37m Jakub Soukup" + - "\n\u001B[34m Website:\u001B[37m " + getDescription().getWebsite() + - "\n\u001B[34m Source code:\u001B[37m Jakub Soukup" + - "\n\n\u001B[35m Thanks for using my plugin! It means a lot to me <3" + - "\n\n" + - "\u001B[33m===========================================================\n" - - ); + logger.info("\u001B[34m"); + logger.info(" ____ ____ __"); + logger.info(" / _/___ / __/___ _________ ___ ____ _/ /_____ _____"); + logger.info(" / // __ \\/ /_/ __ \\/ ___/ __ `__ \\/ __ `/ __/ __ \\/ ___/"); + logger.info(" _/ // / / / __/ /_/ / / / / / / / / /_/ / /_/ /_/ / /"); + logger.info("/___/_/ /_/_/ \\____/_/ /_/ /_/ /_/\\__,_/\\__/\\____/_/"); + logger.info(""); + logger.info("\u001B[33m==========================================================="); + logger.info(""); + logger.info("\u001B[34m Informator is starting!"); + logger.info(""); + logger.info("\u001B[33m==========================================================="); + logger.info(""); + logger.info("\u001B[34m Plugin version:\u001B[37m " + getDescription().getVersion()); + logger.info("\u001B[34m Author:\u001B[37m Jakub Soukup"); + logger.info("\u001B[34m Plugin's website: \u001B[37m https://informator.soukup.xyz/"); + logger.info("\u001B[34m Author's website:\u001B[37m " + getDescription().getWebsite()); + logger.info("\u001B[34m Source code:\u001B[37m soon will be available"); + logger.info(""); + logger.info("\u001B[34m Thanks for using my plugin! It means a lot to me <3"); + logger.info(" Made in the Czech Republic \uD83C\uDDE8\uD83C\uDDFF"); + logger.info(""); + logger.info("\u001B[33m==========================================================="); + logger.info(""); + try { + ConfigHandler.loadConfigs(); + } catch (IOException | InvalidConfigurationException e) { + throw new RuntimeException(e); + } + AnimationHandler.loadAnimations(); + clockHandler.centralClock + logger.info(""); + logger.info("\u001B[33m==========================================================="); + logger.info(""); + logger.info("\u001B[34m Informator loaded!"); + logger.info(""); + logger.info("\u001B[33m==========================================================="); + } + public static Informator getPlugin(){ + return instance; } @Override @@ -37,4 +66,7 @@ public final class Informator extends JavaPlugin { + + + } diff --git a/src/main/java/xyz/soukup/informator/handlers/AnimationHandler.java b/src/main/java/xyz/soukup/informator/handlers/AnimationHandler.java new file mode 100644 index 0000000..bc490eb --- /dev/null +++ b/src/main/java/xyz/soukup/informator/handlers/AnimationHandler.java @@ -0,0 +1,61 @@ +package xyz.soukup.informator.handlers; + +import org.bukkit.configuration.file.YamlConfiguration; +import xyz.soukup.informator.Informator; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; +import java.util.logging.Logger; + + +public class AnimationHandler { + private static final YamlConfiguration aconfig = ConfigHandler.animationConfig; + static Informator plugin = Informator.getPlugin(); + static Logger logger = plugin.getLogger(); + private static final List animations = new ArrayList(); + private static final HashMap> animationFrames = new HashMap>(); + private static final HashMap tpsCounter = new HashMap(); + private static final HashMap animationSpeed = new HashMap(); + private static final HashMap currentFrame = new HashMap(); + private static Integer cycles = 0; + + public static void loadAnimations(){ + animations.addAll(aconfig.getKeys(false)); + for (String animation: animations) { + animationFrames.put(animation, aconfig.getStringList(animation + ".frames") ); + animationSpeed.put(animation, aconfig.getInt(animation + ".speed")); + tpsCounter.put(animation, 0); + currentFrame.put(animation, 0); + logger.info("\u001B[34m Loaded animation\u001B[37m " + animation); + } + + } + public static void refreshAnimations(){ + for (String animation: animations){ + tpsCounter.put(animation, tpsCounter.get(animation) + 1); + if (Objects.equals(tpsCounter.get(animation), animationSpeed.get(animation))){ + tpsCounter.put(animation, 0); + if (currentFrame.get(animation) != (animationFrames.get(animation).size() - 1)) { + currentFrame.put(animation, currentFrame.get(animation) + 1); + } + else { + currentFrame.put(animation, 0); + } + } + + + } + cycles++; + + } + + + public static String getCurrentFrame(String name){ + if (animations.contains(name)) + return animationFrames.get(name).get(currentFrame.get(name))+ " " + currentFrame.get(name); + else + return null; + } +} diff --git a/src/main/java/xyz/soukup/informator/handlers/ConfigHandler.java b/src/main/java/xyz/soukup/informator/handlers/ConfigHandler.java new file mode 100644 index 0000000..1db3d1d --- /dev/null +++ b/src/main/java/xyz/soukup/informator/handlers/ConfigHandler.java @@ -0,0 +1,35 @@ +package xyz.soukup.informator.handlers; + +import org.bukkit.configuration.Configuration; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import xyz.soukup.informator.Informator; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + + +public class ConfigHandler { + static Informator plugin = Informator.getPlugin(); + static Logger logger = plugin.getLogger(); + public static YamlConfiguration animationConfig = new YamlConfiguration(); + public static void loadConfigs() throws IOException, InvalidConfigurationException { + List configsToLoad = new ArrayList<>(); + configsToLoad.add("config.yml"); + configsToLoad.add("animations.yml"); + configsToLoad.add("modules/tab.yml"); + for (String configAdress:configsToLoad) { + File file = new File(plugin.getDataFolder(), configAdress); + if (!file.exists()) + plugin.saveResource(configAdress, false); + logger.info("\u001B[34m Loaded configuration file\u001B[37m " + configAdress); + + } + animationConfig.load(new File(plugin.getDataFolder(), "animations.yml")); + + } + +} diff --git a/src/main/java/xyz/soukup/informator/handlers/clockHandler.java b/src/main/java/xyz/soukup/informator/handlers/clockHandler.java new file mode 100644 index 0000000..423fe64 --- /dev/null +++ b/src/main/java/xyz/soukup/informator/handlers/clockHandler.java @@ -0,0 +1,27 @@ +package xyz.soukup.informator.handlers; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; +import xyz.soukup.informator.Informator; + +import java.util.Objects; + +public class clockHandler { + public static Informator plugin = Informator.getPlugin(); + static int cycles = 0; + + public static BukkitTask centralClock = new BukkitRunnable() { + @Override + public void run() { + cycles++; + AnimationHandler.refreshAnimations(); + for (Player player: Bukkit.getOnlinePlayers()) { + player.sendMessage(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(AnimationHandler.getCurrentFrame("exampleTitle")))); + } + } + }.runTaskTimer(plugin, 0, 1L); + +} diff --git a/src/main/java/xyz/soukup/informator/handlers/tabHandler.java b/src/main/java/xyz/soukup/informator/handlers/tabHandler.java new file mode 100644 index 0000000..415cf4b --- /dev/null +++ b/src/main/java/xyz/soukup/informator/handlers/tabHandler.java @@ -0,0 +1,5 @@ +package xyz.soukup.informator.handlers; + +public class tabHandler { + +} diff --git a/src/main/resources/animations.yml b/src/main/resources/animations.yml new file mode 100644 index 0000000..a3f54a3 --- /dev/null +++ b/src/main/resources/animations.yml @@ -0,0 +1,25 @@ +#Animations is the way to make text move! +#You can use them on tab, scoreboard and bossbar +#Placeholder: {animation.animationName} + + +exampleTitle: + #Speed is in minecraft ticks + #20 ticks = 1 second so speed 20 = 1 frame per second + speed: 2 + #Also hate making animations manually? + #You can use animation creation tool (ACT) built in web configurator! + # https://informator.soukup.xyz/configurator/act + frames: + - "&b&3I&b&fNFORMATOR" + - "&b&fI&b&3N&b&fFORMATOR" + - "&b&fIN&b&3F&b&fORMATOR" + - "&b&fINF&b&3O&b&fRMATOR" + - "&b&fINFO&b&3R&b&fMATOR" + - "&b&fINFOR&b&3M&b&fATOR" + - "&b&fINFORM&b&3A&b&fTOR" + - "&b&fINFORMA&b&3T&b&fOR" + - "&b&fINFORMAT&b&3O&b&fR" + - "&b&fINFORMATO&b&3R" + - "&cKONEC" + diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..ccadb33 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,18 @@ +#Language of plugin's core messages. Won't affect language of any module +lang: cz +#Settings for each module can be found in the modules folder +#What features should this plugin handle +modules-enabled: + tab: true + scoreboard: true + motd: true + bossbar: true + +#Configuration for plugin's web interface +web-interface: + #online configurator enabled. We recommend to disable it after setting up the plugin + enabled: true + #API address of the configurator. + #DO NOT CHANGE THIS IF SOMEONE TOLD YOU TO. + #Api is a powerful tool. It can destroy all configuration if in wrong hands + api-address: https://informator.soukup.xyz/configurator/api/ \ No newline at end of file diff --git a/src/main/resources/modules/tab.yml b/src/main/resources/modules/tab.yml new file mode 100644 index 0000000..a99dda0 --- /dev/null +++ b/src/main/resources/modules/tab.yml @@ -0,0 +1,65 @@ +# ____ ____ __ +# / _/___ / __/___ _________ ___ ____ _/ /_____ _____ +# / // __ \/ /_/ __ \/ ___/ __ `__ \/ __ `/ __/ __ \/ ___/ +# _/ // / / / __/ /_/ / / / / / / / / /_/ / /_/ /_/ / / +#/___/_/ /_/_/ \____/_/ /_/ /_/ /_/\__,_/\__/\____/_/ +# + +settings: + +tabs: + default: + priority: 0 + header: + - "" + - "{animation.exampleTitle}" + - "" + - "{animation.exampleLine}" + - "" + footer: + - "" + - "{animation.exampleLine}" + - "" + - "Change this in modules/tab.yml" + - "" + world: + enabled: false + priority: 1 + worlds: + exampleWorld: + enabled: true + header: + - "World specified tab" + - "{animation.exampleTitle}" + - "" + - "{animation.exampleLine}" + - "" + footer: + - "" + - "{animation.exampleLine}" + - "" + - "Change this in modules/tab.yml" + - "" + #tab that will show only to players with certain group + group: + + player: + enabled: false + priority: 3 + players: + examplePlayer: + enabled: true + header: + - "World specified tab" + - "{animation.exampleTitle}" + - "" + - "{animation.exampleLine}" + - "" + footer: + - "" + - "{animation.exampleLine}" + - "" + - "Change this in modules/tab.yml" + - "" + + diff --git a/target/classes/animations.yml b/target/classes/animations.yml new file mode 100644 index 0000000..a3f54a3 --- /dev/null +++ b/target/classes/animations.yml @@ -0,0 +1,25 @@ +#Animations is the way to make text move! +#You can use them on tab, scoreboard and bossbar +#Placeholder: {animation.animationName} + + +exampleTitle: + #Speed is in minecraft ticks + #20 ticks = 1 second so speed 20 = 1 frame per second + speed: 2 + #Also hate making animations manually? + #You can use animation creation tool (ACT) built in web configurator! + # https://informator.soukup.xyz/configurator/act + frames: + - "&b&3I&b&fNFORMATOR" + - "&b&fI&b&3N&b&fFORMATOR" + - "&b&fIN&b&3F&b&fORMATOR" + - "&b&fINF&b&3O&b&fRMATOR" + - "&b&fINFO&b&3R&b&fMATOR" + - "&b&fINFOR&b&3M&b&fATOR" + - "&b&fINFORM&b&3A&b&fTOR" + - "&b&fINFORMA&b&3T&b&fOR" + - "&b&fINFORMAT&b&3O&b&fR" + - "&b&fINFORMATO&b&3R" + - "&cKONEC" + diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..ccadb33 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,18 @@ +#Language of plugin's core messages. Won't affect language of any module +lang: cz +#Settings for each module can be found in the modules folder +#What features should this plugin handle +modules-enabled: + tab: true + scoreboard: true + motd: true + bossbar: true + +#Configuration for plugin's web interface +web-interface: + #online configurator enabled. We recommend to disable it after setting up the plugin + enabled: true + #API address of the configurator. + #DO NOT CHANGE THIS IF SOMEONE TOLD YOU TO. + #Api is a powerful tool. It can destroy all configuration if in wrong hands + api-address: https://informator.soukup.xyz/configurator/api/ \ No newline at end of file diff --git a/target/classes/modules/tab.yml b/target/classes/modules/tab.yml new file mode 100644 index 0000000..80a9543 --- /dev/null +++ b/target/classes/modules/tab.yml @@ -0,0 +1,47 @@ +# ____ ____ __ +# / _/___ / __/___ _________ ___ ____ _/ /_____ _____ +# / // __ \/ /_/ __ \/ ___/ __ `__ \/ __ `/ __/ __ \/ ___/ +# _/ // / / / __/ /_/ / / / / / / / / /_/ / /_/ /_/ / / +#/___/_/ /_/_/ \____/_/ /_/ /_/ /_/\__,_/\__/\____/_/ +# + +settings: + +tabs: + default: + priority: 0 + header: + - "INFORMATOR" + footer: + - "Change this in modules/tab.yml" + world: + enabled: false + priority: 1 + worlds: + exampleWorld: + enabled: true + header: + - "INFORMATOR" + - "" + - "This tab will show up to players" + - "in world exampleWorld" + footer: + - "Change this in modules/tab.yml" + #tab that will show only to players with certain group + group: + + player: + enabled: false + priority: 3 + players: + examplePlayer: + enabled: true + header: + - "INFORMATOR" + - "" + - "This tab will show up to user" + - "with nickname examplePlayer" + footer: + - "Change this in modules/tab.yml" + + diff --git a/target/classes/xyz/soukup/informator/Informator.class b/target/classes/xyz/soukup/informator/Informator.class index 3ab6270..cee02b9 100644 Binary files a/target/classes/xyz/soukup/informator/Informator.class and b/target/classes/xyz/soukup/informator/Informator.class differ diff --git a/target/classes/xyz/soukup/informator/handlers/AnimationHandler.class b/target/classes/xyz/soukup/informator/handlers/AnimationHandler.class new file mode 100644 index 0000000..48f9e33 Binary files /dev/null and b/target/classes/xyz/soukup/informator/handlers/AnimationHandler.class differ diff --git a/target/classes/xyz/soukup/informator/handlers/ConfigHandler.class b/target/classes/xyz/soukup/informator/handlers/ConfigHandler.class new file mode 100644 index 0000000..01a404e Binary files /dev/null and b/target/classes/xyz/soukup/informator/handlers/ConfigHandler.class differ diff --git a/target/classes/xyz/soukup/informator/handlers/clockHandler$1.class b/target/classes/xyz/soukup/informator/handlers/clockHandler$1.class new file mode 100644 index 0000000..0b85198 Binary files /dev/null and b/target/classes/xyz/soukup/informator/handlers/clockHandler$1.class differ diff --git a/target/classes/xyz/soukup/informator/handlers/clockHandler.class b/target/classes/xyz/soukup/informator/handlers/clockHandler.class new file mode 100644 index 0000000..e36e5d9 Binary files /dev/null and b/target/classes/xyz/soukup/informator/handlers/clockHandler.class differ