3,469
个编辑
MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
| 第250行: | 第250行: | ||
有一些重要的点需要留意 | 有一些重要的点需要留意 | ||
构造函数(Constructor) | ==== 构造函数(Constructor) ==== | ||
构造函数用标识符独一无二 | 构造函数用标识符独一无二 | ||
<syntaxhighlight lang="java"> | |||
public ExampleVisibilityRequirementWithValue() { | public ExampleVisibilityRequirementWithValue() { | ||
//The identifier needs to be unique! It's not possible to register multiple requirements with the same identifier! | //The identifier needs to be unique! It's not possible to register multiple requirements with the same identifier! | ||
| 第257行: | 第258行: | ||
super("example_requirement_with_value"); | super("example_requirement_with_value"); | ||
} | } | ||
</syntaxhighlight> | |||
==== hasValue() ==== | |||
这个方法用于返回 Requirements 是否需要值。 | |||
因为我们想给这个 Requirements 使用值,所以返回true。 | 因为我们想给这个 Requirements 使用值,所以返回true。 | ||
<syntaxhighlight lang="java"> | |||
@Override | @Override | ||
public boolean hasValue() { | public boolean hasValue() { | ||
| 第268行: | 第270行: | ||
return true; | return true; | ||
} | } | ||
</syntaxhighlight> | |||
isRequirementMet() | ==== isRequirementMet() ==== | ||
这是你的 Requirements 的最重要的方法。 | 这是你的 Requirements 的最重要的方法。 | ||
这里用于返回是否满足在此要求中检查的条件。 | 这里用于返回是否满足在此要求中检查的条件。 | ||
这个方法有 Requirements 的值作为参数,所以你可以使用它检查是否满足 Requirements 。 | 这个方法有 Requirements 的值作为参数,所以你可以使用它检查是否满足 Requirements 。 | ||
<syntaxhighlight lang="java"> | |||
//Here you return if the requirement is met (using the given requirement value if the requirement has one). | //Here you return if the requirement is met (using the given requirement value if the requirement has one). | ||
//在这里返回是否满足 Requirements (如果 Requirements 有值则返回 Requirements 的值) | //在这里返回是否满足 Requirements (如果 Requirements 有值则返回 Requirements 的值) | ||
| 第291行: | 第296行: | ||
} | } | ||
</syntaxhighlight> | |||
getDisplayName() | ==== getDisplayName() ==== | ||
此方法返回 Requirements 显示名。 | 此方法返回 Requirements 显示名。 | ||
这个显示名会在布局编辑器的Visibility Requirements选项显示。 | 这个显示名会在布局编辑器的Visibility Requirements选项显示。 | ||
<syntaxhighlight lang="java"> | |||
//This is the display name of the requirement. | //This is the display name of the requirement. | ||
//这个是 Requirements 的显示名。 | //这个是 Requirements 的显示名。 | ||
| 第304行: | 第311行: | ||
return "Example Requirement [With Value]"; | return "Example Requirement [With Value]"; | ||
} | } | ||
</syntaxhighlight> | |||
getDescription() | ==== getDescription() ==== | ||
返回 Requirements 的描述。 | 返回 Requirements 的描述。 | ||
当把鼠标悬停在切换 Requirements 按钮上时,该描述会作为工具提示显示。 | 当把鼠标悬停在切换 Requirements 按钮上时,该描述会作为工具提示显示。 | ||
<syntaxhighlight lang="java"> | |||
//This is the description of the requirement. | //This is the description of the requirement. | ||
//这里是 Requirements 的描述 | //这里是 Requirements 的描述 | ||
| 第319行: | 第328行: | ||
return l; | return l; | ||
} | } | ||
</syntaxhighlight> | |||
==== getValueDisplayName() ==== | |||
getValueDisplayName() | |||
这个方法返回值的显示名。 | 这个方法返回值的显示名。 | ||
<syntaxhighlight lang="java"> | |||
//This is the display name of the VALUE of the requirement. | //This is the display name of the VALUE of the requirement. | ||
//这是 Requirements 的值的显示名。 | //这是 Requirements 的值的显示名。 | ||
| 第331行: | 第340行: | ||
return "Example Value Name"; | return "Example Value Name"; | ||
} | } | ||
</syntaxhighlight> | |||
==== getValuePreset() ==== | |||
如果没有真实的值,则返回自动设置到输入文本字段的内容。 | |||
最好给用户展示真实值的样例。 | 最好给用户展示真实值的样例。 | ||
<syntaxhighlight lang="java"> | |||
//This is the content that will be automatically set to the value input field when there is no value already. | //This is the content that will be automatically set to the value input field when there is no value already. | ||
//在已经没有值的情况下将自动设置到值输入栏的内容。 | //在已经没有值的情况下将自动设置到值输入栏的内容。 | ||
| 第342行: | 第352行: | ||
return "cool value preset"; | return "cool value preset"; | ||
} | } | ||
</syntaxhighlight> | |||
==== getValueInputFieldFilter() ==== | |||
该方法返回一个字符过滤器,该过滤器被用来检查用户可以在数值输入文本字段中允许输入的字符。 | |||
如果你想允许所有字符,那直接返回<code>null</code>。 | |||
<syntaxhighlight lang="java"> | |||
//The character filter of the value input field. Return NULL if you want to allow all characters. | //The character filter of the value input field. Return NULL if you want to allow all characters. | ||
//值输入字段字符过滤器,返回null允许所有字符。 | //值输入字段字符过滤器,返回null允许所有字符。 | ||
| 第355行: | 第366行: | ||
return null; | return null; | ||
} | } | ||
</syntaxhighlight> | |||
====完整示例==== | |||
这是完整的VisibilityRequirement示例. | |||
<syntaxhighlight lang="java"> | |||
package de.keksuccino.fancymenu.api.visibilityrequirements.example; | package de.keksuccino.fancymenu.api.visibilityrequirements.example; | ||
| 第447行: | 第459行: | ||
} | } | ||
</syntaxhighlight> | |||
==== 注册Visibility Requirement ==== | |||
你弟任务!完成啦!啊哈哈哈哈哈哈哈哈哈哈哈哈 | |||
<code>VisibilityRequirement</code>:<code>VisibilityRequirementRegistry</code>先生,Java陛下,我们在天堂(游戏加载)见! | |||
<syntaxhighlight lang="java"> | |||
package de.keksuccino.fancymenu; | package de.keksuccino.fancymenu; | ||
| 第473行: | 第486行: | ||
} | } | ||
</syntaxhighlight> | |||