Skip to content

Commit

Permalink
V3 (#31)
Browse files Browse the repository at this point in the history
* v3

* v3 2

* v3 3

* v3 4

* v3 4

* v3 4

* v3 4

* Update build.yml

* Update build.yml
  • Loading branch information
AceKiron authored Jun 29, 2024
1 parent 6af2495 commit e5d30e9
Show file tree
Hide file tree
Showing 59 changed files with 1,198 additions and 1,324 deletions.
3 changes: 0 additions & 3 deletions .acekiron/test-spigot-plugin.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/build-and-test.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build and test
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/[email protected]

- run: mvn package
19 changes: 0 additions & 19 deletions .github/workflows/publish-javadocs.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/update-license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
LICENSE
commitTitle: "docs: update copyright years"
prTitle: "docs: update copyright years"
prBody: "It's that time of the year, let's update the license"
prBody: "It's that time of the year, let's update the license"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.idea/
target/
javadoc/
dependency-reduced-pom.xml
1 change: 1 addition & 0 deletions PronounMC.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
Expand Down
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
# PronounMC
### A Minecraft plugin for sharing pronouns.
PronounMC, originally meant as a pride month project for 2022, started development on January 21st 2022 and got its first release on April 19th 2022.
But development didn't stop there, several updates and even complete rewrites have been made since.

## Commands
- **/pronounmc**: Opens a GUI which lets you change your pronouns.
- **/viewpronouns**: Lists a player's pronouns to the sender in chat.

## Permissions
- **pronounmc.modify**: Required for modifying pronouns of yourself or someone else.
- **pronounmc.modify.other**: Required for modifying pronouns of someone else.
- **pronounmc.view**: View your own pronouns.
- **pronounmc.view.other**: View somebody else's pronouns.

## Contact
Discord server invite code: `trkeYgm4ds`

Main developer's Discord username: `_mx_ace`
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<modelVersion>4.0.0</modelVersion>

<groupId>dev.mxace</groupId>
<artifactId>PronounMC</artifactId>
<version>2.4</version>
<artifactId>pronounmc</artifactId>
<version>3.0</version>
<packaging>jar</packaging>

<name>PronounMC</name>

<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -21,10 +21,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.11.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
</plugins>
Expand All @@ -51,14 +51,14 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<scope>compile</scope>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.44.1.0</version>
</dependency>
</dependencies>
</project>
138 changes: 100 additions & 38 deletions src/main/java/dev/mxace/pronounmc/PronounMC.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,124 @@
package dev.mxace.pronounmc;

import dev.mxace.pronounmc.api.PronounAPI;
import dev.mxace.pronounmc.api.PronounsDatabase;
import dev.mxace.pronounmc.commandexecutors.PronounmcCommandExecutor;
import dev.mxace.pronounmc.commandexecutors.ViewpronounsCommandExecutor;
import dev.mxace.pronounmc.commands.MyPronounsCommand;
import dev.mxace.pronounmc.commands.PronounsInfoCommand;
import dev.mxace.pronounmc.config.AcceptanceStatusesConfig;
import dev.mxace.pronounmc.config.PronounsConfig;
import dev.mxace.pronounmc.config.SimpleConfig;
import dev.mxace.pronounmc.config.TextsConfig;
import dev.mxace.pronounmc.handlers.ChatHandler;
import dev.mxace.pronounmc.handlers.JoinHandler;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;

/**
* Main class for PronounMC.
* @see org.bukkit.plugin.java.JavaPlugin
* @author AceKiron
* @version 2.3
*/
public final class PronounMC extends JavaPlugin {
/**
* Singleton instance of the PronounMC plugin.
* @see org.bukkit.plugin.java.JavaPlugin
*/
public static PronounMC instance;

/**
* Spigot plugins require a public constructor.
*/
public PronounMC() {
public static PronounMC pluginInstance;

private PronounMCDatabase database;

private SimpleConfig config;
private PronounsConfig pronounsConfig;
private TextsConfig textsConfig;
private AcceptanceStatusesConfig acceptanceStatusesConfig;

private void registerCommand(Class<?> c, String commandName) {
PluginCommand pc = getCommand(commandName);
if (pc == null) {
Bukkit.getLogger().log(Level.SEVERE, "Could not find /" + commandName + " command.");
Bukkit.getPluginManager().disablePlugin(this);
} else {
try {
Object commandInstance = c.getDeclaredField("commandInstance").get(null);

pc.setExecutor((CommandExecutor) commandInstance);
pc.setTabCompleter((TabCompleter) commandInstance);
} catch (NoSuchFieldException | IllegalAccessException ex) {
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage());
Bukkit.getPluginManager().disablePlugin(this);
}
}
}

/**
* Called on plugin enable.
* Replaces the instance singleton, loads the default pronouns sets and sets command executors.
* @throws RuntimeException Gets thrown if the pronouns sets couldn't be loaded.
* @see dev.mxace.pronounmc.api.pronounssets
*/
@Override
public void onEnable() {
instance = this;
pluginInstance = this;

config = new SimpleConfig();
pronounsConfig = new PronounsConfig();
textsConfig = new TextsConfig();
acceptanceStatusesConfig = new AcceptanceStatusesConfig();

if (!getDataFolder().exists()) {
if (!getDataFolder().mkdirs()) {
Bukkit.getLogger().warning("Data folder could not be created.");
}
}

// Load all pronouns
try {
PronounAPI.instance.loadPronounsSetsInPackage(getClassLoader(), "dev.mxace.pronounmc.api.pronounssets");
} catch (IOException | ClassNotFoundException e) {
throw new RuntimeException(e);
database = new PronounMCDatabase("pronouns.db");
} catch (SQLException | IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage());
Bukkit.getPluginManager().disablePlugin(this);
}

getCommand("pronounmc").setExecutor(PronounmcCommandExecutor.instance);
getCommand("viewpronouns").setExecutor(ViewpronounsCommandExecutor.instance);
registerCommand(PronounsInfoCommand.class, "pronounsinfo");
registerCommand(MyPronounsCommand.class, "mypronouns");

try {
JoinHandler joinHandler = new JoinHandler(pronounsConfig.getAllIdentifiers());
getServer().getPluginManager().registerEvents(joinHandler, this);

for (Player p : getServer().getOnlinePlayers()) {
try {
joinHandler.registerDefaultPronounsAcceptanceStatuses(p.getUniqueId());
} catch (SQLException ex) {
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage());
}
}
} catch (IOException ex) {
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage());
}

getServer().getPluginManager().registerEvents(new ChatHandler(), this);
}

/**
* Called on plugin disable.
* Saves any unsaved changes to the database.
* @see dev.mxace.pronounmc.api.PronounsDatabase
*/
@Override
public void onDisable() {
PronounsDatabase.instance.save();
try {
database.closeConnection();
} catch (SQLException ex) {
Bukkit.getLogger().log(Level.WARNING, ex.getMessage());
}
}

public PronounMCDatabase getDatabase() {
return database;
}

public AcceptanceStatusesConfig getAcceptanceStatusesConfig() {
return acceptanceStatusesConfig;
}

public SimpleConfig getSimpleConfig() {
return config;
}

public PronounsConfig getPronounsConfig() {
return pronounsConfig;
}

public TextsConfig getTextsConfig() {
return textsConfig;
}

}
Loading

0 comments on commit e5d30e9

Please sign in to comment.