Skip to content

Commit

Permalink
Add contributions guidelines and fix style standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Sep 28, 2024
1 parent 11c7b6a commit d571152
Show file tree
Hide file tree
Showing 51 changed files with 619 additions and 365 deletions.
23 changes: 19 additions & 4 deletions PW Code Style.xml → .contributing/PW_Style.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<code_scheme name="Phantom Worlds Style" version="173">
<code_scheme name="PW Style" version="173">
<option name="RIGHT_MARGIN" value="100" />
<JavaCodeStyleSettings>
<option name="GENERATE_FINAL_LOCALS" value="true" />
<option name="GENERATE_FINAL_PARAMETERS" value="true" />
<option name="SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENT" value="true" />
<option name="ALIGN_MULTILINE_ANNOTATION_PARAMETERS" value="true" />
<option name="ALIGN_MULTILINE_TEXT_BLOCKS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="JD_ALIGN_PARAM_COMMENTS" value="false" />
<option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" />
<option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
<option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
<option name="JD_P_AT_EMPTY_LINES" value="false" />
Expand All @@ -17,8 +19,17 @@
<codeStyleSettings language="JAVA">
<option name="RIGHT_MARGIN" value="100" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
<option name="CASE_STATEMENT_ON_NEW_LINE" value="false" />
<option name="BLANK_LINES_BEFORE_METHOD_BODY" value="1" />
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="1" />
<option name="ALIGN_MULTILINE_PARAMETERS_IN_CALLS" value="true" />
<option name="ALIGN_MULTILINE_BINARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_ASSIGNMENT" value="true" />
<option name="ALIGN_MULTILINE_TERNARY_OPERATION" value="true" />
<option name="ALIGN_MULTILINE_METHOD_BRACKETS" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="SPACE_AROUND_LAMBDA_ARROW" value="false" />
<option name="SPACE_WITHIN_BRACES" value="true" />
<option name="SPACE_WITHIN_ARRAY_INITIALIZER_BRACES" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
Expand All @@ -33,6 +44,10 @@
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="WRAP_COMMENTS" value="true" />
<option name="IF_BRACE_FORCE" value="1" />
<option name="DOWHILE_BRACE_FORCE" value="1" />
<option name="WHILE_BRACE_FORCE" value="1" />
<option name="FOR_BRACE_FORCE" value="1" />
<option name="WRAP_ON_TYPING" value="0" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
Expand Down
80 changes: 80 additions & 0 deletions .contributing/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Contributing to PhantomWorlds

We welcome contributions to PhantomWorlds plugin and appreciate your efforts to improve the project! Before getting started, please take a moment to review these guidelines to help streamline the process and ensure consistency across contributions.

### Style Guidelines

To maintain a consistent codebase, please adhere to the following style guidelines:

#### 1. Import the Code Style
Use the code style defined in the [PW_Style.xml](PW_Style.xml) file. You can import this file into your IntelliJ environment by following these steps:

1. Navigate to `File` -> `Settings` -> `Editor` -> `Code Style`.
2. Click on the gear icon and select `Import Scheme`.
3. Choose `IntelliJ IDEA code style XML` and select the `PW_Style.xml` file located in the `.contributing/` folder.

This will ensure that your code adheres to the project's formatting rules.

#### 2. Final Obsession IntelliJ Plugin

We recommend using the **Final Obsession** plugin to ensure that all applicable variables, fields, and method parameters are declared `final` where appropriate. This helps maintain immutability, enhancing code safety and readability.

##### Installation:

