File tree Expand file tree Collapse file tree 4 files changed +44
-1
lines changed
common/src/main/java/com/funniray/minimap/common Expand file tree Collapse file tree 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ public void sendSettings(MinimapPlayer player) {
2626 config = worldConfig ;
2727 }
2828
29- String configJson = new Gson ().toJson (config );
29+ String configJson = new Gson ().toJson (config . applyOverrides ( player ) );
3030
3131 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
3232 out .writeByte (42 );
Original file line number Diff line number Diff line change 11package com .funniray .minimap .common .voxel .data ;
22
3+ import com .funniray .minimap .common .api .MinimapPlayer ;
34import org .spongepowered .configurate .objectmapping .ConfigSerializable ;
45
56@ ConfigSerializable
@@ -9,4 +10,24 @@ public class VoxelConfig {
910 public boolean radarPlayersAllowed = true ;
1011 public boolean cavesAllowed = true ;
1112 public String teleportCommand = "tp %p %x %y %z" ;
13+
14+ private boolean getOverride (String nodeSuffix , boolean def , MinimapPlayer player ) {
15+ if (player .hasPermission ("minimap.override." +nodeSuffix +".enabled" )) {
16+ return true ;
17+ } else if (player .hasPermission ("minimap.override." +nodeSuffix +".disabled" )) {
18+ return false ;
19+ }
20+
21+ return def ;
22+ }
23+
24+ public VoxelConfig applyOverrides (MinimapPlayer player ) {
25+ VoxelConfig newConfig = new VoxelConfig ();
26+ newConfig .radarAllowed = getOverride ("radar" , this .radarAllowed , player );
27+ newConfig .radarMobsAllowed = getOverride ("radar-mobs" , this .radarMobsAllowed , player );
28+ newConfig .radarPlayersAllowed = getOverride ("radar-players" , this .radarPlayersAllowed , player );
29+ newConfig .cavesAllowed = getOverride ("cave-mode" , this .cavesAllowed , player );
30+
31+ return newConfig ;
32+ }
1233}
Original file line number Diff line number Diff line change 11package com .funniray .minimap .common .xaeros ;
22
3+ import com .funniray .minimap .common .api .MinimapPlayer ;
34import org .spongepowered .configurate .objectmapping .ConfigSerializable ;
45
56@ ConfigSerializable
67public class XaerosConfig {
78 public boolean caveMode = true ;
89 public boolean netherCaveMode = true ;
910 public boolean radar = true ;
11+
12+ private boolean getOverride (String nodeSuffix , boolean def , MinimapPlayer player ) {
13+ if (player .hasPermission ("minimap.override." +nodeSuffix +".enabled" )) {
14+ return true ;
15+ } else if (player .hasPermission ("minimap.override." +nodeSuffix +".disabled" )) {
16+ return false ;
17+ }
18+
19+ return def ;
20+ }
21+
22+ public XaerosConfig applyOverrides (MinimapPlayer player ) {
23+ XaerosConfig newConfig = new XaerosConfig ();
24+ newConfig .radar = getOverride ("radar" , this .radar , player );
25+ newConfig .caveMode = getOverride ("cave-mode" , this .caveMode , player );
26+ newConfig .netherCaveMode = getOverride ("nether-cave-mode" , this .netherCaveMode , player );
27+
28+ return newConfig ;
29+ }
1030}
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ public void sendXaerosConfig(MinimapPlayer player) {
3939 config = worldConfig ;
4040 }
4141
42+ config = config .applyOverrides (player );
43+
4244 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
4345 out .writeByte (4 );
4446 CompoundBinaryTag tag = CompoundBinaryTag .builder ()
You can’t perform that action at this time.
0 commit comments