自定义 Flag
264 字小于 1 分钟
2025-10-10
自 4.7.0 起,Dominion 开放了自定义 Flag 的功能,允许开发者为领地系统添加自定义的 Flag。
简介
Dominion 的 Flag 系统由两种 Flag 构成:
EnvFlag
: Environment Flag,用于表示与玩家行为无关的领地属性,例如领地的自然环境、天气等。PriFlag
: Privilege Flag,用于表示与玩家行为相关的领地属性,例如玩家是否可以在领地内建造、破坏等。
Flag 对象定义:
/**
* Constructs a new Flag.
*
* @param flag_name the name of the flag (should be unique and not contain spaces)
* @param display_name the display name of the flag
* @param description the description of the flag
* @param default_value the default value of the flag
* @param enable the enable status of the flag
* @param material the material of flag in CUI
*/
构造自定义 Flag
// Define a custom EnvFlag
public static EnvFlag NO_RAIN = new EnvFlag("no_rain", "No Rain", "Weather does not change to rain in this dominion.", false, true, Material.SUNFLOWER);
// Define a custom PriFlag
public static PriFlag BED = new PriFlag("bed", "Bed", "Weather can sleep in bed (set spawn point).", false, true, Material.RED_BED);
// Register the custom flags
Flags.registerEnvFlag(NO_RAIN);
Flags.registerPriFlag(BED);
// Apply the custom flags to dominion system.
Flags.applyNewCustomFlags();