Skip to content

Commit 376ac16

Browse files
tastybentoBONNeFredthedoggyjstnf
authored
Version 1.17.1 (#1796)
* Version 1.17.1 * Add homes command to default player options. * Implements better online player counter. (#1791) Current one is based on online player count when bStats sends data to the server. This one will send data about amount of players who logged in the server. * Add Boxed Gamemode to the list. (#1793) * Add Bank addon (#1792) * Add Holographic Displays as SoftDepend for AOneBlock (#1794) * Custom date time format support for /<admin> info <player> (#1783) Fixes #1720 * Parent/sub-flag support, split up and designate CONTAINER flag as parent flag (#1784) * Split CONTAINER flag into multiple flags CONTAINER split into - CONTAINER (Chest/Minecart Chest) - BARREL (Barrel) - COMPOSTER (Composter) - FLOWER_POT (Flower Pot) - SHULKER_BOX (Shulker Box) - TRAPPED_CHEST (Trapped Chest) Fixes #1777 * Add subflag support * Create container parent flag, chest subflag * Remove extra string from when CHEST was CONTAINER * Fix incorrect flag specified on fired event in IslandToggleClick * Add missing world subflag event firing * Remove extra import * Add world setting flag for island visitors keep inventory (#1785) * Implement 3 bar charts: addons, gamemodes, hooks (#1790) BStats supports sending Bar chart data, however, it does not display it via their site directly. It can be called manually, to view. PieChart does not work very well for addons and hooks. BarChart however allows viewing each addon separately. This change allows sending data to the server about bar charts. * Update action versions * Declare distribution - adopt * Cache Java Maven files differently. * Try dependency for shade snapshot * Add support for Minecraft 1.17.1 * Fix test by incrementing listener value check There is a new listener now. * Spigot 1.17.1 * Fix test for InventoryListener * Re-order repos. * Downgrading to 1.17 Spigot for now to enable building. * Try pluginRespositories tag in POM to enable Github actions Co-authored-by: BONNe <bonne@bonne.id.lv> Co-authored-by: Fredthedoggy <45927799+Fredthedoggy@users.noreply.github.com> Co-authored-by: Justin <jstnf@users.noreply.github.com>
1 parent 85a9e44 commit 376ac16

File tree

21 files changed

+386
-65
lines changed

21 files changed

+386
-65
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ jobs:
1414
with:
1515
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
1616
- name: Set up JDK 16
17-
uses: actions/setup-java@v1
17+
uses: actions/setup-java@v2
1818
with:
19-
java-version: 16
19+
distribution: 'adopt'
20+
java-version: '16'
2021
- name: Cache SonarCloud packages
21-
uses: actions/cache@v1
22+
uses: actions/cache@v2
2223
with:
2324
path: ~/.sonar/cache
2425
key: ${{ runner.os }}-sonar
2526
restore-keys: ${{ runner.os }}-sonar
26-
- name: Cache Maven packages
27-
uses: actions/cache@v1
27+
- name: Cache local Maven repository
28+
uses: actions/cache@v2
2829
with:
29-
path: ~/.m2
30-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
31-
restore-keys: ${{ runner.os }}-m2
30+
path: ~/.m2/repository
31+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: |
33+
${{ runner.os }}-maven-
3234
- name: Build
3335
run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
3436
- run: mkdir staging && cp target/*.jar staging

ADDON.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
The following is a list of all addons currently made for BentoBox:
2+
* [**Bank**](https://github.com/BentoBoxWorld/Bank/): Provides an island bank to enable island members to share money.
23
* [**Biomes**](https://github.com/BentoBoxWorld/Biomes/): Enables players to change biomes on islands.
34
* [**Border**](https://github.com/BentoBoxWorld/Border/): Adds a world border around islands.
45
* [**Cauldron Witchery**](https://github.com/BentoBoxWorld/CauldronWitchery/): Allows summoning mobs using some magic!

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Start now to create the server you've dreamed of!
2525
These are some popular Gamemodes:
2626
* [**AcidIsland**](https://github.com/BentoBoxWorld/AcidIsland): You are marooned in a sea of acid!
2727
* [**AOneBlock**](https://github.com/BentoBoxWorld/AOneBlock): Start to play with only 1 magical block.
28+
* [**Boxed**](https://github.com/BentoBoxWorld/Boxed): A game mode where you are boxed into a tiny space that only expands by completing advancements.
2829
* [**BSkyBlock**](https://github.com/BentoBoxWorld/BSkyBlock): The successor to the popular ASkyBlock.
2930
* [**CaveBlock**](https://github.com/BentoBoxWorld/CaveBlock): Try to live underground!
3031
* [**SkyGrid**](https://github.com/BentoBoxWorld/SkyGrid): Survive in world made up of scattered blocks - what an adventure!

pom.xml

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
<!-- Do not change unless you want different name for local builds. -->
8484
<build.number>-LOCAL</build.number>
8585
<!-- This allows to change between versions. -->
86-
<build.version>1.17.0</build.version>
86+
<build.version>1.17.1</build.version>
8787
</properties>
8888

8989
<!-- Profiles will allow to automatically change build version. -->
@@ -126,40 +126,16 @@
126126
<build.number></build.number>
127127
</properties>
128128
</profile>
129-
<profile>
130-
<id>sonar</id>
131-
<properties>
132-
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
133-
<sonar.organization>bentobox-world</sonar.organization>
134-
</properties>
135-
<build>
136-
<plugins>
137-
<plugin>
138-
<groupId>org.sonarsource.scanner.maven</groupId>
139-
<artifactId>sonar-maven-plugin</artifactId>
140-
<!-- was <version>3.4.1.1168</version> -->
141-
<version>3.6.0.1398</version>
142-
<executions>
143-
<execution>
144-
<phase>verify</phase>
145-
<goals>
146-
<goal>sonar</goal>
147-
</goals>
148-
</execution>
149-
</executions>
150-
</plugin>
151-
</plugins>
152-
</build>
153-
</profile>
154129
</profiles>
155130

131+
<pluginRepositories>
132+
<pluginRepository>
133+
<id>apache.snapshots</id>
134+
<url>https://repository.apache.org/snapshots/</url>
135+
</pluginRepository>
136+
</pluginRepositories>
137+
156138
<repositories>
157-
<repository>
158-
<!-- This is a temporary reference as the Maven Shade plugin
159-
that supports Java 16 is not released yet -->
160-
<id>maven-snapshots</id>
161-
<url>https://repository.apache.org/content/repositories/snapshots/</url>
162-
</repository>
163139
<repository>
164140
<id>spigot-repo</id>
165141
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
@@ -188,6 +164,13 @@
188164
<id>papermc</id>
189165
<url>https://papermc.io/repo/repository/maven-public/</url>
190166
</repository>
167+
<repository>
168+
<!-- This is a temporary reference as the Maven Shade plugin
169+
that supports Java 16 is not released yet -->
170+
<id>maven-snapshots</id>
171+
<url>https://repository.apache.org/content/repositories/snapshots/</url>
172+
</repository>
173+
191174
</repositories>
192175

193176
<dependencies>
@@ -209,7 +192,7 @@
209192
<dependency>
210193
<groupId>org.spigotmc</groupId>
211194
<artifactId>spigot</artifactId>
212-
<version>1.17-R0.1-SNAPSHOT</version>
195+
<version>${spigot.version}</version>
213196
<scope>provided</scope>
214197
</dependency>
215198
<!-- Metrics -->

src/main/java/world/bentobox/bentobox/BStats.java

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package world.bentobox.bentobox;
22

33
import java.util.HashMap;
4+
import java.util.HashSet;
45
import java.util.Map;
6+
import java.util.Set;
7+
import java.util.UUID;
58

69
import org.bstats.bukkit.Metrics;
710
import org.bstats.charts.AdvancedPie;
11+
import org.bstats.charts.SimpleBarChart;
812
import org.bstats.charts.SimplePie;
913
import org.bstats.charts.SingleLineChart;
1014
import org.bukkit.Bukkit;
@@ -29,6 +33,13 @@ public class BStats {
2933
*/
3034
private int islandsCreatedCount = 0;
3135

36+
/**
37+
* Contains the amount of connected players since last data send.
38+
* @since 1.17.1
39+
*/
40+
private final Set<UUID> connectedPlayerSet = new HashSet<>();
41+
42+
3243
BStats(BentoBox plugin) {
3344
this.plugin = plugin;
3445
}
@@ -53,6 +64,11 @@ private void registerCustomMetrics() {
5364
// Single Line charts
5465
registerIslandsCountChart();
5566
registerIslandsCreatedChart();
67+
68+
// Bar Charts
69+
registerAddonsBarChart();
70+
registerGameModeAddonsBarChart();
71+
registerHooksBarChart();
5672
}
5773

5874
private void registerDefaultLanguageChart() {
@@ -86,6 +102,15 @@ public void increaseIslandsCreatedCount() {
86102
islandsCreatedCount++;
87103
}
88104

105+
/**
106+
* Adds given UUID to the connected player set.
107+
* @param uuid UUID of a player who logins.
108+
* @since 1.17.1
109+
*/
110+
public void addPlayer(UUID uuid) {
111+
this.connectedPlayerSet.add(uuid);
112+
}
113+
89114
/**
90115
* Sends the enabled addons (except GameModeAddons) of this server.
91116
* @since 1.1
@@ -132,7 +157,9 @@ private void registerHooksChart() {
132157
*/
133158
private void registerPlayersPerServerChart() {
134159
metrics.addCustomChart(new SimplePie("playersPerServer", () -> {
135-
int players = Bukkit.getOnlinePlayers().size();
160+
int players = this.connectedPlayerSet.size();
161+
this.connectedPlayerSet.clear();
162+
136163
if (players <= 0) return "0";
137164
else if (players <= 10) return "1-10";
138165
else if (players <= 30) return "11-30";
@@ -164,4 +191,44 @@ private void registerFlagsDisplayModeChart() {
164191
return values;
165192
}));
166193
}
194+
195+
/**
196+
* Sends the enabled addons (except GameModeAddons) of this server as bar chart.
197+
* @since 1.17.1
198+
*/
199+
private void registerAddonsBarChart() {
200+
metrics.addCustomChart(new SimpleBarChart("addonsBar", () -> {
201+
Map<String, Integer> values = new HashMap<>();
202+
plugin.getAddonsManager().getEnabledAddons().stream()
203+
.filter(addon -> !(addon instanceof GameModeAddon) && addon.getDescription().isMetrics())
204+
.forEach(addon -> values.put(addon.getDescription().getName(), 1));
205+
return values;
206+
}));
207+
}
208+
209+
/**
210+
* Sends the enabled GameModeAddons of this server as a bar chart.
211+
* @since 1.17.1
212+
*/
213+
private void registerGameModeAddonsBarChart() {
214+
metrics.addCustomChart(new SimpleBarChart("gameModeAddonsBar", () -> {
215+
Map<String, Integer> values = new HashMap<>();
216+
plugin.getAddonsManager().getGameModeAddons().stream()
217+
.filter(gameModeAddon -> gameModeAddon.getDescription().isMetrics())
218+
.forEach(gameModeAddon -> values.put(gameModeAddon.getDescription().getName(), 1));
219+
return values;
220+
}));
221+
}
222+
223+
/**
224+
* Sends the enabled Hooks of this server as a bar chart.
225+
* @since 1.17.1
226+
*/
227+
private void registerHooksBarChart() {
228+
metrics.addCustomChart(new SimpleBarChart("hooksBar", () -> {
229+
Map<String, Integer> values = new HashMap<>();
230+
plugin.getHooks().getHooks().forEach(hook -> values.put(hook.getPluginName(), 1));
231+
return values;
232+
}));
233+
}
167234
}

src/main/java/world/bentobox/bentobox/api/commands/island/DefaultPlayerCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void setup() {
7878
new IslandSethomeCommand(this);
7979
new IslandDeletehomeCommand(this);
8080
new IslandRenamehomeCommand(this);
81+
new IslandHomesCommand(this);
8182
}
8283

8384

src/main/java/world/bentobox/bentobox/api/flags/Flag.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package world.bentobox.bentobox.api.flags;
22

3+
import java.util.Arrays;
34
import java.util.HashSet;
45
import java.util.Optional;
56
import java.util.Set;
@@ -131,6 +132,7 @@ public boolean isGreaterThan(Mode rank) {
131132
private final Addon addon;
132133
private final int cooldown;
133134
private final Mode mode;
135+
private final Set<Flag> subflags;
134136

135137
private Flag(Builder builder) {
136138
this.id = builder.id;
@@ -147,6 +149,7 @@ private Flag(Builder builder) {
147149
this.cooldown = builder.cooldown;
148150
this.addon = builder.addon;
149151
this.mode = builder.mode;
152+
this.subflags = builder.subflags;
150153
}
151154

152155
public String getID() {
@@ -200,6 +203,18 @@ public void setSetting(World world, boolean setting) {
200203
.getWorldSettings(world)
201204
.getWorldFlags()
202205
.put(getID(), setting);
206+
207+
// Subflag support
208+
if (hasSubflags()) {
209+
subflags.stream()
210+
.filter(subflag -> subflag.getType().equals(Type.WORLD_SETTING) || subflag.getType().equals(Type.PROTECTION))
211+
.forEach(subflag -> BentoBox.getInstance()
212+
.getIWM()
213+
.getWorldSettings(world)
214+
.getWorldFlags()
215+
.put(subflag.getID(), setting));
216+
}
217+
203218
// Save config file
204219
BentoBox.getInstance().getIWM().getAddon(world).ifPresent(GameModeAddon::saveWorldSettings);
205220
}
@@ -208,6 +223,7 @@ public void setSetting(World world, boolean setting) {
208223
/**
209224
* Set the original status of this flag for locations outside of island spaces.
210225
* May be overriden by the the setting for this world.
226+
* Does not affect subflags.
211227
* @param defaultSetting - true means it is allowed. false means it is not allowed
212228
*/
213229
public void setDefaultSetting(boolean defaultSetting) {
@@ -217,6 +233,7 @@ public void setDefaultSetting(boolean defaultSetting) {
217233
/**
218234
* Set the status of this flag for locations outside of island spaces for a specific world.
219235
* World must exist and be registered before this method can be called.
236+
* Does not affect subflags.
220237
* @param defaultSetting - true means it is allowed. false means it is not allowed
221238
*/
222239
public void setDefaultSetting(World world, boolean defaultSetting) {
@@ -435,6 +452,22 @@ public Mode getMode() {
435452
return mode;
436453
}
437454

455+
/**
456+
* @return whether the flag has subflags (and therefore is a parent flag)
457+
* @since 1.17.0
458+
*/
459+
public boolean hasSubflags() {
460+
return !subflags.isEmpty();
461+
}
462+
463+
/**
464+
* @return the subflags, an empty Set if none
465+
* @since 1.17.0
466+
*/
467+
public Set<Flag> getSubflags() {
468+
return subflags;
469+
}
470+
438471
@Override
439472
public String toString() {
440473
return "Flag [id=" + id + "]";
@@ -480,6 +513,9 @@ public static class Builder {
480513
// Mode
481514
private Mode mode = Mode.EXPERT;
482515

516+
// Subflags
517+
private Set<Flag> subflags;
518+
483519
/**
484520
* Builder for making flags
485521
* @param id - a unique id that MUST be the same as the enum of the flag
@@ -488,6 +524,7 @@ public static class Builder {
488524
public Builder(String id, Material icon) {
489525
this.id = id;
490526
this.icon = icon;
527+
this.subflags = new HashSet<>();
491528
}
492529

493530
/**
@@ -595,6 +632,19 @@ public Builder mode(Mode mode) {
595632
return this;
596633
}
597634

635+
/**
636+
* Add subflags and designate this flag as a parent flag.
637+
* Subflags have their state simultaneously changed with the parent flag.
638+
* Take extra care to ensure that subflags have the same number of possible values as the parent flag.
639+
* @param flags all Flags that are subflags
640+
* @return Builder - flag builder
641+
* @since 1.17.0
642+
*/
643+
public Builder subflags(Flag... flags) {
644+
this.subflags.addAll(Arrays.asList(flags));
645+
return this;
646+
}
647+
598648
/**
599649
* Build the flag
600650
* @return Flag

src/main/java/world/bentobox/bentobox/api/flags/clicklisteners/CycleClick.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public boolean onClick(Panel panel, User user, ClickType click, int slot) {
9090
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_OFF, 1F, 1F);
9191
// Fire event
9292
Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), flag, island.getFlag(flag)));
93+
94+
// Subflag support
95+
if (flag.hasSubflags()) {
96+
// Fire events for all subflags as well
97+
flag.getSubflags().forEach(subflag -> Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), subflag, island.getFlag(subflag))));
98+
}
9399
} else if (click.equals(ClickType.RIGHT)) {
94100
if (currentRank <= minRank) {
95101
island.setFlag(flag, maxRank);
@@ -99,6 +105,12 @@ public boolean onClick(Panel panel, User user, ClickType click, int slot) {
99105
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
100106
// Fire event
101107
Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), flag, island.getFlag(flag)));
108+
109+
// Subflag support
110+
if (flag.hasSubflags()) {
111+
// Fire events for all subflags as well
112+
flag.getSubflags().forEach(subflag -> Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), subflag, island.getFlag(subflag))));
113+
}
102114
} else if (click.equals(ClickType.SHIFT_LEFT) && user.isOp()) {
103115
if (!plugin.getIWM().getHiddenFlags(user.getWorld()).contains(flag.getID())) {
104116
plugin.getIWM().getHiddenFlags(user.getWorld()).add(flag.getID());

0 commit comments

Comments
 (0)