Skip to content

Commit

Permalink
Reformat project to editorconfig
Browse files Browse the repository at this point in the history
To ensure universal code format this commit creates a .editorconfig file
that mostly defines intellij formatting for the project.
  • Loading branch information
lynxplay committed Dec 21, 2020
1 parent aec5e57 commit 1a3c64d
Show file tree
Hide file tree
Showing 20 changed files with 238 additions and 94 deletions.
119 changes: 119 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4

[*.java]
# java docs
ij_java_doc_enable_formatting = true
ij_java_doc_add_blank_line_after_description = true
ij_java_doc_add_blank_line_after_param_comments = true
ij_java_doc_add_blank_line_after_return = true
ij_java_doc_add_p_tag_on_empty_lines = true
ij_java_doc_align_exception_comments = true
ij_java_doc_align_param_comments = true
ij_java_doc_indent_on_continuation = true
ij_java_doc_keep_empty_lines = true
ij_java_doc_param_description_on_new_line = false
ij_java_doc_preserve_line_breaks = true
ij_java_doc_use_throws_not_exception_tag = true
ij_java_doc_do_not_wrap_if_one_line = true
ij_java_wrap_comments = true
ij_java_wrap_long_lines = true
ij_java_insert_override_annotation = true

ij_java_blank_lines_after_class_header = 1
ij_java_blank_lines_before_class_end = 1
ij_java_packages_to_use_import_on_demand = 0
ij_java_names_count_to_use_import_on_demand = 0

ij_java_else_on_new_line = false

ij_java_class_brace_style = end_of_line
ij_java_block_brace_style = end_of_line
ij_java_lambda_brace_style = end_of_line
ij_java_method_brace_style = end_of_line

ij_java_space_after_closing_angle_bracket_in_type_argument = false
ij_java_space_after_colon = true
ij_java_space_after_comma = true
ij_java_space_after_comma_in_type_arguments = true
ij_java_space_after_for_semicolon = true
ij_java_space_after_quest = true
ij_java_space_after_type_cast = true
ij_java_space_before_annotation_array_initializer_left_brace = false
ij_java_space_before_annotation_parameter_list = false
ij_java_space_before_array_initializer_left_brace = false
ij_java_space_before_catch_keyword = true
ij_java_space_before_catch_left_brace = true
ij_java_space_before_catch_parentheses = true
ij_java_space_before_class_left_brace = true
ij_java_space_before_colon = true
ij_java_space_before_colon_in_foreach = true
ij_java_space_before_comma = false
ij_java_space_before_do_left_brace = true
ij_java_space_before_else_keyword = true
ij_java_space_before_else_left_brace = true
ij_java_space_before_finally_keyword = true
ij_java_space_before_finally_left_brace = true
ij_java_space_before_for_left_brace = true
ij_java_space_before_for_parentheses = true
ij_java_space_before_for_semicolon = false
ij_java_space_before_if_left_brace = true
ij_java_space_before_if_parentheses = true
ij_java_space_before_method_call_parentheses = false
ij_java_space_before_method_left_brace = true
ij_java_space_before_method_parentheses = false
ij_java_space_before_opening_angle_bracket_in_type_parameter = false
ij_java_space_before_quest = true
ij_java_space_before_switch_left_brace = true
ij_java_space_before_switch_parentheses = true
ij_java_space_before_synchronized_left_brace = true
ij_java_space_before_synchronized_parentheses = true
ij_java_space_before_try_left_brace = true
ij_java_space_before_try_parentheses = true
ij_java_space_before_type_parameter_list = false
ij_java_space_before_while_keyword = true
ij_java_space_before_while_left_brace = true
ij_java_space_before_while_parentheses = true
ij_java_space_inside_one_line_enum_braces = false
ij_java_space_within_empty_array_initializer_braces = false
ij_java_space_within_empty_method_call_parentheses = false
ij_java_space_within_empty_method_parentheses = false
ij_java_spaces_around_additive_operators = true
ij_java_spaces_around_assignment_operators = true
ij_java_spaces_around_bitwise_operators = true
ij_java_spaces_around_equality_operators = true
ij_java_spaces_around_lambda_arrow = true
ij_java_spaces_around_logical_operators = true
ij_java_spaces_around_method_ref_dbl_colon = false
ij_java_spaces_around_multiplicative_operators = true
ij_java_spaces_around_relational_operators = true
ij_java_spaces_around_shift_operators = true
ij_java_spaces_around_type_bounds_in_type_parameters = true
ij_java_spaces_around_unary_operator = false
ij_java_spaces_within_angle_brackets = false
ij_java_spaces_within_annotation_parentheses = false
ij_java_spaces_within_array_initializer_braces = false
ij_java_spaces_within_braces = false
ij_java_spaces_within_brackets = false
ij_java_spaces_within_cast_parentheses = false
ij_java_spaces_within_catch_parentheses = false
ij_java_spaces_within_for_parentheses = false
ij_java_spaces_within_if_parentheses = false
ij_java_spaces_within_method_call_parentheses = false
ij_java_spaces_within_method_parentheses = false
ij_java_spaces_within_parentheses = false
ij_java_spaces_within_switch_parentheses = false
ij_java_spaces_within_synchronized_parentheses = false
ij_java_spaces_within_try_parentheses = false
ij_java_spaces_within_while_parentheses = false

