Skip to content

Commit

Permalink
Merge pull request #324 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Version 1.14.0
  • Loading branch information
tastybento authored Jul 6, 2023
2 parents a7e1318 + 2a3e862 commit 78695e7
Show file tree
Hide file tree
Showing 20 changed files with 806 additions and 237 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
96 changes: 79 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ The user command is `/ob`. The admin command is `/oba`.

Q: What phases are there?

A: There are 11 phases: Plains, Underground, Winter, Ocean, Jungle, Swamp, Dungeon, Desert, The Nether, Plenty, Desolation, and The End. Each phase features a set of blocks, items, and mobs appropriate for the setting.
A: There are 12 phases: Plains, Underground, Winter, Ocean, Jungle, Swamp, Dungeon, Desert, The Nether, Plenty, Desolation, Deep Dark, and The End. Each phase features a set of blocks, chests, items, and mobs appropriate for the setting.

Q: How many blocks are there in the 11 phases?
Q: How many blocks are there in the phases?

A: There are currently 11 thousand blocks!
A: There are currently 12 thousand blocks!

Q: What happens after the last phase?

A: The phases repeat.

Q: Why do I keep falling and dying!

A: There are tricks to surviving, but it might be difficult! You need to build defenses.
A: There are tricks to surviving, but it might be difficult! You need to build space so you don't fall.

Q: I can't catch the blocks when I mine them! How do I do that?

A: Yep. It's tough. You can't catch them all, but it *is* an infinite block!
A: You can't catch them all, but it *is* an infinite block!

Q: Why do certain blocks spawn more frequently than others?

A: They just do! You can set the relative probability in the config files in the phases folder.
A: They just do! It's random. You can set the relative probability in the config files in the phases folder. Admins can also set certain blocks to appear at certain times no matter what. Look out for the sponge for example!

Q. How do I know which is the magic block?

A. Hit it and it will give out green particles.
A. Hit it and it will give out green particles. It's also at the center of your island.

Q. My magic block is no longer there! How do I get another one?

Expand All @@ -68,15 +68,15 @@ A. Be prepared. Listen carefully when you mine a block and you will hear hostile

Q. When mobs spawn, my defenses are destroyed! Why?

A. Mobs make space to spawn. If there's anything in the way, it'll be broken and dropped. You'll have to build accordingly.
A. Mobs make space to spawn. If there's anything in the way, it'll be broken and dropped. You'll have to build accordingly. This is to prevent suffocation exploits.

Q: Do chests spawn?

A: Yes. Chests spawn with random items in them from the current phase. There are common, uncommon, rare and epic chests. Chests with sparkles are good.

Q: Is it possible to reach the Nether or End in this map?

A: The vanilla Nether exists by default but there is no End world.
A: The vanilla Nether exists by default but there is no End world, just an End Phase.

Q: What is the end goal?

Expand All @@ -100,14 +100,81 @@ The config files to make the phases are in the phases folder.
There are two files per phase - a file that contains the blocks and mobs, and a file that contains the chests.

The first number of any file is how many blocks need to be mined to reach that phase. This is the phase's key number.
Each phase also has a name, a biome and the following sections:

Each phase also has a name, an icon, a biome and the following sections:

- name
- icon
- fixedBlocks
- holograms
- biome
- start-commands
- end-commands
- end-commands-first-time
- requirements
- blocks
- mobs

In the chests file, it just has the phase number and a chests section.


### name
Name of the phase

### icon
The material for an icon to show

### fixedBlocks
List of blocks that will generate at these specific block counts. The numbers are relative to the phase and not the overall player's count.
If you define 0 here, then firstBlock is not required and firstBlock will be replaced with this block.

### holograms

Hologram Lines to Display. The key number is the block of the phase to show the hologram. Chat color codes can be used. A hologram plugin is not required for these holograms.
The First (Before Phase 1) Hologram is Located in your Locale.

### Biome
The biomes for this phase.

