-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: global role and environment setting overrides (closes #190)
- Loading branch information
Showing
10 changed files
with
168 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
vane-regions/src/main/java/org/oddlama/vane/regions/RegionGlobalEnvironmentOverrides.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.oddlama.vane.regions; | ||
|
||
import org.oddlama.vane.annotation.config.ConfigInt; | ||
import org.oddlama.vane.core.module.Context; | ||
import org.oddlama.vane.core.module.ModuleComponent; | ||
import org.oddlama.vane.regions.region.EnvironmentSetting; | ||
|
||
public class RegionGlobalEnvironmentOverrides extends ModuleComponent<Regions> { | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether animals can spawn.") | ||
public int config_animals; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether monsters can spawn.") | ||
public int config_monsters; | ||
|
||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether explosions can happen.") | ||
public int config_explosions; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether fire spreads and consumes.") | ||
public int config_fire; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether pvp is allowed.") | ||
public int config_pvp; | ||
|
||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether fields can be trampled.") | ||
public int config_trample; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides whether vines can grow.") | ||
public int config_vine_growth; | ||
|
||
public RegionGlobalEnvironmentOverrides(Context<Regions> context) { | ||
super(context.namespace("global_environment_overrides", "This controls global environment setting overrides for all regions on the server. `0` means no-override, the player-configured values are used normally, `1` force-enables this setting for all regions, `-1` force-disables respectively.")); | ||
} | ||
|
||
public int get_override(final EnvironmentSetting setting) { | ||
switch (setting) { | ||
case ANIMALS: return config_animals; | ||
case MONSTERS: return config_monsters; | ||
case EXPLOSIONS: return config_explosions; | ||
case FIRE: return config_fire; | ||
case PVP: return config_pvp; | ||
case TRAMPLE: return config_trample; | ||
case VINE_GROWTH: return config_vine_growth; | ||
} | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void on_enable() {} | ||
|
||
@Override | ||
public void on_disable() {} | ||
} |
40 changes: 40 additions & 0 deletions
40
vane-regions/src/main/java/org/oddlama/vane/regions/RegionGlobalRoleOverrides.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.oddlama.vane.regions; | ||
|
||
import org.oddlama.vane.annotation.config.ConfigInt; | ||
import org.oddlama.vane.core.module.Context; | ||
import org.oddlama.vane.core.module.ModuleComponent; | ||
import org.oddlama.vane.regions.region.RoleSetting; | ||
|
||
public class RegionGlobalRoleOverrides extends ModuleComponent<Regions> { | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides the admin permission. Be careful, this is almost never what you want and may result in immutable regions.") | ||
public int config_admin; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides the build permission.") | ||
public int config_build; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides the use permission.") | ||
public int config_use; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides the container permission.") | ||
public int config_container; | ||
@ConfigInt(def = 0, min = -1, max = 1, desc = "Overrides the portal permission.") | ||
public int config_portal; | ||
|
||
public RegionGlobalRoleOverrides(Context<Regions> context) { | ||
super(context.namespace("global_role_overrides", "This controls global role setting overrides for all roles in every region on the server. `0` means no-override, the player-configured values are used normally, `1` force-enables this setting for all roles in every region, `-1` force-disables respectively. Force-disable naturally also affects the owner, so be careful!")); | ||
} | ||
|
||
public int get_override(final RoleSetting setting) { | ||
switch (setting) { | ||
case ADMIN: return config_admin; | ||
case BUILD: return config_build; | ||
case USE: return config_use; | ||
case CONTAINER: return config_container; | ||
case PORTAL: return config_portal; | ||
} | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void on_enable() {} | ||
|
||
@Override | ||
public void on_disable() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters