jakub 2 years ago
parent d31738b773
commit 141d5ef24a
  1. 2
      .idea/artifacts/Informator_jar.xml
  2. 3
      .idea/misc.xml
  3. 7
      src/main/java/xyz/soukup/informator/Informator.java
  4. 6
      src/main/java/xyz/soukup/informator/handlers/AnimationHandler.java
  5. 7
      src/main/java/xyz/soukup/informator/handlers/ConfigHandler.java
  6. 46
      src/main/java/xyz/soukup/informator/handlers/PlaceholderHandler.java
  7. 78
      src/main/java/xyz/soukup/informator/handlers/TabHandler.java
  8. 8
      src/main/java/xyz/soukup/informator/handlers/clockHandler.java
  9. 5
      src/main/java/xyz/soukup/informator/handlers/tabHandler.java
  10. 4
      src/main/resources/animations.yml
  11. 1
      src/main/resources/config.yml
  12. 45
      src/main/resources/modules/tab.yml
  13. 57
      target/classes/modules/tab.yml
  14. BIN
      target/classes/xyz/soukup/informator/Informator.class
  15. BIN
      target/classes/xyz/soukup/informator/handlers/AnimationHandler.class
  16. BIN
      target/classes/xyz/soukup/informator/handlers/ConfigHandler.class
  17. BIN
      target/classes/xyz/soukup/informator/handlers/PlaceholderHandler.class
  18. BIN
      target/classes/xyz/soukup/informator/handlers/TabHandler.class
  19. BIN
      target/classes/xyz/soukup/informator/handlers/clockHandler$1.class
  20. BIN
      target/classes/xyz/soukup/informator/handlers/clockHandler.class

@ -1,6 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="Informator:jar">
<output-path>$USER_HOME$/Plocha/betaserver/plugins/</output-path>
<output-path>$USER_HOME$/Plocha/beta server/plugins</output-path>
<root id="archive" name="Informator.jar">
<element id="module-output" name="Informator" />
</root>

@ -12,8 +12,9 @@
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="corretto-20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -4,6 +4,7 @@ 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.TabHandler;
import xyz.soukup.informator.handlers.clockHandler;
import java.io.IOException;
@ -46,13 +47,17 @@ public final class Informator extends JavaPlugin {
throw new RuntimeException(e);
}
AnimationHandler.loadAnimations();
clockHandler.centralClock
if (ConfigHandler.config.getBoolean("modules-enabled.tab")){
TabHandler.loadTabs();
}
clockHandler clockHandler = new clockHandler();
logger.info("");
logger.info("\u001B[33m===========================================================");
logger.info("");
logger.info("\u001B[34m Informator loaded!");
logger.info("");
logger.info("\u001B[33m===========================================================");
TabHandler.loadTabs();
}
public static Informator getPlugin(){
return instance;

@ -19,7 +19,6 @@ public class AnimationHandler {
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));
@ -47,15 +46,14 @@ public class AnimationHandler {
}
cycles++;
}
public static String getCurrentFrame(String name){
if (animations.contains(name))
return animationFrames.get(name).get(currentFrame.get(name))+ " " + currentFrame.get(name);
return animationFrames.get(name).get(currentFrame.get(name));
else
return null;
return "&cinvalid animation";
}
}

