From fdf7e396234980df8dcec26afaae6dddc8bf38c7 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Sat, 16 Apr 2022 16:53:29 -0500 Subject: [PATCH] Removed Compiler Files --- .gitignore | 6 + .gradle/7.3.3/checksums/checksums.lock | Bin 17 -> 0 bytes .gradle/7.3.3/checksums/md5-checksums.bin | Bin 18597 -> 0 bytes .gradle/7.3.3/checksums/sha1-checksums.bin | Bin 18659 -> 0 bytes .../dependencies-accessors.lock | Bin 17 -> 0 bytes .../dependencies-accessors/gc.properties | 0 .../executionHistory/executionHistory.bin | Bin 19540 -> 0 bytes .../executionHistory/executionHistory.lock | Bin 17 -> 0 bytes .gradle/7.3.3/fileChanges/last-build.bin | Bin 1 -> 0 bytes .gradle/7.3.3/fileHashes/fileHashes.bin | Bin 18697 -> 0 bytes .gradle/7.3.3/fileHashes/fileHashes.lock | Bin 17 -> 0 bytes .gradle/7.3.3/gc.properties | 0 .../buildOutputCleanup.lock | Bin 17 -> 0 bytes .gradle/buildOutputCleanup/cache.properties | 2 - .gradle/buildOutputCleanup/outputFiles.bin | Bin 18695 -> 0 bytes .gradle/file-system.probe | Bin 8 -> 0 bytes .gradle/vcs-1/gc.properties | 0 .idea/.gitignore | 3 - .idea/compiler.xml | 6 - .idea/gradle.xml | 17 --- .idea/inspectionProfiles/Project_Default.xml | 54 -------- .idea/jarRepositories.xml | 30 ----- .idea/misc.xml | 12 -- .idea/modules/Configurations.main.iml | 13 -- .idea/uiDesigner.xml | 124 ------------------ .idea/vcs.xml | 6 - Configurations.iml | 9 -- .../configurations/ConfigFactory.java | 4 +- .../simplexdev/configurations/Group.java | 31 ++++- .../simplexdev/configurations/Section.java | 24 +++- .../simplexdev/configurations/api/IGroup.java | 11 +- .../simplexdev/configurations/api/INode.java | 2 +- .../configurations/api/ISection.java | 8 +- .../api/{Serializable.java => Serialize.java} | 2 +- .../simplexdev/configurations/api/Yaml.java | 64 +++++++-- 35 files changed, 132 insertions(+), 296 deletions(-) delete mode 100644 .gradle/7.3.3/checksums/checksums.lock delete mode 100644 .gradle/7.3.3/checksums/md5-checksums.bin delete mode 100644 .gradle/7.3.3/checksums/sha1-checksums.bin delete mode 100644 .gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock delete mode 100644 .gradle/7.3.3/dependencies-accessors/gc.properties delete mode 100644 .gradle/7.3.3/executionHistory/executionHistory.bin delete mode 100644 .gradle/7.3.3/executionHistory/executionHistory.lock delete mode 100644 .gradle/7.3.3/fileChanges/last-build.bin delete mode 100644 .gradle/7.3.3/fileHashes/fileHashes.bin delete mode 100644 .gradle/7.3.3/fileHashes/fileHashes.lock delete mode 100644 .gradle/7.3.3/gc.properties delete mode 100644 .gradle/buildOutputCleanup/buildOutputCleanup.lock delete mode 100644 .gradle/buildOutputCleanup/cache.properties delete mode 100644 .gradle/buildOutputCleanup/outputFiles.bin delete mode 100644 .gradle/file-system.probe delete mode 100644 .gradle/vcs-1/gc.properties delete mode 100644 .idea/.gitignore delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules/Configurations.main.iml delete mode 100644 .idea/uiDesigner.xml delete mode 100644 .idea/vcs.xml delete mode 100644 Configurations.iml rename src/main/java/io/github/simplexdev/configurations/api/{Serializable.java => Serialize.java} (77%) diff --git a/.gitignore b/.gitignore index a1c2a23..7dc0dd2 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,11 @@ *.tar.gz *.rar +# Compiler Files # +build/ +.idea/ +.gradle/ +Configurations.iml + # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/.gradle/7.3.3/checksums/checksums.lock b/.gradle/7.3.3/checksums/checksums.lock deleted file mode 100644 index f083086fde958f90930ed681d98d0f55f636f315..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 UcmZS1Zf-GPpSAE60|ama04>M^+W-In diff --git a/.gradle/7.3.3/checksums/md5-checksums.bin b/.gradle/7.3.3/checksums/md5-checksums.bin deleted file mode 100644 index 9a738144ff6d7343c6f67454a580865e4aff8bb8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18597 zcmeI%Axncn7y#gNCPmnS;(`cEB8Uvlf&&$sAPBAqG8mW*!(uXspi#tTSW;vr!629g zv6~DU=Kh1;$L(YI2MqEY+`TXF@p5-hy_FEkrSJX-gE28kWdsNiAV7cs0RjXF5FkK+ z009C72oNAZfWUtd*oqGsO^+$h6|$t*3ZXg{lS2FDxY}D?>ZR@V{rvx6`)>T{=<0l` zU$5o$JjQx0?O6#BAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+0D-?0Sd53w##zZ`X=n0bbGq?y+THzZHP<>PAq*W}d_6Cu8x=b-&j0Rc eEMH$93^#A@N6u~@H)iTt$NO7*FLhL2vyLAE8$>$* diff --git a/.gradle/7.3.3/checksums/sha1-checksums.bin b/.gradle/7.3.3/checksums/sha1-checksums.bin deleted file mode 100644 index 57749d83f3d7db55742a33c9c237373b10b414ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18659 zcmeI%F-Sr|9LMpqCZl*E?~zax4GluU!-gOV5{zm{Xb=*I)@*AC&EXN%;8s&qo5KSM z48=7ETZ0ISLY&%yoEk!is5|aGB$`{|dvJGu{>Se-I59c1Q0*~ z0R#|0009ILKmY**5I_I{1Q0*~0R;YwKvG_$PhTcH*`o?0D}>!Ii(dD(V7C|N+xmF9 z?7ts0hn?O0N^{KX$Nc_!)odIVPe#0c*6;hf?5Fe@D*^~0fB*srAb nH&HKD`JFm0S1zts&+8AC`?*tlu}Vh^XDapFax*$Ley393IEG^0 diff --git a/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock deleted file mode 100644 index b0303396d41266079846e1d4e684bf26940651ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 TcmZR6Dtf3a$@5q*0~7!NG}Qz& diff --git a/.gradle/7.3.3/dependencies-accessors/gc.properties b/.gradle/7.3.3/dependencies-accessors/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/.gradle/7.3.3/executionHistory/executionHistory.bin b/.gradle/7.3.3/executionHistory/executionHistory.bin deleted file mode 100644 index 8ee3401f89c38d6597cc5c540568178ee5753661..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19540 zcmeI(Pe>F|90%~3-HA*R*MqRqDd-aAtnB&+MFMqAB`tB?lvtAI?9-Xmof+Sob+M~a zfno|`hoJIOheDx9BnYWXl!x*ZL3HR66x68>UhK`zE-G{o^APc!!<)yvncwgIKJPJ? zVWN^03~c2OY5OSO?xF_)2tWV=5P$##AOHafKmY;|fB*y_009U<00Izz!2co;7ljmi z#RO0L+)im$lB$l1j$EZ3>-Ux1zvB(JHx<4g6wc!MNpB1-1Rwwb2tWV=5P$##AOHaf zKmY;|fB*y_009U<00Izz00bZa0SG_<0uX=z1Rwwb2tWV=5P$##AOHafKmY>&f)>4{|jHNOY-dyFU(z3;d)nP`Gqf{lfp*n<* za5c+_ZBwT9dFO#B)htFFnhXRV$cfcQ#fO^?jm`7^OC|DOM<|*mOw)~V+DtetTH4Ee zPIMDTcW<9->uHL1whqK&tvv(n7rI&tvD_Q{Gx;(?NrO9l&TW}7m~jltJcwMo0{$W4 z!p?*-orG&@W0|zH>#^Pmn-;C?spja8>AR0zZSFWfyE8?cjr!Mg$FX@sD8wlnH#Eu% zYb#RZ7zzM9%MD7(^dNCGJ*F|kcI0O*4T-o2 z&l53{CZ?m4L`Ra6Zf2#Z=I}&|Weyp`8L?eN2%hjFW>pbF3QT>L%X)uqoIBDm*%;l} zdNTj=`KRxp^>XD#imb(q*kLY;gxp9wIBZ1{DaDeLP^26b zH{q~$l5&vC*1J*;9Cn%K?Rnmoc68JCU(fse`#=49dOp|J6vFV9b%{#(D=i%Y2q1s} z0tg_000IagfB*srAb@)fB*sr zAbic{A-Vok)MxzU>Tjjb7(H=_Tz)`&X^&)0H#nIqf$SlT&W?$?g{n$JZWhzish% zygBK4?eVSCi}Y@xQ+iSRV765C-cyg#UG15b)I#Fnz?FWdeWd?#WB55XBYjN!?0Nm( z@ylC>^i}P8Hzv{+KI4i20tg_000IagfB*srAb`)nI2Nn879XrP%OG - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 611e7c8..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 7ae5ed7..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index 8633eb9..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index d93202f..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/Configurations.main.iml b/.idea/modules/Configurations.main.iml deleted file mode 100644 index f5de878..0000000 --- a/.idea/modules/Configurations.main.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - PAPER - ADVENTURE - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Configurations.iml b/Configurations.iml deleted file mode 100644 index d6ebd48..0000000 --- a/Configurations.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/configurations/ConfigFactory.java b/src/main/java/io/github/simplexdev/configurations/ConfigFactory.java index b5084ce..97d37e5 100644 --- a/src/main/java/io/github/simplexdev/configurations/ConfigFactory.java +++ b/src/main/java/io/github/simplexdev/configurations/ConfigFactory.java @@ -4,8 +4,8 @@ import io.github.simplexdev.configurations.api.INode; import io.github.simplexdev.configurations.api.ISection; public class ConfigFactory { - public ISection createNewSection(String name) { - ISection section = new Section(name); + public Section createNewSection(String name) { + Section section = new Section(name); Configurations.availableSections.add(section); return section; } diff --git a/src/main/java/io/github/simplexdev/configurations/Group.java b/src/main/java/io/github/simplexdev/configurations/Group.java index 346c624..746c19b 100644 --- a/src/main/java/io/github/simplexdev/configurations/Group.java +++ b/src/main/java/io/github/simplexdev/configurations/Group.java @@ -45,7 +45,7 @@ public class Group implements IGroup { * @param name The name of this group. */ public Group(@NotNull IGroup group, @NotNull String name) { - this.section = group.getSection(); + this.section = group.getParentSection(); this.group = group; this.name = name; } @@ -103,6 +103,7 @@ public class Group implements IGroup { * @param name The name of the nested group * @return The nested group. */ + @Override public @Nullable IGroup getNestedGroup(String name) { for (IGroup nested : nestedGroups) { if (nested.getName().equalsIgnoreCase(name)) { @@ -112,6 +113,16 @@ public class Group implements IGroup { return null; } + @Override + public boolean hasNest() { + return nestedGroups.isEmpty(); + } + + @Override + public List getNest() { + return nestedGroups; + } + /** * Gets the parent section associated with this group. * This will get the parent section regardless of nesting because sections are singular. @@ -119,7 +130,7 @@ public class Group implements IGroup { * @return The parent section of this group. */ @Override - public @NotNull ISection getSection() { + public @NotNull ISection getParentSection() { return section; } @@ -154,11 +165,23 @@ public class Group implements IGroup { @Override public String serialize() { - return getName(); + // Will indent the group in relation to the amount of parent groups there are. + if (getParentGroup() != null) { + int x = 0; // Origin + IGroup parent = getParentGroup(); + while (parent.getParentGroup() != null) { + parent = parent.getParentGroup(); + x++; + } + x += 1; // Consider parent section as 0 + x *= 2; // Double indent + return getParentSection().indent(x) + getName() + ": "; + } + return getParentSection().indent(2) + getName() + ": "; // Parent section has no indentation and this is not a nested group. } @Override public IGroup deserialize(String serializedInput) { - return getSection().getGroup(serializedInput); + return getParentSection().getGroup(serializedInput); } } diff --git a/src/main/java/io/github/simplexdev/configurations/Section.java b/src/main/java/io/github/simplexdev/configurations/Section.java index 473537b..854151e 100644 --- a/src/main/java/io/github/simplexdev/configurations/Section.java +++ b/src/main/java/io/github/simplexdev/configurations/Section.java @@ -50,6 +50,12 @@ public class Section implements ISection { for (IGroup group : groupList) { if (group.getName().equalsIgnoreCase(name)) { return group; + } else if (group.hasNest()) { + for (IGroup nested : group.getNest()) { + if (nested.getName().equalsIgnoreCase(name)) { + return nested; + } + } } } return null; @@ -61,7 +67,7 @@ public class Section implements ISection { @Override public String serialize() { - return getName(); + return getName() + ": " + newLine(); } @Override @@ -73,4 +79,20 @@ public class Section implements ISection { } return null; } + + @Override + public String indent(int level) { + StringBuilder sb = new StringBuilder(); + int x = 0; + while (x < level) { + sb.append("\\ "); + x++; + } + return sb.toString(); + } + + @Override + public String newLine() { + return "\n"; + } } diff --git a/src/main/java/io/github/simplexdev/configurations/api/IGroup.java b/src/main/java/io/github/simplexdev/configurations/api/IGroup.java index 66f640a..8673f95 100644 --- a/src/main/java/io/github/simplexdev/configurations/api/IGroup.java +++ b/src/main/java/io/github/simplexdev/configurations/api/IGroup.java @@ -4,8 +4,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Collection; +import java.util.List; -public interface IGroup extends Serializable { +public interface IGroup extends Serialize { IGroup createNestedGroup(IGroup group, String name, INode... nodes); String getName(); @@ -19,6 +20,12 @@ public interface IGroup extends Serializable { @Nullable IGroup getParentGroup(); + @Nullable IGroup getNestedGroup(String name); + + boolean hasNest(); + + List getNest(); + /** * Gets the parent section associated to this group. * Groups cannot exist outside a parent section. @@ -27,7 +34,7 @@ public interface IGroup extends Serializable { * @return The parent section of this group. */ @NotNull - ISection getSection(); + ISection getParentSection(); /** * @return The nodes contained within this group. diff --git a/src/main/java/io/github/simplexdev/configurations/api/INode.java b/src/main/java/io/github/simplexdev/configurations/api/INode.java index d6ac004..d3b3996 100644 --- a/src/main/java/io/github/simplexdev/configurations/api/INode.java +++ b/src/main/java/io/github/simplexdev/configurations/api/INode.java @@ -1,6 +1,6 @@ package io.github.simplexdev.configurations.api; -public interface INode extends Serializable { +public interface INode extends Serialize { /** * @return The name of the configuration entry. */ diff --git a/src/main/java/io/github/simplexdev/configurations/api/ISection.java b/src/main/java/io/github/simplexdev/configurations/api/ISection.java index f6a614a..d155c29 100644 --- a/src/main/java/io/github/simplexdev/configurations/api/ISection.java +++ b/src/main/java/io/github/simplexdev/configurations/api/ISection.java @@ -4,7 +4,9 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface ISection extends Serializable { +import java.io.Serializable; + +public interface ISection extends Serializable, Serialize { @NotNull String getName(); @@ -16,4 +18,8 @@ public interface ISection extends Serializable { @Nullable IGroup getGroup(String name); + + String indent(int level); + + String newLine(); } diff --git a/src/main/java/io/github/simplexdev/configurations/api/Serializable.java b/src/main/java/io/github/simplexdev/configurations/api/Serialize.java similarity index 77% rename from src/main/java/io/github/simplexdev/configurations/api/Serializable.java rename to src/main/java/io/github/simplexdev/configurations/api/Serialize.java index 01dcd05..06d21ac 100644 --- a/src/main/java/io/github/simplexdev/configurations/api/Serializable.java +++ b/src/main/java/io/github/simplexdev/configurations/api/Serialize.java @@ -1,6 +1,6 @@ package io.github.simplexdev.configurations.api; -public interface Serializable { +public interface Serialize { String serialize(); T deserialize(String serializedInput); diff --git a/src/main/java/io/github/simplexdev/configurations/api/Yaml.java b/src/main/java/io/github/simplexdev/configurations/api/Yaml.java index d7d1cef..adda41c 100644 --- a/src/main/java/io/github/simplexdev/configurations/api/Yaml.java +++ b/src/main/java/io/github/simplexdev/configurations/api/Yaml.java @@ -1,39 +1,56 @@ package io.github.simplexdev.configurations.api; +import io.github.simplexdev.configurations.ConfigFactory; import io.github.simplexdev.configurations.Configurations; import io.github.simplexdev.configurations.Utils; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.function.Supplier; @SuppressWarnings("ALL") -public abstract class Yaml { +public abstract class Yaml extends org.yaml.snakeyaml.Yaml { private final Plugin plugin; private final File dataFolder; private final File configFile; private final Utils utils; + private final ConfigFactory factory; + private final String fileName; - private final Map> groupsPerSection = new HashMap<>(); - private final Map>> nodesPerGroup = new HashMap<>(); + private final Map> groupsInSection = new HashMap<>(); + private final Map>> nodesInGroup = new HashMap<>(); - public Yaml(Plugin plugin, String fileName, boolean copyResource) { + public Yaml(@NotNull Plugin plugin, @Nullable String subDirectory, @NotNull String fileName, @NotNull boolean copyResource) { + super(); this.plugin = plugin; this.utils = new Utils(); + this.factory = new ConfigFactory(); + this.fileName = fileName; File dataFolder = plugin.getDataFolder(); if (!dataFolder.exists()) dataFolder.mkdir(); + if (subDirectory != null) { + File subDir = new File(dataFolder, subDirectory); + } + this.dataFolder = dataFolder; File file = new File(dataFolder, fileName); - try { - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } } if (copyResource) { plugin.saveResource(fileName, true); @@ -41,6 +58,33 @@ public abstract class Yaml { this.configFile = file; } + public Yaml(Plugin plugin, String fileName) { + this(plugin, null, fileName, false); + } + + public Yaml(Plugin plugin) { + this(plugin, null, "config.yml", false); + } + + public Yaml(Plugin plugin, boolean copyResource) { + this(plugin, null, "config.yml", true); + } + + public void load() { + try { + super.load(new BufferedReader(new FileReader(configFile))); + } catch (IOException ex) { + plugin.getLogger().severe(ex.getMessage()); + } + } + + public void save(boolean saveResource) { + if (saveResource) { + plugin.saveResource(fileName, true); + } + } + + @Nullable public ISection getSection(String name) { for (ISection section : Configurations.availableSections) { if (section.getName().equalsIgnoreCase(name)) { @@ -49,4 +93,8 @@ public abstract class Yaml { } return null; } + + public final ConfigFactory getFactory() { + return factory; + } }