-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f15022d
Showing
12 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Build and upload artifact | ||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-jar: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Maven Action | ||
uses: s4u/setup-maven-action@v1.18.0 | ||
with: | ||
java-version: 21 | ||
|
||
- run: mvn package | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: pmc-base | ||
path: target/pmc-chat-addon-*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Update copyright year(s) in license file | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 3 1 1 *' | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: FantasticFiasco/action-update-license-year@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
path: | | ||
LICENSE | ||
commitTitle: "docs: update copyright years" | ||
prTitle: "docs: update copyright years" | ||
prBody: "It's that time of the year, let's update the license" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2025 AceKiron | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module version="4"> | ||
<component name="FacetManager"> | ||
<facet type="minecraft" name="Minecraft"> | ||
<configuration> | ||
<autoDetectTypes> | ||
<platformType>SPIGOT</platformType> | ||
</autoDetectTypes> | ||
<projectReimportVersion>1</projectReimportVersion> | ||
</configuration> | ||
</facet> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.github.PronounMC</groupId> | ||
<artifactId>pmc-chat-addon</artifactId> | ||
<version>2025.1</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>PronounMC-ChatAddon</name> | ||
|
||
<properties> | ||
<java.version>21</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.13.0</version> | ||
<configuration> | ||
<source>${java.version}</source> | ||
<target>${java.version}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
<repository> | ||
<id>placeholderapi</id> | ||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url> | ||
</repository> | ||
<repository> | ||
<id>pronounmc</id> | ||
<url>https://maven.pkg.github.com/PronounMC/pmc-base</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.21.4-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>me.clip</groupId> | ||
<artifactId>placeholderapi</artifactId> | ||
<version>2.11.6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.PronounMC</groupId> | ||
<artifactId>pmc-base</artifactId> | ||
<version>2025.1</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
41 changes: 41 additions & 0 deletions
41
src/main/java/dev/mxace/pronounmc/addons/chataddon/ChatAddon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.mxace.pronounmc.addons.chataddon; | ||
|
||
import dev.mxace.pronounmc.addons.chataddon.listeners.ChatListener; | ||
import dev.mxace.pronounmc.addons.chataddon.listeners.PlaceholderAPIChatListener; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.configuration.InvalidConfigurationException; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public final class ChatAddon extends JavaPlugin { | ||
|
||
@Override | ||
public void onEnable() { | ||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { | ||
// PlaceholderAPI found | ||
File file = new File(getDataFolder(), "config.yml"); | ||
|
||
if (!file.exists()) { | ||
saveResource("config.yml", false); | ||
} | ||
|
||
YamlConfiguration yaml = new YamlConfiguration(); | ||
yaml.options().parseComments(true); | ||
|
||
try { | ||
yaml.load(file); | ||
} catch (IOException | InvalidConfigurationException ex) { | ||
Bukkit.getLogger().severe("Could not load config from '" + file.getPath() + "'."); | ||
} | ||
|
||
getServer().getPluginManager().registerEvents(new PlaceholderAPIChatListener(yaml.getString("placeholderapi-chat-format", "<%player_name%>[%pronounmc_identifier%]")), this); | ||
} else { | ||
// PlaceholderAPI not found | ||
getServer().getPluginManager().registerEvents(new ChatListener(), this); | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/dev/mxace/pronounmc/addons/chataddon/ChatAddonConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package dev.mxace.pronounmc.addons.chataddon; | ||
|
||
public class ChatAddonConfig { | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/dev/mxace/pronounmc/addons/chataddon/listeners/ChatListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package dev.mxace.pronounmc.addons.chataddon.listeners; | ||
|
||
import dev.mxace.pronounmc.manager.PronounsManager; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
|
||
public class ChatListener implements Listener { | ||
@EventHandler(priority = EventPriority.LOWEST) | ||
public void onPlayerChat(AsyncPlayerChatEvent event) { | ||
event.setCancelled(true); | ||
|
||
String msg = "<" + event.getPlayer().getDisplayName() + ">[" + PronounsManager.getPronouns(event.getPlayer()).getIdentifier() + "] " + event.getMessage(); | ||
|
||
Bukkit.getLogger().info(msg); | ||
|
||
for (Player recipient : event.getRecipients()) { | ||
recipient.sendMessage(msg); | ||
} | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/dev/mxace/pronounmc/addons/chataddon/listeners/PlaceholderAPIChatListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dev.mxace.pronounmc.addons.chataddon.listeners; | ||
|
||
import me.clip.placeholderapi.PlaceholderAPI; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
|
||
public class PlaceholderAPIChatListener implements Listener { | ||
private final String format; | ||
|
||
public PlaceholderAPIChatListener(String format) { | ||
this.format = format; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.LOWEST) | ||
public void onPlayerChat(AsyncPlayerChatEvent event) { | ||
event.setCancelled(true); | ||
|
||
String msg = PlaceholderAPI.setPlaceholders(event.getPlayer(), format) + " " + event.getMessage(); | ||
|
||
Bukkit.getLogger().info(msg); | ||
|
||
for (Player recipient : event.getRecipients()) { | ||
recipient.sendMessage(msg); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
placeholderapi-chat-format: "<%player_name%>[%pronounmc_identifier%]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: PronounMC-ChatAddon | ||
version: '2025.1' | ||
main: dev.mxace.pronounmc.addons.chataddon.ChatAddon | ||
api-version: '1.21' | ||
depend: | ||
- PronounMC | ||
softdepend: | ||
- PlaceholderAPI |