This commit is contained in:
2024-07-22 21:10:03 +02:00
commit 714fdcc312
23 changed files with 369 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

13
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="ColorfulWords" />
</profile>
</annotationProcessing>
</component>
</project>

7
.idea/encodings.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

35
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="papermc-repo" />
<option name="name" value="papermc-repo" />
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="sonatype" />
<option name="name" value="sonatype" />
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
</remote-repository>
</component>
</project>

15
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
<option name="workspaceImportForciblyTurnedOn" value="true" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="corretto-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/ColorfulWords.iml" filepath="$PROJECT_DIR$/ColorfulWords.iml" />
</modules>
</component>
</project>

14
ColorfulWords.iml Normal file
View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.twip-network</groupId>
<artifactId>ColorfulWords</artifactId>
<name>ColorfulWords</name>
<version>1.0-1.21</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

80
pom.xml Normal file
View File

@@ -0,0 +1,80 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.twip-network</groupId>
<artifactId>ColorfulWords</artifactId>
<version>1.0-1.21</version>
<packaging>jar</packaging>
<name>ColorfulWords</name>
<properties>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
</project>

View File

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

View File

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

View File

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

View File

@@ -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 <hex>|reset
permission: colorfulwords.color
permission-message: You do not have permission to use this command.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.

10
target/classes/plugin.yml Normal file
View File

@@ -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 <hex>|reset
permission: colorfulwords.color
permission-message: You do not have permission to use this command.

View File

@@ -0,0 +1,3 @@
artifactId=ColorfulWords
groupId=org.twip-network
version=1.0-1.21

View File

@@ -0,0 +1,3 @@
org\twipnetwork\colorfulwords\ColorCommand.class
org\twipnetwork\colorfulwords\ColorfulWords.class
org\twipnetwork\colorfulwords\ChatListener.class

View File

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

View File

Binary file not shown.