### Commands
A list of commands can be run at the start and end of a phase. Commands are run as the Console
unless the command is prefixed with [SUDO], then the command is run as the player
triggering the commands.

These placeholders in the command string will be replaced with the appropriate value:
* [island] - Island name
* [owner] - Island owner's name
* [player] - The name of the player who broke the block triggering the commands
* [phase] - the name of this phase
* [blocks] - the number of blocks broken
* [level] - your island level (Requires Levels Addon)
* [bank-balance] - your island bank balance (Requires Bank Addon)
* [eco-balance] - player's economy balance (Requires Vault and an economy plugin)

Examples:
```
start-commands:
- 'give [player] WOODEN_AXE 1'
- 'broadcast [player] just started OneBlock!'
end-commands:
- '[SUDO]summon minecraft:wither'
These are run only the first time a phase is completed
end-commands-first-time:
- 'broadcast &c&l[!] &b[player] &fhas completed the &d&n[phase]&f phase for the first time.'
```
### Requirements

You can stipulate a set of requirements to start the phase:
* economy-balance - the minimum player's economy balance (Requires Vault and an economy plugin)
* bank-balance - the minimum island bank balance (requires Bank Addon)
* level - the island level (Requires Levels Addon)
* permission - a permission string
Example:
```
requirements:
bank-balance: 10000
level: 10
permission: ready.for.battle
```

### blocks

The blocks section list Bukkit Materials followed by a relative probability. All the probability values are added up for the whole phase and the chance of the block being placed is the relative probability divided by the total of all the probabilities.
Expand All @@ -130,11 +197,6 @@ OneBlock is an add-on that uses the BentoBox API. Here are some other ones that

You can add all the usual addons to OneBlock, like Challeges, Likes, Level, Warps, etc. but it is not required.

### Other Plugins

