Skip to content

Commit

Permalink
Version 1.17.1 (#1796)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Fredthedoggy <[email protected]>
Co-authored-by: Justin <[email protected]>
  • Loading branch information
4 people authored Jul 11, 2021
1 parent 85a9e44 commit 376ac16
Show file tree
Hide file tree
Showing 21 changed files with 386 additions and 65 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 16
uses: actions/setup-java@v1
uses: actions/setup-java@v2
with:
java-version: 16
distribution: 'adopt'
java-version: '16'
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build
run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
- run: mkdir staging && cp target/*.jar staging
Expand Down
1 change: 1 addition & 0 deletions ADDON.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
The following is a list of all addons currently made for BentoBox:
* [**Bank**](https://github.com/BentoBoxWorld/Bank/): Provides an island bank to enable island members to share money.
* [**Biomes**](https://github.com/BentoBoxWorld/Biomes/): Enables players to change biomes on islands.
* [**Border**](https://github.com/BentoBoxWorld/Border/): Adds a world border around islands.
* [**Cauldron Witchery**](https://github.com/BentoBoxWorld/CauldronWitchery/): Allows summoning mobs using some magic!
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Start now to create the server you've dreamed of!
These are some popular Gamemodes:
* [**AcidIsland**](https://github.com/BentoBoxWorld/AcidIsland): You are marooned in a sea of acid!
* [**AOneBlock**](https://github.com/BentoBoxWorld/AOneBlock): Start to play with only 1 magical block.
* [**Boxed**](https://github.com/BentoBoxWorld/Boxed): A game mode where you are boxed into a tiny space that only expands by completing advancements.
* [**BSkyBlock**](https://github.com/BentoBoxWorld/BSkyBlock): The successor to the popular ASkyBlock.
* [**CaveBlock**](https://github.com/BentoBoxWorld/CaveBlock): Try to live underground!
* [**SkyGrid**](https://github.com/BentoBoxWorld/SkyGrid): Survive in world made up of scattered blocks - what an adventure!
Expand Down
49 changes: 16 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.17.0</build.version>
<build.version>1.17.1</build.version>
</properties>

<!-- Profiles will allow to automatically change build version. -->
Expand Down Expand Up @@ -126,40 +126,16 @@
<build.number></build.number>
</properties>
</profile>
<profile>
<id>sonar</id>
<properties>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>bentobox-world</sonar.organization>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<!-- was <version>3.4.1.1168</version> -->
<version>3.6.0.1398</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>

<repositories>
<repository>
<!-- This is a temporary reference as the Maven Shade plugin
that supports Java 16 is not released yet -->
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
Expand Down Expand Up @@ -188,6 +164,13 @@
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<!-- This is a temporary reference as the Maven Shade plugin
that supports Java 16 is not released yet -->
<id>maven-snapshots</id>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
</repository>

</repositories>

<dependencies>
Expand All @@ -209,7 +192,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<!-- Metrics -->
Expand Down
69 changes: 68 additions & 1 deletion src/main/java/world/bentobox/bentobox/BStats.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package world.bentobox.bentobox;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.bstats.bukkit.Metrics;
import org.bstats.charts.AdvancedPie;
import org.bstats.charts.SimpleBarChart;
import org.bstats.charts.SimplePie;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
Expand All @@ -29,6 +33,13 @@ public class BStats {
*/
private int islandsCreatedCount = 0;

/**
* Contains the amount of connected players since last data send.
* @since 1.17.1
*/
private final Set<UUID> connectedPlayerSet = new HashSet<>();


BStats(BentoBox plugin) {
this.plugin = plugin;
}
Expand All @@ -53,6 +64,11 @@ private void registerCustomMetrics() {
// Single Line charts
registerIslandsCountChart();
registerIslandsCreatedChart();

// Bar Charts
registerAddonsBarChart();
registerGameModeAddonsBarChart();
registerHooksBarChart();
}

private void registerDefaultLanguageChart() {
Expand Down Expand Up @@ -86,6 +102,15 @@ public void increaseIslandsCreatedCount() {
islandsCreatedCount++;
}

/**
* Adds given UUID to the connected player set.
* @param uuid UUID of a player who logins.
* @since 1.17.1
*/
public void addPlayer(UUID uuid) {
this.connectedPlayerSet.add(uuid);
}

/**
* Sends the enabled addons (except GameModeAddons) of this server.
* @since 1.1
Expand Down Expand Up @@ -132,7 +157,9 @@ private void registerHooksChart() {
*/
private void registerPlayersPerServerChart() {
metrics.addCustomChart(new SimplePie("playersPerServer", () -> {
int players = Bukkit.getOnlinePlayers().size();
int players = this.connectedPlayerSet.size();
this.connectedPlayerSet.clear();

if (players <= 0) return "0";
else if (players <= 10) return "1-10";
else if (players <= 30) return "11-30";
Expand Down Expand Up @@ -164,4 +191,44 @@ private void registerFlagsDisplayModeChart() {
return values;
}));
}

/**
* Sends the enabled addons (except GameModeAddons) of this server as bar chart.
* @since 1.17.1
*/
private void registerAddonsBarChart() {
metrics.addCustomChart(new SimpleBarChart("addonsBar", () -> {
Map<String, Integer> values = new HashMap<>();
plugin.getAddonsManager().getEnabledAddons().stream()
.filter(addon -> !(addon instanceof GameModeAddon) && addon.getDescription().isMetrics())
.forEach(addon -> values.put(addon.getDescription().getName(), 1));
return values;
}));
}

/**
* Sends the enabled GameModeAddons of this server as a bar chart.
* @since 1.17.1
*/
private void registerGameModeAddonsBarChart() {
metrics.addCustomChart(new SimpleBarChart("gameModeAddonsBar", () -> {
Map<String, Integer> values = new HashMap<>();
plugin.getAddonsManager().getGameModeAddons().stream()
.filter(gameModeAddon -> gameModeAddon.getDescription().isMetrics())
.forEach(gameModeAddon -> values.put(gameModeAddon.getDescription().getName(), 1));
return values;
}));
}

/**
* Sends the enabled Hooks of this server as a bar chart.
* @since 1.17.1
*/
private void registerHooksBarChart() {
metrics.addCustomChart(new SimpleBarChart("hooksBar", () -> {
Map<String, Integer> values = new HashMap<>();
plugin.getHooks().getHooks().forEach(hook -> values.put(hook.getPluginName(), 1));
return values;
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void setup() {
new IslandSethomeCommand(this);
new IslandDeletehomeCommand(this);
new IslandRenamehomeCommand(this);
new IslandHomesCommand(this);
}


Expand Down
50 changes: 50 additions & 0 deletions src/main/java/world/bentobox/bentobox/api/flags/Flag.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package world.bentobox.bentobox.api.flags;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -131,6 +132,7 @@ public boolean isGreaterThan(Mode rank) {
private final Addon addon;
private final int cooldown;
private final Mode mode;
private final Set<Flag> subflags;

private Flag(Builder builder) {
this.id = builder.id;
Expand All @@ -147,6 +149,7 @@ private Flag(Builder builder) {
this.cooldown = builder.cooldown;
this.addon = builder.addon;
this.mode = builder.mode;
this.subflags = builder.subflags;
}

public String getID() {
Expand Down Expand Up @@ -200,6 +203,18 @@ public void setSetting(World world, boolean setting) {
.getWorldSettings(world)
.getWorldFlags()
.put(getID(), setting);

// Subflag support
if (hasSubflags()) {
subflags.stream()
.filter(subflag -> subflag.getType().equals(Type.WORLD_SETTING) || subflag.getType().equals(Type.PROTECTION))
.forEach(subflag -> BentoBox.getInstance()
.getIWM()
.getWorldSettings(world)
.getWorldFlags()
.put(subflag.getID(), setting));
}

// Save config file
BentoBox.getInstance().getIWM().getAddon(world).ifPresent(GameModeAddon::saveWorldSettings);
}
Expand All @@ -208,6 +223,7 @@ public void setSetting(World world, boolean setting) {
/**
* Set the original status of this flag for locations outside of island spaces.
* May be overriden by the the setting for this world.
* Does not affect subflags.
* @param defaultSetting - true means it is allowed. false means it is not allowed
*/
public void setDefaultSetting(boolean defaultSetting) {
Expand All @@ -217,6 +233,7 @@ public void setDefaultSetting(boolean defaultSetting) {
/**
* Set the status of this flag for locations outside of island spaces for a specific world.
* World must exist and be registered before this method can be called.
* Does not affect subflags.
* @param defaultSetting - true means it is allowed. false means it is not allowed
*/
public void setDefaultSetting(World world, boolean defaultSetting) {
Expand Down Expand Up @@ -435,6 +452,22 @@ public Mode getMode() {
return mode;
}

/**
* @return whether the flag has subflags (and therefore is a parent flag)
* @since 1.17.0
*/
public boolean hasSubflags() {
return !subflags.isEmpty();
}

/**
* @return the subflags, an empty Set if none
* @since 1.17.0
*/
public Set<Flag> getSubflags() {
return subflags;
}

@Override
public String toString() {
return "Flag [id=" + id + "]";
Expand Down Expand Up @@ -480,6 +513,9 @@ public static class Builder {
// Mode
private Mode mode = Mode.EXPERT;

// Subflags
private Set<Flag> subflags;

/**
* Builder for making flags
* @param id - a unique id that MUST be the same as the enum of the flag
Expand All @@ -488,6 +524,7 @@ public static class Builder {
public Builder(String id, Material icon) {
this.id = id;
this.icon = icon;
this.subflags = new HashSet<>();
}

/**
Expand Down Expand Up @@ -595,6 +632,19 @@ public Builder mode(Mode mode) {
return this;
}

/**
* Add subflags and designate this flag as a parent flag.
* Subflags have their state simultaneously changed with the parent flag.
* Take extra care to ensure that subflags have the same number of possible values as the parent flag.
* @param flags all Flags that are subflags
* @return Builder - flag builder
* @since 1.17.0
*/
public Builder subflags(Flag... flags) {
this.subflags.addAll(Arrays.asList(flags));
return this;
}

/**
* Build the flag
* @return Flag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public boolean onClick(Panel panel, User user, ClickType click, int slot) {
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_OFF, 1F, 1F);
// Fire event
Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), flag, island.getFlag(flag)));

// Subflag support
if (flag.hasSubflags()) {
// Fire events for all subflags as well
flag.getSubflags().forEach(subflag -> Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), subflag, island.getFlag(subflag))));
}
} else if (click.equals(ClickType.RIGHT)) {
if (currentRank <= minRank) {
island.setFlag(flag, maxRank);
Expand All @@ -99,6 +105,12 @@ public boolean onClick(Panel panel, User user, ClickType click, int slot) {
user.getPlayer().playSound(user.getLocation(), Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1F, 1F);
// Fire event
Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), flag, island.getFlag(flag)));

// Subflag support
if (flag.hasSubflags()) {
// Fire events for all subflags as well
flag.getSubflags().forEach(subflag -> Bukkit.getPluginManager().callEvent(new FlagProtectionChangeEvent(island, user.getUniqueId(), subflag, island.getFlag(subflag))));
}
} else if (click.equals(ClickType.SHIFT_LEFT) && user.isOp()) {
if (!plugin.getIWM().getHiddenFlags(user.getWorld()).contains(flag.getID())) {
plugin.getIWM().getHiddenFlags(user.getWorld()).add(flag.getID());
Expand Down
Loading

0 comments on commit 376ac16

Please sign in to comment.