You should be able to use the org.bukkit.block.Banner class to freely change the patterns on a placed banner, including removing all patterns if you wish.
Observed/Actual behavior
You can freely edit patterns in this manner, as long as the end state is that the banner still has some sort of pattern. If you try removing all patterns so the banner is empty, the banner remains unchanged (it keeps its previous patterns). This seems to only occur if the rest of the banner's state (banner type and rotation) is also unchanged.
Steps/models to reproduce
Here's the code from my plugin that highlights the issue. "bannerBlock" is an instance of org.bukkit.block.Block that points to the banner in the world, and the banner starts out with a pattern on it.
Banner bannerState=(Banner)bannerBlock.getState();while(bannerState.numberOfPatterns()>0)bannerState.removePattern(0);bannerState.update(true);
If you run this code, the banner remains unchanged. HOWEVER, the following code DOES work:
None except my own plugin where this issue occurred
Paper version
This server is running Paper version 1.21.1-120-master@57c75a4 (2024-10-09T21:11:07Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.1-57-b483da4 (MC: 1.21.1)
Expected behavior
You should be able to use the org.bukkit.block.Banner class to freely change the patterns on a placed banner, including removing all patterns if you wish.
Observed/Actual behavior
You can freely edit patterns in this manner, as long as the end state is that the banner still has some sort of pattern. If you try removing all patterns so the banner is empty, the banner remains unchanged (it keeps its previous patterns). This seems to only occur if the rest of the banner's state (banner type and rotation) is also unchanged.
Steps/models to reproduce
Here's the code from my plugin that highlights the issue. "bannerBlock" is an instance of org.bukkit.block.Block that points to the banner in the world, and the banner starts out with a pattern on it.
Banner bannerState=(Banner)bannerBlock.getState();
while(bannerState.numberOfPatterns()>0)
bannerState.removePattern(0);
bannerState.update(true);
If you run this code, the banner remains unchanged. HOWEVER, the following code DOES work:
Banner bannerState=(Banner)bannerBlock.getState();
while(bannerState.numberOfPatterns()>0)
bannerState.removePattern(0);
bannerState.addPattern(some_pattern);
bannerState.update(true);
Plugin and Datapack List
None except my own plugin where this issue occurred
Paper version
This server is running Paper version 1.21.1-120-master@57c75a4 (2024-10-09T21:11:07Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT) You are running the latest version Previous version: 1.21.1-57-b483da4 (MC: 1.21.1)
Other
No response