první commit

master
jakub 2 years ago
parent 7f8ba1dc03
commit d31738b773
  1. 124
      .idea/uiDesigner.xml
  2. 70
      src/main/java/xyz/soukup/informator/Informator.java
  3. 61
      src/main/java/xyz/soukup/informator/handlers/AnimationHandler.java
  4. 35
      src/main/java/xyz/soukup/informator/handlers/ConfigHandler.java
  5. 27
      src/main/java/xyz/soukup/informator/handlers/clockHandler.java
  6. 5
      src/main/java/xyz/soukup/informator/handlers/tabHandler.java
  7. 25
      src/main/resources/animations.yml
  8. 18
      src/main/resources/config.yml
  9. 65
      src/main/resources/modules/tab.yml
  10. 25
      target/classes/animations.yml
  11. 18
      target/classes/config.yml
  12. 47
      target/classes/modules/tab.yml
  13. BIN
      target/classes/xyz/soukup/informator/Informator.class
  14. BIN
      target/classes/xyz/soukup/informator/handlers/AnimationHandler.class
  15. BIN
      target/classes/xyz/soukup/informator/handlers/ConfigHandler.class
  16. BIN
      target/classes/xyz/soukup/informator/handlers/clockHandler$1.class
  17. BIN
      target/classes/xyz/soukup/informator/handlers/clockHandler.class

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -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 {
}

@ -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<String> animations = new ArrayList<String>();
private static final HashMap<String, List<String>> animationFrames = new HashMap<String, List<String>>();
private static final HashMap<String, Integer> tpsCounter = new HashMap<String, Integer>();
private static final HashMap<String, Integer> animationSpeed = new HashMap<String, Integer>();
private static final HashMap<String, Integer> currentFrame = new HashMap<String, Integer>();
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;
}
}

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

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

@ -0,0 +1,5 @@
package xyz.soukup.informator.handlers;
public class tabHandler {
}

@ -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"

@ -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/

@ -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"
- ""

@ -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"

@ -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/

@ -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"
Loading…
Cancel
Save