* To use the Holographic phase names, you will need to install the [Holographic Displays plugin](https://dev.bukkit.org/projects/holographic-displays)


Bugs and Feature requests
=========================
File bug and feature requests here: https://github.com/BentoBoxWorld/OneBlock/issues
Expand Down
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.19.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.22.0</bentobox.version>
<bentobox.version>1.24.0-SNAPSHOT</bentobox.version>
<level.version>2.6.2</level.version>
<bank.version>1.3.0</bank.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- 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.13.0</build.version>
<build.version>1.14.0</build.version>
<!-- SonarCloud -->
<sonar.projectKey>BentoBoxWorld_AOneBlock</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -141,6 +141,10 @@
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack-repo</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -208,6 +212,12 @@
<version>${bank.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>API-ItemsAdder</artifactId>
<version>3.2.5</version>
<scope>provided</scope>
</dependency>

</dependencies>

Expand Down
52 changes: 36 additions & 16 deletions src/main/java/world/bentobox/aoneblock/AOneBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.Objects;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
Expand All @@ -19,6 +20,8 @@
import world.bentobox.aoneblock.listeners.BlockListener;
import world.bentobox.aoneblock.listeners.BlockProtect;
import world.bentobox.aoneblock.listeners.HoloListener;
import world.bentobox.aoneblock.listeners.InfoListener;
import world.bentobox.aoneblock.listeners.ItemsAdderListener;
import world.bentobox.aoneblock.listeners.JoinLeaveListener;
import world.bentobox.aoneblock.listeners.NoBlockHandler;
import world.bentobox.aoneblock.oneblocks.OneBlocksManager;
Expand All @@ -38,6 +41,7 @@ public class AOneBlock extends GameModeAddon {

private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
public static boolean hasItemsAdder = false;

// Settings
private Settings settings;
Expand All @@ -50,6 +54,11 @@ public class AOneBlock extends GameModeAddon {

@Override
public void onLoad() {
// Check if ItemsAdder exists, if yes register listener
if (Bukkit.getPluginManager().getPlugin("ItemsAdder") != null) {
registerListener(new ItemsAdderListener(this));
hasItemsAdder = true;
}
// Save the default config from config.yml
saveDefaultConfig();
// Load settings from config.yml. This will check if there are any issues with it too.
Expand Down Expand Up @@ -79,21 +88,12 @@ private boolean loadSettings() {

@Override
public void onEnable() {
try {
oneBlockManager = new OneBlocksManager(this);
oneBlockManager.loadPhases();
blockListener = new BlockListener(this);
} catch (IOException e) {
// Disable
logError("AOneBlock settings could not load (oneblock.yml error)! Addon disabled.");
logError(e.getMessage());
setState(State.DISABLED);
return;
}
registerListener(blockListener);
loadData();

registerListener(new NoBlockHandler(this));
registerListener(new BlockProtect(this));
registerListener(new JoinLeaveListener(this));
registerListener(new InfoListener(this));
// Register placeholders
registerPlaceholders();

Expand All @@ -106,6 +106,22 @@ public void onEnable() {
registerListener(holoListener);
}

//Load some of Manager
public void loadData() {
try {
oneBlockManager = new OneBlocksManager(this);
oneBlockManager.loadPhases();
blockListener = new BlockListener(this);
} catch (IOException e) {
// Disable
logError("AOneBlock settings could not load (oneblock.yml error)! Addon disabled.");
logError(e.getMessage());
setState(State.DISABLED);
return;
}
registerListener(blockListener);
}

private void registerPlaceholders() {
phManager = new PlaceholdersManager(this);
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_phase", phManager::getPhaseByLocation);
Expand All @@ -122,7 +138,7 @@ private void registerPlaceholders() {
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_done_scale", phManager::getDoneScaleByLocation);
// Since 1.10
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "visited_island_lifetime_count", phManager::getLifetimeByLocation);
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_lifetime_count", phManager::getLifetime);
getPlugin().getPlaceholdersManager().registerPlaceholder(this, "my_island_lifetime_count", phManager::getLifetime);
}

@Override
Expand Down Expand Up @@ -253,9 +269,6 @@ public void saveDefaultConfig()
public void allLoaded() {
// save settings. This will occur after all addons have loaded
this.saveWorldSettings();

// Manage Old Holograms
holoListener.setUp();
}

/**
Expand Down Expand Up @@ -293,4 +306,11 @@ public PlaceholdersManager getPlaceholdersManager() {
public HoloListener getHoloListener() {
return holoListener;
}

/**
* @return true if ItemsAdder is on the server
*/
public boolean hasItemsAdder() {
return hasItemsAdder;
}
}
20 changes: 20 additions & 0 deletions src/main/java/world/bentobox/aoneblock/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public class Settings implements WorldSettings {
@ConfigComment("If set to 0, then holograms will persist until cleared some other way.")
@ConfigEntry(path = "world.hologram-duration")
private int hologramDuration = 10;

@ConfigComment("Clear blocks when spawning mobs.")
@ConfigComment("Mobs break blocks when they spawn is to prevent players from building a box around the magic block,")
@ConfigComment("having the mob spawn, and then die by suffocation, i.e., it's a cheat prevention.")
@ConfigEntry(path = "world.mobs-clear-blocks")
private boolean clearBlocks = true;

@ConfigComment("Spawn limits. These override the limits set in bukkit.yml")
@ConfigComment("If set to a negative number, the server defaults will be used")
Expand Down Expand Up @@ -2041,4 +2047,18 @@ public boolean isUseHolograms() {
public void setUseHolograms(boolean useHolograms) {
this.useHolograms = useHolograms;
}

/**
* @return the clearBlocks
*/
public boolean isClearBlocks() {
return clearBlocks;
}

/**
* @param clearBlocks the clearBlocks to set
*/
public void setClearBlocks(boolean clearBlocks) {
this.clearBlocks = clearBlocks;
}
}
Loading

0 comments on commit 78695e7

Please sign in to comment.