99import io .github .simplexdev .simplexcore .module .SimplexModule ;
1010import io .github .simplexdev .simplexcore .utils .TickedTime ;
1111import io .github .simplexdev .simplexcore .utils .Utilities ;
12+ import net .kyori .adventure .text .Component ;
1213import org .bukkit .command .CommandSender ;
1314import org .bukkit .configuration .ConfigurationSection ;
1415import org .bukkit .entity .Player ;
@@ -33,7 +34,7 @@ public abstract class Ban implements IBan {
3334 private final SimplexModule <?> plugin ;
3435
3536 private final String banId ;
36- private final String banReason ;
37+ private final Component banReason ;
3738
3839 /**
3940 * Creates a new Ban Entry.
@@ -79,7 +80,7 @@ public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType
7980 * @param banDate The date when the ban was created.
8081 * @param banDuration How long the ban should last.
8182 */
82- public Ban (SimplexModule <?> plugin , Player player , CommandSender sender , BanType type , String banId , String banReason , Date banDate , long banDuration ) {
83+ public Ban (SimplexModule <?> plugin , Player player , CommandSender sender , BanType type , String banId , Component banReason , Date banDate , long banDuration ) {
8384 this .plugin = plugin ;
8485 this .player = player ;
8586 this .sender = sender ;
@@ -92,18 +93,20 @@ public Ban(SimplexModule<?> plugin, Player player, CommandSender sender, BanType
9293
9394 /**
9495 * Writes the Ban to a file.
95- * @param separateFiles Whether or not to create individual files for players or store them all in one bans.yml file.
96+ * @param separateFiles Whether to create individual files for players or store
97+ * them all in one bans.yml file.
9698 */
9799 public void writeToFile (boolean separateFiles ) {
98100 File fileLocation = new File (plugin .getParentFolder (), "bans" );
99101
102+ Yaml yaml ;
100103 if (separateFiles ) {
101- Yaml yaml = new YamlFactory (plugin ).from (null , fileLocation , player .getName () + ".yml" );
104+ yaml = new YamlFactory (plugin ).from (null , fileLocation , player .getName () + ".yml" );
102105 ConfigurationSection section = yaml .getConfig ().createSection (getOffender ().toString ());
103106 section .set ("name" , player .getName ());
104107 section .set ("ban_id" , banId );
105108 section .set ("sender" , sender .getName ());
106- section .set ("reason" , banReason );
109+ section .set ("reason" , banReason . toString () );
107110 section .set ("duration" , banDuration );
108111 section .set ("date" , banDate .getTime ());
109112 section .set ("type" , type .toString ());
@@ -112,14 +115,13 @@ public void writeToFile(boolean separateFiles) {
112115 } catch (IOException e ) {
113116 plugin .getLogger ().severe (e .getMessage ());
114117 }
115- yaml .reload ();
116118 } else {
117- Yaml yaml = new YamlFactory (plugin ).from (null , fileLocation , "bans.yml" );
119+ yaml = new YamlFactory (plugin ).from (null , fileLocation , "bans.yml" );
118120 ConfigurationSection section = yaml .getConfig ().createSection (getOffender ().toString ());
119121 section .set ("name" , player .getName ());
120122 section .set ("ban_id" , banId );
121123 section .set ("sender" , sender .getName ());
122- section .set ("reason" , banReason );
124+ section .set ("reason" , banReason . toString () );
123125 section .set ("duration" , banDuration );
124126 section .set ("date" , banDate .getTime ());
125127 section .set ("type" , type .toString ());
@@ -128,7 +130,7 @@ public void writeToFile(boolean separateFiles) {
128130 } catch (IOException ex ) {
129131 plugin .getLogger ().severe (ex .getMessage ());
130132 }
131- yaml .reload ();
132133 }
134+ yaml .reload ();
133135 }
134136}
0 commit comments