@ -16,6 +16,9 @@ public class ConfigHandler {
static Informator plugin = Informator.getPlugin();
static Logger logger = plugin.getLogger();
public static YamlConfiguration animationConfig = new YamlConfiguration();
public static YamlConfiguration config = new YamlConfiguration();
public static YamlConfiguration tabConfig = new YamlConfiguration();
public static void loadConfigs() throws IOException, InvalidConfigurationException {
List<String> configsToLoad = new ArrayList<>();
configsToLoad.add("config.yml");
@ -29,6 +32,10 @@ public class ConfigHandler {
}
animationConfig.load(new File(plugin.getDataFolder(), "animations.yml"));
tabConfig.load(new File(plugin.getDataFolder(), "modules/tab.yml"));
config.load(new File(plugin.getDataFolder(), "config.yml"));
}

@ -0,0 +1,46 @@
package xyz.soukup.informator.handlers;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PlaceholderHandler {
public static String substituteAll(String text, Player player){
String result = substitudeAnimation(text);
result = substitudeColor(result);
return result;
}
public static String substitudeAnimation(String text){
// Define the regular expression pattern for placeholders
Pattern pattern = Pattern.compile("%%animation:(.*?)%%");
// Create a matcher with the input string
Matcher matcher = pattern.matcher(text);
// StringBuffer to hold the result
StringBuffer result = new StringBuffer();
// Find and replace placeholders
while (matcher.find()) {
// Get the animation name
String animationName = matcher.group(1);
// Look up the corresponding value from the map
String replacement = AnimationHandler.getCurrentFrame(animationName);
// Append the replacement to the result
matcher.appendReplacement(result, replacement);
}
// Append the remainder of the input string after the last match
matcher.appendTail(result);
// Convert the result to a String
return result.toString();
}
public static String substitudeColor(String text){
return ChatColor.translateAlternateColorCodes('&', text);
}
}

@ -0,0 +1,78 @@
package xyz.soukup.informator.handlers;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.stream.Collectors;
public class TabHandler {
private static HashMap<String, List<Object>> tabData = new HashMap<>();
public static HashMap<Player, String> playerTab = new HashMap<>();
private static final YamlConfiguration tabConfig = ConfigHandler.tabConfig;
public static void loadTabs(){
List<String> tabSources = new ArrayList<>();
tabSources.add("tabs.required");
tabSources.add("tabs.world.worlds");
tabSources.add("tabs.group.groups");
tabSources.add("tabs.player.players");
for(String targetKey: tabSources){
ConfigurationSection targetSection = tabConfig.getConfigurationSection(targetKey);
if (targetSection != null) {
Set<String> keys = targetSection.getKeys(false);
for (String key : keys) {
List<Object> tabDataList = new ArrayList<>();
tabDataList.add(tabConfig.getInt(targetKey + "." + key + ".priority"));
List<String> header = tabConfig.getStringList(targetKey + "." + key + ".header");
List<String> footer = tabConfig.getStringList(targetKey + "." + key + ".footer");
String headerString = String.join("\n&r", header);
String footerString = String.join("\n&r", footer);
tabDataList.add(headerString);
tabDataList.add(footerString);
tabData.put(targetKey + "." + key, tabDataList);
}
}
}
}
public static void chooseTab(Player player){
String choosenTab = "tabs.required.default";
int choosenPriority = tabConfig.getInt("tabs.required.default.priority");
if (tabData.containsKey("tabs.player.players." + player.getDisplayName())){
player.sendMessage("ss"+choosenPriority);
if ((int)tabData.get("tabs.player.players." + player.getDisplayName()).get(0) > choosenPriority){
player.sendMessage("SSSSSSSS");
choosenTab = "tabs.player.players." + player.getDisplayName();
choosenPriority = (int)tabData.get("tabs.player.players." + player.getDisplayName()).get(0);
}
}
if (tabData.containsKey("tabs.world.worlds." + player.getWorld().getName())){
if ((int)tabData.get("tabs.world.worlds." + player.getWorld().getName()).get(0) > choosenPriority){
choosenTab = "tab.world.worlds." + player.getWorld().getName();
}
}
playerTab.put(player, choosenTab);
}
public static void refreshTabs(){
for (Player player : Bukkit.getOnlinePlayers()){
if (!playerTab.containsKey(player)){
chooseTab(player);
}
player.setPlayerListHeader(PlaceholderHandler.substituteAll((String) tabData.get(playerTab.get(player)).get(1), player));
player.setPlayerListFooter(PlaceholderHandler.substituteAll((String) tabData.get(playerTab.get(player)).get(2), player));
}
}
}

@ -11,16 +11,16 @@ 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"))));
if (ConfigHandler.config.getBoolean("modules-enabled.tab")){
TabHandler.refreshTabs();
}
}
}.runTaskTimer(plugin, 0, 1L);

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

@ -6,7 +6,7 @@
exampleTitle:
#Speed is in minecraft ticks
#20 ticks = 1 second so speed 20 = 1 frame per second
speed: 2
speed: 4
#Also hate making animations manually?
#You can use animation creation tool (ACT) built in web configurator!
# https://informator.soukup.xyz/configurator/act
@ -21,5 +21,5 @@ exampleTitle:
- "&b&fINFORMA&b&3T&b&fOR"
- "&b&fINFORMAT&b&3O&b&fR"
- "&b&fINFORMATO&b&3R"
- "&cKONEC"

@ -9,6 +9,7 @@ modules-enabled:
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

@ -5,20 +5,21 @@
#/___/_/ /_/_/ \____/_/ /_/ /_/ /_/\__,_/\__/\____/_/
#
settings:
enabled: true
tabs:
required:
default:
priority: 0
header:
- ""
- "{animation.exampleTitle}"
- "%%animation:exampleTitle%%"
- ""
- "{animation.exampleLine}"
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "{animation.exampleLine}"
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""
@ -30,34 +31,50 @@ tabs:
enabled: true
header:
- "World specified tab"
- "{animation.exampleTitle}"
- "%%animation:exampleTitle%%"
- ""
- "{animation.exampleLine}"
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "{animation.exampleLine}"
- "%%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:
groups:
exampleGroup:
enabled: true
header:
- "World specified tab"
- "{animation.exampleTitle}"
- "%%animation:exampleTitle%%"
- ""
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""
player:
enabled: false
players:
Kuba1428:
priority: 3
enabled: true
header:
- "Player specified tab"
- "%%animation:exampleTitle%%"
- ""
- "{animation.exampleLine}"
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "{animation.exampleLine}"
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""

@ -5,15 +5,24 @@
#/___/_/ /_/_/ \____/_/ /_/ /_/ /_/\__,_/\__/\____/_/
#
settings:
enabled: true
tabs:
required:
default:
priority: 0
header:
- "INFORMATOR"
- ""
- "%%animation:exampleTitle%%"
- ""
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""
world:
enabled: false
priority: 1
@ -21,27 +30,53 @@ tabs:
exampleWorld:
enabled: true
header:
- "INFORMATOR"
- "World specified tab"
- "%%animation:exampleTitle%%"
- ""
- "%%animation:exampleLine%%"
- ""
- "This tab will show up to players"
- "in world exampleWorld"
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
groups:
exampleGroup:
enabled: true
header:
- "World specified tab"
- "%%animation:exampleTitle%%"
- ""
- "%%animation:exampleLine%%"
- ""
footer:
- ""
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""
player:
enabled: false
players:
examplePlayer:
Kuba1428:
priority: 3
enabled: true
header:
- "INFORMATOR"
- "Player specified tab"
- "%%animation:exampleTitle%%"
- ""
- "%%animation:exampleLine%%"
- ""
- "This tab will show up to user"
- "with nickname examplePlayer"
footer:
- ""
- "%%animation:exampleLine%%"
- ""
- "Change this in modules/tab.yml"
- ""

Loading…
Cancel
Save