22
22
23
23
import com .google .inject .Inject ;
24
24
import io .github .poqdavid .nyx .nyxcore .Permissions .BackpackPermission ;
25
+ import io .github .poqdavid .nyx .nyxcore .Permissions .MarketPermission ;
25
26
import io .github .poqdavid .nyx .nyxcore .Permissions .ToolsPermission ;
26
27
import io .github .poqdavid .nyx .nyxcore .Utils .CText ;
27
28
import io .github .poqdavid .nyx .nyxcore .Utils .NCLogger ;
28
- import io .github .poqdavid .nyx .nyxcore .Utils .Setting .NyxTools .Settings ;
29
+ import io .github .poqdavid .nyx .nyxcore .Utils .Setting .NyxMarket .NMSettings ;
30
+ import io .github .poqdavid .nyx .nyxcore .Utils .Setting .NyxTools .NTSettings ;
29
31
import org .bstats .sponge .Metrics ;
30
32
import org .slf4j .Logger ;
31
33
import org .spongepowered .api .Game ;
48
50
import java .nio .file .Paths ;
49
51
import java .util .Optional ;
50
52
51
- @ Plugin (id = PluginData . id , name = PluginData . name , version = PluginData . version , description = PluginData . description , url = PluginData . url , authors = {PluginData . author1 })
53
+ @ Plugin (id = "nyxcore" , name = "@ name@" , version = "@ version@" , description = "@ description@" , url = "https://github.com/poqdavid/NyxCore" , authors = {"@authors@" })
52
54
public class NyxCore {
53
55
54
56
public static NyxCore nyxcore ;
@@ -58,33 +60,40 @@ public class NyxCore {
58
60
private final Path backpackDir ;
59
61
private final Path toolsDir ;
60
62
private final Path backpacksDir ;
63
+ private final Path effectDir ;
64
+ private final Path marketDir ;
61
65
private final PluginContainer pluginContainer ;
62
66
private final Metrics metrics ;
63
67
public NCLogger logger ;
64
68
public PermissionService permService ;
65
69
public PermissionDescription .Builder permDescBuilder ;
66
70
public Path recordsDir ;
67
- public Settings nytSettings ;
71
+ public NTSettings nytSettings ;
72
+ public NMSettings nmSettings ;
68
73
@ Inject
69
74
private Game game ;
70
75
private CommandManager cmdManager ;
71
76
72
77
@ Inject
73
78
public NyxCore (Metrics .Factory metricsFactory , @ ConfigDir (sharedRoot = true ) Path path , Logger logger , PluginContainer container ) {
74
79
nyxcore = this ;
75
- this .dataDir = Sponge .getGame ().getSavesDirectory ().resolve (PluginData .id );
76
80
this .pluginContainer = container ;
81
+
82
+ this .dataDir = Sponge .getGame ().getSavesDirectory ().resolve (this .getPluginContainer ().getId ());
83
+
77
84
this .logger = new NCLogger ();
78
- this .nytSettings = new Settings ();
79
- this .configDirPath = path .resolve (PluginData .shortName );
85
+ this .nytSettings = new NTSettings ();
86
+ this .nmSettings = new NMSettings ();
87
+ this .configDirPath = path .resolve ("Nyx" );
80
88
this .configFullPath = Paths .get (this .getConfigPath ().toString (), "config.json" );
81
89
this .backpackDir = Paths .get (this .getConfigPath ().toString (), "NyxBackpack" );
82
90
this .toolsDir = Paths .get (this .getConfigPath ().toString (), "NyxTools" );
83
91
this .backpacksDir = Paths .get (this .backpackDir .toString (), "backpacks" );
84
-
92
+ this .effectDir = Paths .get (this .getConfigPath ().toString (), "NyxEffect" );
93
+ this .marketDir = Paths .get (this .getConfigPath ().toString (), "NyxMarket" );
85
94
86
95
this .logger .info (" " );
87
- this .logger .info (CText .get (CText .Colors .MAGENTA , 0 , "NyxCore " ) + CText .get (CText .Colors .YELLOW , 0 , " v" + PluginData . version ));
96
+ this .logger .info (CText .get (CText .Colors .MAGENTA , 0 , "@name@ " ) + CText .get (CText .Colors .YELLOW , 0 , " v" + this . getVersion () ));
88
97
this .logger .info ("Starting..." );
89
98
this .logger .info (" " );
90
99
@@ -117,21 +126,40 @@ public Path getBackpacksPath() {
117
126
return this .backpacksDir ;
118
127
}
119
128
129
+ @ Nonnull
130
+ public Path getEffectPath () {
131
+ return this .effectDir ;
132
+ }
133
+
134
+ @ Nonnull
135
+ public Path getMarketPath () {
136
+ return this .marketDir ;
137
+ }
138
+
120
139
@ Nonnull
121
140
public PluginContainer getPluginContainer () {
122
141
return this .pluginContainer ;
123
142
}
124
143
125
144
@ Nonnull
126
145
public String getVersion () {
127
- return PluginData .version ;
146
+ if (this .getPluginContainer ().getVersion ().isPresent ()) {
147
+ return this .getPluginContainer ().getVersion ().get ();
148
+ } else {
149
+ return "@version@" ;
150
+ }
128
151
}
129
152
130
153
@ Nonnull
131
- public Settings getToolsSettings () {
154
+ public NTSettings getToolsSettings () {
132
155
return this .nytSettings ;
133
156
}
134
157
158
+ @ Nonnull
159
+ public NMSettings getMarketSettings () {
160
+ return this .nmSettings ;
161
+ }
162
+
135
163
@ Nonnull
136
164
public NCLogger getLogger (String name ) {
137
165
if (name == null || name .isEmpty ()) {
@@ -154,7 +182,7 @@ public void setGame(Game game) {
154
182
@ Listener
155
183
public void onGamePreInit (@ Nullable final GamePreInitializationEvent event ) {
156
184
this .logger .info (" " );
157
- this .logger .info (CText .get (CText .Colors .MAGENTA , 0 , "NyxCore " ) + CText .get (CText .Colors .YELLOW , 0 , " v" + PluginData . version ));
185
+ this .logger .info (CText .get (CText .Colors .MAGENTA , 0 , "@name@ " ) + CText .get (CText .Colors .YELLOW , 0 , " v" + this . getVersion () ));
158
186
this .logger .info ("Initializing..." );
159
187
this .logger .info (" " );
160
188
nyxcore = this ;
@@ -415,6 +443,93 @@ public void onGameInit(@Nullable final GameInitializationEvent event) {
415
443
.assign (PermissionDescription .ROLE_STAFF , true )
416
444
.assign (PermissionDescription .ROLE_ADMIN , true )
417
445
.register ();
446
+
447
+ //Market
448
+ this .permDescBuilder
449
+ .id (MarketPermission .COMMAND_HELP )
450
+ .description (Text .of ("Allows the use of help command" ))
451
+ .assign (PermissionDescription .ROLE_USER , true )
452
+ .assign (PermissionDescription .ROLE_STAFF , true )
453
+ .assign (PermissionDescription .ROLE_ADMIN , true )
454
+ .register ();
455
+ this .permDescBuilder
456
+ .id (MarketPermission .COMMAND_MAIN )
457
+ .description (Text .of ("Allows the use of /sm, /NyxMarket" ))
458
+ .assign (PermissionDescription .ROLE_USER , true )
459
+ .assign (PermissionDescription .ROLE_STAFF , true )
460
+ .assign (PermissionDescription .ROLE_ADMIN , true )
461
+ .register ();
462
+ this .permDescBuilder
463
+ .id (MarketPermission .COMMAND_SELL )
464
+ .description (Text .of ("Allows the use of /market sell" ))
465
+ .assign (PermissionDescription .ROLE_USER , true )
466
+ .assign (PermissionDescription .ROLE_STAFF , true )
467
+ .assign (PermissionDescription .ROLE_ADMIN , true )
468
+ .register ();
469
+ this .permDescBuilder
470
+ .id (MarketPermission .COMMAND_BUY )
471
+ .description (Text .of ("Allows the use of /market buy" ))
472
+ .assign (PermissionDescription .ROLE_USER , true )
473
+ .assign (PermissionDescription .ROLE_STAFF , true )
474
+ .assign (PermissionDescription .ROLE_ADMIN , true )
475
+ .register ();
476
+ this .permDescBuilder
477
+ .id (MarketPermission .COMMAND_HISTORY )
478
+ .description (Text .of ("Allows the use of /market history" ))
479
+ .assign (PermissionDescription .ROLE_USER , false )
480
+ .assign (PermissionDescription .ROLE_STAFF , true )
481
+ .assign (PermissionDescription .ROLE_ADMIN , true )
482
+ .register ();
483
+ this .permDescBuilder
484
+ .id (MarketPermission .COMMAND_MAIL )
485
+ .description (Text .of ("Allows the use of /market mail" ))
486
+ .assign (PermissionDescription .ROLE_USER , true )
487
+ .assign (PermissionDescription .ROLE_STAFF , true )
488
+ .assign (PermissionDescription .ROLE_ADMIN , true )
489
+ .register ();
490
+ this .permDescBuilder
491
+ .id (MarketPermission .COMMAND_PRICECHECK )
492
+ .description (Text .of ("Allows the use of /market price" ))
493
+ .assign (PermissionDescription .ROLE_USER , true )
494
+ .assign (PermissionDescription .ROLE_STAFF , true )
495
+ .assign (PermissionDescription .ROLE_ADMIN , true )
496
+ .register ();
497
+ this .permDescBuilder
498
+ .id (MarketPermission .COMMAND_PRICELIMIT )
499
+ .description (Text .of ("Allows the use of /market pricelimit" ))
500
+ .assign (PermissionDescription .ROLE_USER , false )
501
+ .assign (PermissionDescription .ROLE_STAFF , false )
502
+ .assign (PermissionDescription .ROLE_ADMIN , true )
503
+ .register ();
504
+ this .permDescBuilder
505
+ .id (MarketPermission .COMMAND_RELOAD )
506
+ .description (Text .of ("Allows the use of /market reload" ))
507
+ .assign (PermissionDescription .ROLE_USER , false )
508
+ .assign (PermissionDescription .ROLE_STAFF , false )
509
+ .assign (PermissionDescription .ROLE_ADMIN , true )
510
+ .register ();
511
+ this .permDescBuilder
512
+ .id (MarketPermission .COMMAND_SEND )
513
+ .description (Text .of ("Allows the use of /market send" ))
514
+ .assign (PermissionDescription .ROLE_USER , true )
515
+ .assign (PermissionDescription .ROLE_STAFF , true )
516
+ .assign (PermissionDescription .ROLE_ADMIN , true )
517
+ .register ();
518
+
519
+ this .permDescBuilder
520
+ .id (MarketPermission .ADMIN_CANCEL )
521
+ .description (Text .of ("Allows the the admin to cancel market items" ))
522
+ .assign (PermissionDescription .ROLE_USER , false )
523
+ .assign (PermissionDescription .ROLE_STAFF , false )
524
+ .assign (PermissionDescription .ROLE_ADMIN , true )
525
+ .register ();
526
+ this .permDescBuilder
527
+ .id (MarketPermission .COMMAND_SETTING )
528
+ .description (Text .of ("Allows the the admin to change settings" ))
529
+ .assign (PermissionDescription .ROLE_USER , false )
530
+ .assign (PermissionDescription .ROLE_STAFF , false )
531
+ .assign (PermissionDescription .ROLE_ADMIN , true )
532
+ .register ();
418
533
}
419
534
420
535
this .logger .info ("Plugin Initialized successfully!" );
0 commit comments