1. In IntelliJ, go to `File` -> `Settings` -> `Plugins`.
2. Search for the plugin [Final Obsession](https://plugins.jetbrains.com/plugin/21687-final-obsession).
3. Click `Install`.
4. Restart IntelliJ to activate the plugin.

## Contributor License Agreement (CLA)

Before submitting your first pull request, you must sign our Contributor License Agreement (CLA). This is required to ensure that we can freely use your contributions while maintaining the integrity of the project's licensing.

## Licensing for Contributions

All new contributions to this project will be licensed under the [AGPLv3](https://www.gnu.org/licenses/agpl-3.0.html) license. By contributing, you agree that your contributions will also be licensed under this license.

## Best Practices for Branch Names

To help organize the development process, we follow specific conventions for branch names based on their purpose:

### Feature Branches
Feature branches are used for developing new features. Use the prefix `feature/` or `feat/`.

- **Example**: `feature/login-system` or `feat/payment-processing`.

### Bugfix Branches
Bugfix branches are used to fix bugs in the code. Use the prefix `bugfix/` or `fix/`.

- **Example**: `bugfix/header-styling` or `fix/form-validation`.

### Hotfix Branches
Hotfix branches are created directly from the production branch to fix critical bugs in the production environment. Use the prefix `hotfix/` or `hfix/`.

- **Example**: `hotfix/critical-security-issue` or `hfix/performance-patch`.

### Release Branches
Release branches are used to prepare for a new production release. They allow for last-minute adjustments and polishing. Use the prefix `release/`.

- **Example**: `release/v1.0.1`.

## How to Contribute

1. **Fork** the repository to your own GitHub account.
2. **Clone** the forked repository to your local machine.
3. **Create a new branch** for your changes using the branch naming guidelines above.
4. **Commit** your changes with clear and descriptive commit messages.
5. **Push** your changes to your fork.
6. **Create a pull request** (PR) with a detailed explanation of your changes and any relevant issues.

Please ensure that your pull request is up to date with the latest version of the `main` branch before submission.

## Code Review and Merging

After submitting your pull request, one of the maintainers will review your changes. You may be asked to make adjustments or provide further clarification. Once approved, your changes will be merged into the main repository.

Thank you for your contribution!

## Resources
- [License](https://www.gnu.org/licenses/agpl-3.0.html)
- [Style File](PW_Style.xml)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
wish. :)
* Click [here](https://github.com/TheNewEconomy/PhantomWorlds/wiki) to visit the Wiki.

## Contributing

Contributions to PhantomWorlds are welcome and encouraged! Whether you're fixing a bug, adding a new feature, or improving documentation, we would love your help.

However, to ensure the project stays consistent and manageable, we ask that you follow our [contributing guidelines](.contributing/contributing.md) before submitting a pull request.

Please make sure to:

- Sign the Contributor License Agreement (CLA) if this is your first contribution when it appears in the Pull Request.
- Follow the coding standards and branch naming conventions outlined in the guidelines.
- Use the required IntelliJ plugin **Final Obsession** for code quality and consistency.

Thank you for your contributions!

## Contributors

* Please see the [Credits](https://github.com/TheNewEconomy/PhantomWorlds/wiki/Credits) - thank you
Expand Down
69 changes: 42 additions & 27 deletions src/main/java/me/lokka30/phantomworlds/PhantomWorlds.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public class PhantomWorlds extends JavaPlugin {

public static final List<String> createTabs = new ArrayList<>();

/*
*TODO:
* - Translate backslash character in world names as a space so world names with a space can be used in the plugin
* - Vanish compatibility
* - don't send 'by' messages unless the sender is not a player / target can see the (player) sender
* - add vanish compatibility to 'teleport' subcommand
* - add ability to toggle vanish compatibility
* - log in console (LogLevel:INFO) when a command is prevented due to a target player seemingly being vanished to the command sender.
*/
/*
*TODO:
* - Translate backslash character in world names as a space so world names with a space can be used in the plugin
* - Vanish compatibility
* - don't send 'by' messages unless the sender is not a player / target can see the (player) sender
* - add vanish compatibility to 'teleport' subcommand
* - add ability to toggle vanish compatibility
* - log in console (LogLevel:INFO) when a command is prevented due to a target player seemingly being vanished to the command sender.
*/


private static PhantomWorlds instance;
Expand All @@ -82,7 +82,7 @@ public class PhantomWorlds extends JavaPlugin {
/**
* If you have contributed code to the plugin, add your name to the end of this list! :)
*/
public static final String[] CONTRIBUTORS = new String[]{"madison-allen"};
public static final String[] CONTRIBUTORS = new String[]{ "madison-allen" };

public static final List<String> COMMAND_HELP = new LinkedList<>();

Expand Down Expand Up @@ -111,13 +111,13 @@ public class PhantomWorlds extends JavaPlugin {
* Data/configuration files.
*/
public final YamlConfigFile settings = new YamlConfigFile(this,
new File(getDataFolder(), "settings.yml"));
new File(getDataFolder(), "settings.yml"));
public final YamlConfigFile advancedSettings = new YamlConfigFile(this,
new File(getDataFolder(), "advancedSettings.yml"));
new File(getDataFolder(), "advancedSettings.yml"));
public final YamlConfigFile messages = new YamlConfigFile(this,
new File(getDataFolder(), "messages.yml"));
new File(getDataFolder(), "messages.yml"));
public final YamlConfigFile data = new YamlConfigFile(this,
new File(getDataFolder(), "data.yml"));
new File(getDataFolder(), "data.yml"));

/*
Used to check if world are loaded
Expand All @@ -142,7 +142,7 @@ public void onEnable() {
}
createTabs.addAll(generateCreateSuggestions());

QuickTimer timer = new QuickTimer(TimeUnit.MILLISECONDS);
final QuickTimer timer = new QuickTimer(TimeUnit.MILLISECONDS);

final String bukkitVersion = Bukkit.getServer().getBukkitVersion();
if(Utils.isOneSeventeen(bukkitVersion)) {
Expand All @@ -166,6 +166,7 @@ public void onEnable() {
}

public boolean isWorldLoaded() {

return isWorldLoaded;
}

Expand All @@ -176,6 +177,7 @@ public boolean isWorldLoaded() {
*/
@Override
public void onDisable() {

final QuickTimer timer = new QuickTimer(TimeUnit.MILLISECONDS);

if(backupService != null) {
Expand All @@ -192,6 +194,7 @@ public void onDisable() {
* @since v2.0.0
*/
void checkCompatibility() {

getLogger().info("Checking compatibility with server...");

compatibilityChecker.checkAll();
Expand All @@ -201,7 +204,7 @@ void checkCompatibility() {
}

for(int i = 0; i < compatibilityChecker.incompatibilities.size(); i++) {
CompatibilityChecker.Incompatibility incompatibility = compatibilityChecker.incompatibilities.get(
final CompatibilityChecker.Incompatibility incompatibility = compatibilityChecker.incompatibilities.get(
i);
getLogger().warning(
"Incompatibility #" + (i + 1) + " (Type: " + incompatibility.type + "):");
Expand All @@ -217,6 +220,7 @@ void checkCompatibility() {
* @since v2.0.0
*/
public void loadFiles() {

getLogger().info("Checking for backup directory...");

final File backup = new File(getDataFolder(), BACKUP_FOLDER);
Expand All @@ -226,7 +230,7 @@ public void loadFiles() {

getLogger().info("Loading files...");

for(FileManager.PWFile pwFile : FileManager.PWFile.values()) {
for(final FileManager.PWFile pwFile : FileManager.PWFile.values()) {
fileManager.init(pwFile);
}
}
Expand All @@ -238,6 +242,7 @@ public void loadFiles() {
* @since v2.0.0
*/
public void loadWorlds() {

getLogger().info("Loading worlds...");
worldManager.loadManagedWorlds();
isWorldLoaded = true;
Expand All @@ -250,13 +255,14 @@ public void loadWorlds() {
* @since v2.0.0
*/
void registerCommands() {

getLogger().info("Registering commands...");

this.command = LiteBukkitFactory.builder()
.commands(new PWCommand())
.settings(settings -> settings
.nativePermissions(false)
)
.settings(settings->settings
.nativePermissions(false)
)
.invalidUsage(new PWInvalidUsageHandler())
.argument(GameMode.class, new GamemodeParameter())
.argument(PortalType.class, new PortalParameter())
Expand All @@ -273,6 +279,7 @@ void registerCommands() {
* @since v2.0.0
*/
void registerListeners() {

getLogger().info("Registering listeners...");
getServer().getPluginManager().registerEvents(new PlayerChangeWorldListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
Expand All @@ -289,6 +296,7 @@ void registerListeners() {
* @since v2.0.0
*/
void miscStartupProcedures() {

getLogger().info("Running misc startup procedures...");

/* bStats Metrics */
Expand All @@ -313,36 +321,41 @@ void miscStartupProcedures() {

messages.getConfig().getStringList("update-checker.console.text")
.forEach(message->getLogger().info(message
.replace("%currentVersion%",
updateCheckerResult.getCurrentVersion())
.replace("%latestVersion%", updateCheckerResult.getLatestVersion())
));
.replace("%currentVersion%",
updateCheckerResult.getCurrentVersion())
.replace("%latestVersion%", updateCheckerResult.getLatestVersion())
));
}
});
} catch(Exception ex) {
} catch(final Exception ex) {
getLogger().warning("Unable to check for updates - check your internet connection: "
+ ex.getMessage());
+ ex.getMessage());
}
}
}

public static PhantomWorlds instance() {

return instance;
}

public static Logger logger() {

return instance.getLogger();
}

public static WorldManager worldManager() {

return instance.worldManager;
}

public static VersionCompatibility compatibility() {

return compatibility;
}

private ArrayList<String> generateCreateSuggestions() {

final ArrayList<String> suggestions = new ArrayList<>();

suggestions.addAll(addTrueFalseValues("generatestructures"));
Expand Down Expand Up @@ -373,14 +386,15 @@ private ArrayList<String> generateCreateSuggestions() {

suggestions.add("seed:");

for(WorldType worldType : WorldType.values()) {
for(final WorldType worldType : WorldType.values()) {
suggestions.add("type:" + worldType.toString());
}

return suggestions;
}

private ArrayList<String> addTrueFalseValues(String option) {

final ArrayList<String> list = new ArrayList<>();
option = option + ":";

Expand All @@ -391,6 +405,7 @@ private ArrayList<String> addTrueFalseValues(String option) {
}

public FoliaLib folia() {

return folia;
}
}
Loading

0 comments on commit d571152

Please sign in to comment.