[{*.yml, *.yaml}]
indent_size = 2
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.lynxplay</groupId>
<artifactId>serena</artifactId>
<version>1.0.4-SNAPSHOT</version>
<version>1.0.5-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/lynxplay/serena/FixedScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface FixedScheduler {
/**
* Runs the task after x spigot ticks
*
* @param task the task to execute
* @param task the task to execute
* @param delay the delay in ticks
*/
void runTaskDelayed(Runnable task, long delay);
Expand Down
61 changes: 33 additions & 28 deletions src/main/java/dev/lynxplay/serena/Serena.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void onEnable() {

this.cooldownContainer = new HashedCooldownContainer();
this.playerPermissionChecker = new SimplePlayerPermissionChecker();
this.playerToggleRegistry = new PersistentPlayerToggleRegister(Bukkit::getPlayer, new NamespacedKey(this, "ToggleValue"));
this.playerToggleRegistry = new PersistentPlayerToggleRegister(Bukkit::getPlayer, new NamespacedKey(this,
"ToggleValue"));

this.fixedScheduler = (r, l) -> getServer().getScheduler().runTaskLater(this, r, l);

Expand All @@ -67,58 +68,60 @@ public void reload() {
LanguageConfiguration languageConfiguration = readConfig(languageConfigurationFactory, "language.yml");
PropertyConfiguration propertyConfiguration = readConfig(propertyConfigurationFactory, "properties.yml");

getLogger().info(String.format("player-pickup-cooldown %d seconds", propertyConfiguration.playerPickupCooldown().getSeconds()));
getLogger().info(String.format("player-pickup-cooldown %d seconds",
propertyConfiguration.playerPickupCooldown().getSeconds()));

HandlerList.unregisterAll(this);
registerListeners(this.cooldownContainer, languageConfiguration, this.playerToggleRegistry
, this.playerPermissionChecker, propertyConfiguration, fixedScheduler);
, this.playerPermissionChecker, propertyConfiguration, fixedScheduler);

registerCommands(this.playerToggleRegistry, languageConfiguration, this.playerPermissionChecker);
}

/**
* Registers the listeners this plugin uses
*
* @param cooldownContainer the cooldown container to pass
* @param cooldownContainer the cooldown container to pass
* @param languageConfiguration the languageConfiguration to use
* @param toggleRegistry the toggle registry to use
* @param permissionChecker the permission checker to use
* @param toggleRegistry the toggle registry to use
* @param permissionChecker the permission checker to use
* @param propertyConfiguration the propertyConfiguration to use
*/
private void registerListeners(CooldownContainer cooldownContainer
, LanguageConfiguration languageConfiguration
, PlayerToggleRegistry toggleRegistry
, PlayerPermissionChecker permissionChecker
, PropertyConfiguration propertyConfiguration
, FixedScheduler scheduler) {
, LanguageConfiguration languageConfiguration
, PlayerToggleRegistry toggleRegistry
, PlayerPermissionChecker permissionChecker
, PropertyConfiguration propertyConfiguration
, FixedScheduler scheduler) {

this.getServer().getPluginManager().registerEvents(new PlayerPickupListener(cooldownContainer
, languageConfiguration
, toggleRegistry
, permissionChecker
, propertyConfiguration
, Player::getDisplayName), this);
this.getServer().getPluginManager().registerEvents(new PlayerThrowListener(propertyConfiguration, scheduler), this);
, languageConfiguration
, toggleRegistry
, permissionChecker
, propertyConfiguration
, Player::getDisplayName), this);
this.getServer().getPluginManager().registerEvents(new PlayerThrowListener(propertyConfiguration, scheduler),
this);
this.getServer().getPluginManager().registerEvents(new PlayerConnectionListener(cooldownContainer), this);
}

/**
* Registers the commands this plugin uses
*
* @param playerToggleRegistry the toggle registry to use
* @param playerToggleRegistry the toggle registry to use
* @param languageConfiguration the languageConfiguration to use
* @param permissionChecker the the permission checker to use
* @param permissionChecker the the permission checker to use
*/
private void registerCommands(PlayerToggleRegistry playerToggleRegistry
, LanguageConfiguration languageConfiguration
, PlayerPermissionChecker permissionChecker) {
, LanguageConfiguration languageConfiguration
, PlayerPermissionChecker permissionChecker) {

Objects.requireNonNull(getCommand("serena")).setExecutor(new SerenaToggleCommand(playerToggleRegistry
, languageConfiguration
, permissionChecker));
, languageConfiguration
, permissionChecker));
Objects.requireNonNull(getCommand("serena-reload")).setExecutor(new SerenaReloadCommand(permissionChecker
, languageConfiguration
, this));
, languageConfiguration
, this));
}

