commit 714fdcc31232a90ad2aef93d99f89f8a59b844b1 Author: Richard Mikloš Date: Mon Jul 22 21:10:03 2024 +0200 Init diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..8064f27 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..ec38a59 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..df1ef66 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a4ee625 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/ColorfulWords.iml b/ColorfulWords.iml new file mode 100644 index 0000000..bbeeb3e --- /dev/null +++ b/ColorfulWords.iml @@ -0,0 +1,14 @@ + + + + + + + PAPER + ADVENTURE + + 1 + + + + \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..d6e624c --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + org.twip-network + ColorfulWords + ColorfulWords + 1.0-1.21 + + + + true + src/main/resources + + + + + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/repositories/snapshots/ + + + + + io.papermc.paper + paper-api + 1.21-R0.1-SNAPSHOT + provided + + + + 21 + UTF-8 + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..cdc109a --- /dev/null +++ b/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + + org.twip-network + ColorfulWords + 1.0-1.21 + jar + + ColorfulWords + + + 21 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + sonatype + https://oss.sonatype.org/content/repositories/snapshots/ + + + + + + io.papermc.paper + paper-api + 1.21-R0.1-SNAPSHOT + provided + + + net.kyori + adventure-api + 4.17.0 + + + net.kyori + adventure-platform-bukkit + 4.3.3 + + + diff --git a/src/main/java/org/twipnetwork/colorfulwords/ChatListener.java b/src/main/java/org/twipnetwork/colorfulwords/ChatListener.java new file mode 100644 index 0000000..92d7ccb --- /dev/null +++ b/src/main/java/org/twipnetwork/colorfulwords/ChatListener.java @@ -0,0 +1,25 @@ +package org.twipnetwork.colorfulwords; + +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.TextColor; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +public class ChatListener implements Listener { + private final ColorfulWords plugin; + + public ChatListener(ColorfulWords plugin) { + this.plugin = plugin; + } + + @EventHandler + public void onPlayerChat(AsyncPlayerChatEvent event) { + String colorHex = plugin.getPlayerColor(event.getPlayer().getUniqueId()); + if (colorHex != null) { + TextColor color = TextColor.fromHexString(colorHex); + String coloredMessage = Component.text(event.getMessage()).color(color).toString(); + event.setFormat("%1$s: " + coloredMessage); + } + } +} diff --git a/src/main/java/org/twipnetwork/colorfulwords/ColorCommand.java b/src/main/java/org/twipnetwork/colorfulwords/ColorCommand.java new file mode 100644 index 0000000..1b5fbc2 --- /dev/null +++ b/src/main/java/org/twipnetwork/colorfulwords/ColorCommand.java @@ -0,0 +1,42 @@ +package org.twipnetwork.colorfulwords; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class ColorCommand implements CommandExecutor { + private final ColorfulWords plugin; + + public ColorCommand(ColorfulWords plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!(sender instanceof Player)) { + sender.sendMessage("This command can only be used by players."); + return true; + } + + Player player = (Player) sender; + if (args.length != 1) { + player.sendMessage(ChatColor.RED + "Usage: /color |reset"); + return true; + } + + String colorHex = args[0]; + if (colorHex.equalsIgnoreCase("reset")) { + plugin.resetPlayerColor(player.getUniqueId()); + player.sendMessage(ChatColor.GREEN + "Your chat color has been reset."); + } else if (colorHex.matches("^#[a-fA-F0-9]{6}$")) { + plugin.setPlayerColor(player.getUniqueId(), colorHex); + player.sendMessage(ChatColor.GREEN + "Your chat color has been set to " + colorHex + "."); + } else { + player.sendMessage(ChatColor.RED + "Invalid hex color. Please use a valid hex code."); + } + + return true; + } +} diff --git a/src/main/java/org/twipnetwork/colorfulwords/ColorfulWords.java b/src/main/java/org/twipnetwork/colorfulwords/ColorfulWords.java new file mode 100644 index 0000000..cc27639 --- /dev/null +++ b/src/main/java/org/twipnetwork/colorfulwords/ColorfulWords.java @@ -0,0 +1,39 @@ +package org.twipnetwork.colorfulwords; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.UUID; + +public final class ColorfulWords extends JavaPlugin { + + @Override + public void onEnable() { + // Plugin startup logic + saveDefaultConfig(); + getServer().getPluginManager().registerEvents(new ChatListener(this), this); + getCommand("color").setExecutor(new ColorCommand(this)); + } + + @Override + public void onDisable() { + // Plugin shutdown logic + } + + public String getPlayerColor(UUID playerId) { + FileConfiguration config = getConfig(); + return config.getString("players." + playerId.toString()); + } + + public void setPlayerColor(UUID playerId, String colorHex) { + FileConfiguration config = getConfig(); + config.set("players." + playerId.toString(), colorHex); + saveConfig(); + } + + public void resetPlayerColor(UUID playerId) { + FileConfiguration config = getConfig(); + config.set("players." + playerId.toString(), null); + saveConfig(); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..a8bf447 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,10 @@ +name: ColorfulWords +version: 1.0-1.21 +main: org.twipnetwork.colorfulwords.ColorfulWords +api-version: 1.21 +commands: + color: + description: Change your chat color + usage: /color |reset + permission: colorfulwords.color + permission-message: You do not have permission to use this command. diff --git a/target/ColorfulWords-1.0-1.21-shaded.jar b/target/ColorfulWords-1.0-1.21-shaded.jar new file mode 100644 index 0000000..dadd1fa Binary files /dev/null and b/target/ColorfulWords-1.0-1.21-shaded.jar differ diff --git a/target/ColorfulWords-1.0-1.21.jar b/target/ColorfulWords-1.0-1.21.jar new file mode 100644 index 0000000..dadd1fa Binary files /dev/null and b/target/ColorfulWords-1.0-1.21.jar differ diff --git a/target/classes/org/twipnetwork/colorfulwords/ChatListener.class b/target/classes/org/twipnetwork/colorfulwords/ChatListener.class new file mode 100644 index 0000000..a0f90f2 Binary files /dev/null and b/target/classes/org/twipnetwork/colorfulwords/ChatListener.class differ diff --git a/target/classes/org/twipnetwork/colorfulwords/ColorCommand.class b/target/classes/org/twipnetwork/colorfulwords/ColorCommand.class new file mode 100644 index 0000000..e2ffc1e Binary files /dev/null and b/target/classes/org/twipnetwork/colorfulwords/ColorCommand.class differ diff --git a/target/classes/org/twipnetwork/colorfulwords/ColorfulWords.class b/target/classes/org/twipnetwork/colorfulwords/ColorfulWords.class new file mode 100644 index 0000000..a89e34a Binary files /dev/null and b/target/classes/org/twipnetwork/colorfulwords/ColorfulWords.class differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..a8bf447 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,10 @@ +name: ColorfulWords +version: 1.0-1.21 +main: org.twipnetwork.colorfulwords.ColorfulWords +api-version: 1.21 +commands: + color: + description: Change your chat color + usage: /color |reset + permission: colorfulwords.color + permission-message: You do not have permission to use this command. diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..8ea2f6f --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=ColorfulWords +groupId=org.twip-network +version=1.0-1.21 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..5481bed --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,3 @@ +org\twipnetwork\colorfulwords\ColorCommand.class +org\twipnetwork\colorfulwords\ColorfulWords.class +org\twipnetwork\colorfulwords\ChatListener.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..b93f707 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,2 @@ +C:\DEV\JAVA\IntelliJ\ColorfulWords\src\main\java\org\twipnetwork\colorfulwords\ColorfulWords.java +C:\DEV\JAVA\IntelliJ\ColorfulWords\src\main\java\org\twipnetwork\colorfulwords\ChatListener.java diff --git a/target/original-ColorfulWords-1.0-1.21.jar b/target/original-ColorfulWords-1.0-1.21.jar new file mode 100644 index 0000000..399e47e Binary files /dev/null and b/target/original-ColorfulWords-1.0-1.21.jar differ