Skip to content

Commit c7b75c8

Browse files
Reformating the code
1 parent dc3588b commit c7b75c8

File tree

19 files changed

+160
-170
lines changed

19 files changed

+160
-170
lines changed

src/main/java/de/redstoneworld/redutilities/entity/EntityHelper.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,60 @@ public class EntityHelper {
1515

1616
/**
1717
* This method returns a list of EntityTypes based on the Set of input strings.
18-
*
18+
*
1919
* @param inputSet (Set of Strings) the input String
2020
* @return (Set of EntityTypes) the resulted EntityTypes
2121
*/
2222
public static Set<EntityType> getEntityTypes(Set<String> inputSet) {
2323
if ((inputSet == null) || (inputSet.isEmpty())) return null;
24-
24+
2525
Set<EntityType> entities = EnumSet.noneOf(EntityType.class);
26-
26+
2727
for (String input : inputSet.stream().toList()) {
2828
entities.addAll(getEntityTypes(input));
2929
}
30-
30+
3131
return entities;
3232
}
33-
33+
3434
/**
35-
* This method returns a list of EntityTypes based on the input string. Various formats
35+
* This method returns a list of EntityTypes based on the input string. Various formats
3636
* of specifications are supported here:
37-
*
37+
*
3838
* <ul>
39-
* <li>EntityType-Tag starting with "#" or "tag=" - see <a href="https://minecraft.wiki/w/Tag#Entity_type_tags_2">Minecraft-Wiki</a>
40-
* <i>(Vanilla Minecraft implementation)</i> and <a href="https://jd.papermc.io/paper/1.21.1/org/bukkit/Tag.html">PaperMC Java-Doc</a>
39+
* <li>EntityType-Tag starting with "#" or "tag=" - see <a href="https://minecraft.wiki/w/Tag#Entity_type_tags_2">Minecraft-Wiki</a>
40+
* <i>(Vanilla Minecraft implementation)</i> and <a href="https://jd.papermc.io/paper/1.21.1/org/bukkit/Tag.html">PaperMC Java-Doc</a>
4141
* <i>(Bukkit implementation)</i> for the EntityType-Tag lists</li>
4242
* <li>Regex via "r="</li>
4343
* <li>clean ENTITY-TYPE names with wildcards via "*"</li>
4444
* <li>clean ENTITY-TYPE names</li>
4545
* </ul>
46-
*
47-
* <b>Note:</b> Currently, the expanding <a href="https://jd.papermc.io/paper/1.21.1/io/papermc/paper/tag/EntityTags.html">EntitySetTags</a>
46+
*
47+
* <b>Note:</b> Currently, the expanding <a href="https://jd.papermc.io/paper/1.21.1/io/papermc/paper/tag/EntityTags.html">EntitySetTags</a>
4848
* from PaperMC are not supported here.
49-
*
49+
*
5050
* <br/><br/>
5151
* Basic-Design by <a href="https://github.com/Phoenix616">Phoenix616</a>
52-
*
52+
*
5353
* @param input (String) the input String
5454
* @return (Set of EntityTypes) the resulted EntityTypes
5555
*/
5656
public static Set<EntityType> getEntityTypes(String input) {
5757
if ((input == null) || (input.isEmpty())) return null;
58-
58+
5959
Set<EntityType> entities = EnumSet.noneOf(EntityType.class);
60-
60+
6161
// EntityType-Tag Definition:
6262
if ((input.startsWith("#")) || (input.startsWith("tag="))) {
6363
String nameSpace = "";
6464
String tagName = "";
65-
65+
6666
if (input.startsWith("#")) {
6767
tagName = input.substring(1).toLowerCase();
6868
} else if (input.startsWith("tag=")) {
6969
tagName = input.substring(4).toLowerCase();
7070
}
71-
71+
7272
String[] parts = tagName.split(":");
7373
if (parts.length == 1) {
7474
nameSpace = NamespacedKey.MINECRAFT;
@@ -77,12 +77,12 @@ public static Set<EntityType> getEntityTypes(String input) {
7777
nameSpace = parts[0].toLowerCase();
7878
tagName = parts[1].toLowerCase();
7979
}
80-
80+
8181
Tag<EntityType> tag;
82-
82+
8383
// EntityTypes:
8484
tag = Bukkit.getTag(Tag.REGISTRY_ENTITY_TYPES, new NamespacedKey(nameSpace, tagName), EntityType.class);
85-
85+
8686
if (tag == null) {
8787
try {
8888
Field field = EntityTags.class.getField(tagName);
@@ -95,24 +95,24 @@ public static Set<EntityType> getEntityTypes(String input) {
9595
if (tag != null) {
9696
entities.addAll(tag.getValues());
9797
}
98-
98+
9999
// Regex Definition:
100100
} else if (input.startsWith("r=") || input.contains("*")) {
101101
Pattern p = Pattern.compile(input.startsWith("r=") ? input.substring(2) : input.replace("*", "(.*)"));
102-
102+
103103
for (EntityType entity : EntityType.values()) {
104104
if (p.matcher(entity.name()).matches()) {
105105
entities.add(entity);
106106
}
107107
}
108-
108+
109109
// clean EntityType-Name Definition:
110110
} else {
111111
entities.add(EntityType.valueOf(input.toUpperCase()));
112-
112+
113113
}
114-
114+
115115
return entities;
116116
}
117-
117+
118118
}

src/main/java/de/redstoneworld/redutilities/files/FileManager.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class FileManager {
1111

1212
private final File baseDir;
1313
private Logger logger;
14-
14+
1515
public FileManager(File baseDir) {
1616
this.baseDir = baseDir;
1717
}
@@ -37,25 +37,25 @@ public File createFolder(File dir, String newFolderName) {
3737
public File copyDefaultFile(InputStream pluginResource, String resourceFileName) {
3838
return copyDefaultFile(pluginResource, baseDir, resourceFileName);
3939
}
40-
40+
4141
public File copyDefaultFile(InputStream pluginResource, File dir, String resourceFileName) {
4242

4343
File file = new File(dir, resourceFileName);
44-
44+
4545
try {
4646

4747
// Create default file if it doesn't exist
4848
if (!file.exists()) {
4949
logger.log(Level.INFO, "Creating the default file: '" + resourceFileName + "'");
50-
50+
5151
FileOutputStream outputStream = new FileOutputStream(file);
5252
pluginResource.transferTo(outputStream);
5353
}
5454

5555
} catch (IOException e) {
5656
e.printStackTrace();
5757
}
58-
58+
5959
return file;
6060
}
6161

@@ -64,13 +64,13 @@ public String getFileContent(String fileName) {
6464
}
6565

6666
public String getFileContent(File dir, String fileName) {
67-
67+
6868
File file = new File(dir, fileName);
6969
return getFileContent(file);
7070
}
71-
71+
7272
public String getFileContent(File file) {
73-
73+
7474
String content = "";
7575

7676
try {
@@ -88,23 +88,23 @@ public String getFileContent(File file) {
8888
public File saveNewFile(String newFileName, String content) {
8989
return saveNewFile(baseDir, newFileName, content);
9090
}
91-
91+
9292
public File saveNewFile(File dir, String newFileName, String content) {
93-
93+
9494
File newFile = new File(dir, newFileName);
9595

9696
try {
9797
if (!newFile.exists()) {
9898
logger.log(Level.INFO, "Creating the file: '" + newFileName + "'");
99-
99+
100100
FileOutputStream outputStream = new FileOutputStream(newFile);
101101
if (!content.isBlank()) outputStream.write(content.getBytes());
102102
}
103103

104104
} catch (IOException e) {
105105
e.printStackTrace();
106106
}
107-
107+
108108
return newFile;
109109
}
110110

@@ -115,5 +115,5 @@ public void setLogger(Logger logger) {
115115
public Logger getLogger() {
116116
return logger;
117117
}
118-
118+
119119
}

src/main/java/de/redstoneworld/redutilities/files/bukkit/FileReader.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import org.bukkit.configuration.Configuration;
55

66
public class FileReader {
7-
7+
88
Configuration configuration;
9-
9+
1010
// Configuration sections following the standard structure of the RedstoneWorld plugins.
1111
private String configPartMessages = "messages";
1212
private String configPartFeatures = "features";
13-
13+
1414
public void setConfig(Configuration configuration) {
1515
this.configuration = configuration;
1616
}
@@ -21,7 +21,7 @@ public Configuration getConfiguration() {
2121

2222
/**
2323
* This method sets the configuration part for messages.
24-
*
24+
*
2525
* @param configPartMessages (String) config part
2626
*/
2727
public void setConfigPartMessages(String configPartMessages) {
@@ -51,7 +51,6 @@ private String getConfigPartFeatures() {
5151
*
5252
* @param key YAML key
5353
* @param args placeholder without "%" and value for the placeholder
54-
*
5554
* @return the config messages (String)
5655
*/
5756
public String getLang(String key, String... args) {
@@ -65,7 +64,6 @@ public String getLang(String key, String... args) {
6564
* @param key YAML key
6665
* @param colorCodeReplace should the native color-code identifier "§" be replaced with "&amp;"
6766
* @param args placeholder without "%" and value for the placeholder
68-
*
6967
* @return the config messages (String)
7068
*/
7169
public String getLang(Boolean colorCodeReplace, String key, String... args) {
@@ -90,5 +88,5 @@ public int getIntOption(String key) {
9088
public String getStringOption(String key) {
9189
return configuration.getString(configPartFeatures + "." + key);
9290
}
93-
91+
9492
}

src/main/java/de/redstoneworld/redutilities/files/bungee/ConfigHandler.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,36 @@ public class ConfigHandler {
1818
private Configuration config;
1919
private final Plugin plugin;
2020
private File configFile;
21-
21+
2222
public ConfigHandler(Plugin plugin) {
2323
instance = this;
24-
24+
2525
this.plugin = plugin;
2626
load("config.yml");
2727
}
2828

2929
public ConfigHandler(Plugin plugin, String fileName) {
3030
instance = this;
31-
31+
3232
this.plugin = plugin;
3333
load(fileName);
3434
}
3535

3636
private void load(String fileName) {
3737
configFile = new File(plugin.getDataFolder(), fileName);
38-
38+
3939
try {
4040
// Create Data folder
4141
if (!plugin.getDataFolder().exists()) {
4242
plugin.getLogger().log(Level.INFO, "Creating the plugin folder");
43-
43+
4444
plugin.getDataFolder().mkdirs();
4545
}
4646

4747
// Copy default config if it doesn't exist
4848
if (!configFile.exists()) {
4949
plugin.getLogger().log(Level.INFO, "Copy default file: " + fileName);
50-
50+
5151
FileOutputStream outputStream = new FileOutputStream(configFile);
5252
InputStream in = plugin.getResourceAsStream(fileName);
5353
in.transferTo(outputStream);
@@ -56,7 +56,7 @@ private void load(String fileName) {
5656
// Load config
5757
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
5858
plugin.getLogger().log(Level.INFO, "Loaded file: " + fileName);
59-
59+
6060
} catch (IOException e) {
6161
e.printStackTrace();
6262
}
@@ -65,7 +65,7 @@ private void load(String fileName) {
6565
public void saveConfig() {
6666
String fileName = configFile.getName();
6767
plugin.getLogger().log(Level.INFO, "Saving file: " + fileName);
68-
68+
6969
try {
7070
ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, configFile);
7171
} catch (IOException e) {
@@ -76,7 +76,7 @@ public void saveConfig() {
7676
public void reloadConfig() {
7777
String fileName = configFile.getName();
7878
plugin.getLogger().log(Level.INFO, "Reloading file: " + fileName);
79-
79+
8080
load(configFile.getName());
8181
}
8282

src/main/java/de/redstoneworld/redutilities/files/bungee/FileReader.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import net.md_5.bungee.config.Configuration;
55

66
public class FileReader {
7-
7+
88
Configuration configuration;
9-
9+
1010
// Configuration sections following the standard structure of the RedstoneWorld plugins.
1111
private String configPartMessages = "messages";
1212
private String configPartFeatures = "features";
13-
13+
1414
public void setConfig(Configuration configuration) {
1515
this.configuration = configuration;
1616
}
@@ -21,7 +21,7 @@ public Configuration getConfiguration() {
2121

2222
/**
2323
* This method sets the configuration part for messages.
24-
*
24+
*
2525
* @param configPartMessages (String) config part
2626
*/
2727
public void setConfigPartMessages(String configPartMessages) {
@@ -51,7 +51,6 @@ private String getConfigPartFeatures() {
5151
*
5252
* @param key YAML key
5353
* @param args placeholder without "%" and value for the placeholder
54-
*
5554
* @return the config messages (String)
5655
*/
5756
public String getLang(String key, String... args) {
@@ -65,15 +64,14 @@ public String getLang(String key, String... args) {
6564
* @param key YAML key
6665
* @param colorCodeReplace should the native color-code identifier "§" be replaced with "&amp;"
6766
* @param args placeholder without "%" and value for the placeholder
68-
*
6967
* @return the config messages (String)
7068
*/
7169
public String getLang(Boolean colorCodeReplace, String key, String... args) {
7270
String lang = configuration.getString(configPartMessages + "." + key, "&cUnknown language key &6" + key);
7371
for (int i = 0; i + 1 < args.length; i += 2) {
7472
lang = lang.replace("%" + args[i] + "%", args[i + 1]);
7573
}
76-
74+
7775
if (colorCodeReplace) return ChatColor.translateAlternateColorCodes('&', lang);
7876

7977
return lang;
@@ -90,5 +88,5 @@ public int getIntOption(String key) {
9088
public String getStringOption(String key) {
9189
return configuration.getString(configPartFeatures + "." + key);
9290
}
93-
91+
9492
}

0 commit comments

Comments
 (0)