/**
Expand All @@ -132,9 +135,9 @@ private void exportConfiguration() {
/**
* Reads a config from a relative path
*
* @param factory the factory to create the data instance from
* @param factory the factory to create the data instance from
* @param filePath the file path of the config
* @param <T> the type of the data instance
* @param <T> the type of the data instance
*
* @return the data instance
*
Expand All @@ -144,7 +147,9 @@ private <T> T readConfig(ConfigurationFactory<T> factory, String filePath) {
try (BufferedReader reader = Files.newBufferedReader(getDataFolder().toPath().resolve(filePath))) {
return factory.create(YamlConfiguration.loadConfiguration(reader));
} catch (IOException e) {
throw new RuntimeException(String.format("Could not read configuration file %s in plugin data-folder", filePath), e);
throw new RuntimeException(String.format("Could not read configuration file %s in plugin data-folder",
filePath), e);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.lynxplay.serena.commands;

import dev.lynxplay.serena.permission.PlayerPermissionChecker;
import dev.lynxplay.serena.Reloadable;
import dev.lynxplay.serena.configuration.language.LanguageConfiguration;
import dev.lynxplay.serena.permission.PlayerPermissionChecker;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -14,7 +14,8 @@ public class SerenaReloadCommand implements CommandExecutor {
private final LanguageConfiguration languageConfiguration;
private final Reloadable reloadable;

public SerenaReloadCommand(PlayerPermissionChecker permissionChecker, LanguageConfiguration languageConfiguration, Reloadable reloadable) {
public SerenaReloadCommand(PlayerPermissionChecker permissionChecker, LanguageConfiguration languageConfiguration
, Reloadable reloadable) {
this.permissionChecker = permissionChecker;
this.languageConfiguration = languageConfiguration;
this.reloadable = reloadable;
Expand All @@ -26,10 +27,10 @@ public SerenaReloadCommand(PlayerPermissionChecker permissionChecker, LanguageCo
* If false is returned, then the "usage" plugin.yml entry for this command (if defined) will be sent to the
* player.
*
* @param sender Source of the command
* @param sender Source of the command
* @param command Command which was executed
* @param label Alias of the command which was used
* @param args Passed command arguments
* @param label Alias of the command which was used
* @param args Passed command arguments
*
* @return true if a valid command, otherwise false
*/
Expand All @@ -50,4 +51,5 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
player.sendMessage(this.languageConfiguration.reloadComplete());
return true;
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.lynxplay.serena.commands;

import dev.lynxplay.serena.configuration.language.LanguageConfiguration;
import dev.lynxplay.serena.permission.PlayerPermissionChecker;
import dev.lynxplay.serena.player.PlayerToggleRegistry;
import dev.lynxplay.serena.configuration.language.LanguageConfiguration;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -15,8 +15,8 @@ public class SerenaToggleCommand implements CommandExecutor {
private final PlayerPermissionChecker permissionChecker;

public SerenaToggleCommand(PlayerToggleRegistry playerToggleRegistry
, LanguageConfiguration languageConfiguration
, PlayerPermissionChecker permissionChecker) {
, LanguageConfiguration languageConfiguration
, PlayerPermissionChecker permissionChecker) {
this.playerToggleRegistry = playerToggleRegistry;
this.languageConfiguration = languageConfiguration;
this.permissionChecker = permissionChecker;
Expand All @@ -28,10 +28,10 @@ public SerenaToggleCommand(PlayerToggleRegistry playerToggleRegistry
* If false is returned, then the "usage" plugin.yml entry for this command (if defined) will be sent to the
* player.
*
* @param sender Source of the command
* @param sender Source of the command
* @param command Command which was executed
* @param label Alias of the command which was used
* @param args Passed command arguments
* @param label Alias of the command which was used
* @param args Passed command arguments
*
* @return true if a valid command, otherwise false
*/
Expand All @@ -49,8 +49,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

player.sendMessage(this.playerToggleRegistry.toggle(player.getUniqueId())
? this.languageConfiguration.pickupEnabled()
: this.languageConfiguration.pickupDisabled());
? this.languageConfiguration.pickupEnabled()
: this.languageConfiguration.pickupDisabled());
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public class ImmutableLanguageConfiguration implements LanguageConfiguration {
private final String reloadComplete;

ImmutableLanguageConfiguration(String prefix
, String playerPickupCooldown
, String pickupDisabled
, String pickupEnabled
, String permissionMissing
, String playerCannotBePickedUp, String reloadComplete) {
, String playerPickupCooldown
, String pickupDisabled
, String pickupEnabled
, String permissionMissing
, String playerCannotBePickedUp, String reloadComplete) {
this.prefix = prefix;
this.playerPickupCooldown = playerPickupCooldown;
this.pickupDisabled = pickupDisabled;
Expand Down Expand Up @@ -102,4 +102,5 @@ public String permissionMissing() {
public String reloadComplete() {
return prefix() + this.reloadComplete;
}

}
Loading

0 comments on commit 1a3c64d

Please sign in to comment.