1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
tags

Conflicts:
	CHANGELOG.md
	src/test/java/io/github/thebusybiscuit/slimefun4/testing/TestUtilities.java
This commit is contained in:
TheBusyBiscuit 2020-09-19 11:35:41 +02:00
commit 9547d51db2
11 changed files with 52 additions and 83 deletions

View File

@ -23,7 +23,7 @@ This is an Open-Source project and we love Pull Requests.
So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun/Slimefun4/pulls) which fixes this bug. So if you have an idea on how to approach a known issue, feel free to make a [Pull Request](https://github.com/Slimefun/Slimefun4/pulls) which fixes this bug.
You can also comment on the existing Issue, proposing your idea or communicating that you wanna work on this. You can also comment on the existing Issue, proposing your idea or communicating that you wanna work on this.
## :toolbox: 3. Pull Requests: Additions/Changes ## :wrench: 3. Pull Requests: Additions/Changes
Slimefun is an Open-Source project and anyone is allowed to make changes or add content to this plugin! Slimefun is an Open-Source project and anyone is allowed to make changes or add content to this plugin!
Please visit our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and share your ideas first, we hate to reject changes because the community disagrees.<br> Please visit our [Discord Server](https://github.com/Slimefun/Slimefun4#discord) and share your ideas first, we hate to reject changes because the community disagrees.<br>
@ -66,8 +66,9 @@ To prevent any accidents from happening, please contact us on our [Discord Serve
#### Documentation #### Documentation
Code documentation is also a great way to improve the maintainability of the project. Code documentation is also a great way to improve the maintainability of the project.
Every class and every public method should have a Javadocs tag assigned to it. 1. Every class and every public method should have a Javadocs section assigned to it.
Classes should also include an "author" tag to indicate who worked on that class. 2. Classes should also include an `@author` tag to indicate who worked on that class.
3. Methods and parameters should be annotated with `@Nullable` or `@Nonnull` to indicate whether or not null values are accepted.
Feel free to visit our [Javadocs](https://slimefun.github.io/javadocs/Slimefun4/docs/overview-summary.html) Feel free to visit our [Javadocs](https://slimefun.github.io/javadocs/Slimefun4/docs/overview-summary.html)
@ -76,4 +77,20 @@ Unit Tests help us test the project to work as intended in an automated manner.<
More or better Unit Tests are always good to have, so feel free to submit a Test and place it in our [src/test/java](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java/io/github/thebusybiscuit/slimefun4/testing) directory More or better Unit Tests are always good to have, so feel free to submit a Test and place it in our [src/test/java](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java/io/github/thebusybiscuit/slimefun4/testing) directory
We are using [Junit 5 - Jupiter](https://github.com/junit-team/junit5/) and [MockBukkit](https://github.com/seeseemelk/MockBukkit) as our testing environment.<br> We are using [Junit 5 - Jupiter](https://github.com/junit-team/junit5/) and [MockBukkit](https://github.com/seeseemelk/MockBukkit) as our testing environment.<br>
Every new Unit Test should have a "DisplayName" annotation with a plain text description on what the Unit Test tests. Every new Unit Test should have a `@DisplayName` annotation with a plain text description on what the Unit Test tests.
## :toolbox: How to compile Slimefun4
Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.<br>
To compile Slimefun yourself, follow these steps:
1. Clone the project via git<br>
`$ git clone https://github.com/Slimefun/Slimefun4/`
2. Compile the project using Maven<br>
`$ mvn clean package`
3. Extract the compiled `Slimefun-v4.X-UNOFFICIAL.jar` from your `/target/` directory.
If you are already using an IDE, make sure to import the project via git and set it up as a *Maven project*.
Then you should be able build it via Maven using the goals `clean package`.
If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel.<br>
**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**.

View File

@ -17,7 +17,7 @@ assignees: ''
## :bookmark_tabs: Steps to reproduce the Issue (REQUIRED) ## :bookmark_tabs: Steps to reproduce the Issue (REQUIRED)
<!-- Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. --> <!-- Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. -->
<!-- Youtube Videos and Screenshots are recommended! --> <!-- Youtube Videos and Screenshots are recommended!!! -->
<!-- Start writing below this line --> <!-- Start writing below this line -->
@ -30,13 +30,13 @@ assignees: ''
## :scroll: Server Log ## :scroll: Server Log
<!-- Take a look at your Server Log and post any errors you can find via https://pastebin.com/ --> <!-- Take a look at your Server Log and post any errors you can find via https://pastebin.com/ -->
<!-- If you are unsure about it, post your full log, you can find it under /logs/latest.log --> <!-- If you are unsure about it, post your full log, you can find it under /logs/latest.log -->
<!-- Start writing below this line --> <!-- Paste your link(s) below this line -->
## :open_file_folder: Error Reports ## :open_file_folder: /error-reports/ Folder
<!-- Check the folder /plugins/Slimefun/error-reports/ and upload all files inside that folder. --> <!-- Check the folder /plugins/Slimefun/error-reports/ and upload all files inside that folder. -->
<!-- You can also post these files via https://pastebin.com/ --> <!-- You can also post these files via https://pastebin.com/ -->
<!-- Start writing below this line --> <!-- Paste your link(s) below this line -->
## :compass: Environment (REQUIRED) ## :compass: Environment (REQUIRED)

View File

@ -34,6 +34,10 @@
#### Fixes #### Fixes
* Fixed #2300 * Fixed #2300
* Fixed #2296 * Fixed #2296
* Fixed colors of Cheat Sheet Slimefun Guide
* Fixed Cheat Sheet Slimefun Guide being unable to open the settings menu via shift + right click
* Fixed #2320
* Fixed some issues with ChestTerminal
* Fixed #2238 * Fixed #2238
## Release Candidate 16 (07 Sep 2020) ## Release Candidate 16 (07 Sep 2020)

View File

@ -19,6 +19,7 @@ Check out our [Addons](https://github.com/Slimefun/Slimefun4/wiki/Addons), you m
* **[Bug Tracker](https://github.com/Slimefun/Slimefun4/issues)** * **[Bug Tracker](https://github.com/Slimefun/Slimefun4/issues)**
* **[Wiki](https://github.com/Slimefun/Slimefun4/wiki)** * **[Wiki](https://github.com/Slimefun/Slimefun4/wiki)**
* **[FAQ](https://github.com/Slimefun/Slimefun4/wiki/FAQ)** * **[FAQ](https://github.com/Slimefun/Slimefun4/wiki/FAQ)**
* **[How to contribute](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md)**
## Download Slimefun 4 ## Download Slimefun 4
(See also: [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun)) (See also: [How to install Slimefun](https://github.com/Slimefun/Slimefun4/wiki/Installing-Slimefun))
@ -66,7 +67,7 @@ Well, we asked some users on our [Discord server](#discord) to send us some scre
| *Screenshot provided by GalaxyKat11#3816* | *Screenshot provided by TamThan#7987* | *Screenshot provided by Kilaruna#4981* | | *Screenshot provided by GalaxyKat11#3816* | *Screenshot provided by TamThan#7987* | *Screenshot provided by Kilaruna#4981* |
## Discord ## Discord
You can find Slimefun's community on Discord and connect with **over 2000** users of this plugin from all over the world.<br> You can find Slimefun's community on Discord and connect with **over 2500** users of this plugin from all over the world.<br>
Click the badge down below to join the server for suggestions/questions or other discussions about this plugin.<br> Click the badge down below to join the server for suggestions/questions or other discussions about this plugin.<br>
We are also hosting a community event every so often, join us to find out more.<br> We are also hosting a community event every so often, join us to find out more.<br>
**Important**: We do **not** accept bug reports on discord, please use our [Issue Tracker](https://github.com/Slimefun/Slimefun4/issues) to submit bug reports! **Important**: We do **not** accept bug reports on discord, please use our [Issue Tracker](https://github.com/Slimefun/Slimefun4/issues) to submit bug reports!
@ -102,49 +103,10 @@ The wiki is entirely community-run, so if you find an article missing, feel free
## Contributing to this project ## Contributing to this project
Slimefun 4 is an Open-Source project and licensed under Slimefun 4 is an Open-Source project and licensed under
[GNU GPLv3](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE).<br> [GNU GPLv3](https://github.com/Slimefun/Slimefun4/blob/master/LICENSE).<br>
Over 100 people have already contributed to this amazing project. You guys are awesome.<br> Over 150+ people have already contributed to this amazing project. You guys are awesome.<br>
Please consider helping us maintain this project too, your engagement keeps the project alive <3. Please consider helping us maintain this project too, your engagement keeps the project alive <3.
### Translations You can find more info on how to contribute to this project in our [CONTRIBUTING.md](https://github.com/Slimefun/Slimefun4/blob/master/.github/CONTRIBUTING.md).
Slimefun4 has recently added support for translations, note that translations are still _work in progress_.<br>
So not everything may be available for translation yet.<br>
[Read more...](https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun)
### Pull requests
This is an open-source community project, so **your contributions keep this plugin alive!**<br>
Pull Requests can be fixes, changes or even additions, but please keep in mind that if you add too much content to Slimefun 4, you should maybe consider making an Addon for it instead ([Developer Guide](https://github.com/Slimefun/Slimefun4/wiki/Developer-Guide)).
#### Compiling
Slimefun is written in Java and uses [Maven](https://maven.apache.org/) for compilation.<br>
To compile Slimefun yourself, follow these steps:
1. Clone the project via git<br>
`$ git clone https://github.com/Slimefun/Slimefun4/`
2. Compile the project using Maven<br>
`$ mvn clean package`
If you are already using an IDE, make sure to import the project via git and set it as a *Maven project*. Then you should be able build it via Maven using the goals `clean package`.
If you have any further questions, then please join our [Discord Support Server](#discord) and ask your questions in the `#programming-help` channel. Note that we will not accept any bug reports from custom-compiled versions of Slimefun.
### Code Quality
Slimefun uses [Sonarcloud.io](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) to monitor Code Quality.
| [Overall Maintainability](https://sonarcloud.io/documentation/user-guide/metric-definitions/#maintainability) | "Code Smells" | "Technical Debt" | Test Coverage |
| ---- | ---- | ---- | ---- |
| [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=code_smells)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=sqale_index)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=TheBusyBiscuit_Slimefun4&metric=coverage)](https://sonarcloud.io/dashboard?id=TheBusyBiscuit_Slimefun4) |
##### "Code Smells"
Code Smells are portions of the source code that are confusing, lack documentation or are just done very badly in general. These code smells should be held to a bare minimum.
_Please contact us on [Discord](#discord) before working on any code smells. Some design patterns may not be changed abruptly because an addon might depend on them._
##### "Technical Debt"
Technical Debt is basically an estimate for how long it would take to fix all issues and code smells.
##### Test Coverage
Slimefun now also uses Automated Tests to determine whether an update could break something. The coverage shows how much these tests cover. Higher coverage means less breaking changes and as a result also better and more reliable builds.
Due to this being a very huge project though, getting to `100% coverage` is probably close to impossible. But increasing that number even slightly still helps. So feel free to write Unit Tests for Slimefun and place them in the [/src/test/java/](https://github.com/Slimefun/Slimefun4/tree/master/src/test/java) folder.
## Disclaimers ## Disclaimers
Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project. Slimefun4 uses various systems that collect usage information or download automatic updates as well as the latest information about the project.

View File

@ -128,7 +128,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version> <version>0.8.6</version>
<executions> <executions>
<execution> <execution>
@ -304,7 +304,7 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>
<version>5.6.2</version> <version>5.7.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -324,7 +324,7 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>3.5.10</version> <version>3.5.11</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -45,6 +45,9 @@ public class MultiBlock {
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
SUPPORTED_TAGS.add(Tag.WOODEN_FENCES); SUPPORTED_TAGS.add(Tag.WOODEN_FENCES);
} }
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
SUPPORTED_TAGS.add(Tag.FIRE);
}
} }
@Nonnull @Nonnull

View File

@ -15,6 +15,8 @@ import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -296,7 +298,8 @@ abstract class ChestTerminalNetwork extends Network {
try { try {
for (Location l : terminals) { for (Location l : terminals) {
BlockMenu terminal = BlockStorage.getInventory(l); BlockMenu terminal = BlockStorage.getInventory(l);
int page = Integer.parseInt(BlockStorage.getLocationInfo(l, "page")); String data = BlockStorage.getLocationInfo(l, "page");
int page = data == null ? 1 : Integer.parseInt(data);
if (!items.isEmpty() && items.size() < (page - 1) * TERMINAL_SLOTS.length + 1) { if (!items.isEmpty() && items.size() < (page - 1) * TERMINAL_SLOTS.length + 1) {
page = 1; page = 1;
@ -325,13 +328,14 @@ abstract class ChestTerminalNetwork extends Network {
return System.nanoTime() - timestamp; return System.nanoTime() - timestamp;
} }
} }
@Override @Override
public void markDirty(@Nonnull Location l) { public void markDirty(@Nonnull Location l) {
connectorCache.remove(l); connectorCache.remove(l);
super.markDirty(l); super.markDirty(l);
} }
@ParametersAreNonnullByDefault
private void updateTerminal(Location l, BlockMenu terminal, int slot, int index, List<ItemStackAndInteger> items) { private void updateTerminal(Location l, BlockMenu terminal, int slot, int index, List<ItemStackAndInteger> items) {
if (items.size() > index) { if (items.size() > index) {
ItemStackAndInteger item = items.get(index); ItemStackAndInteger item = items.get(index);
@ -390,6 +394,7 @@ abstract class ChestTerminalNetwork extends Network {
return items; return items;
} }
@ParametersAreNonnullByDefault
private void findAllItems(List<ItemStackAndInteger> items, Location l, Block target) { private void findAllItems(List<ItemStackAndInteger> items, Location l, Block target) {
UniversalBlockMenu menu = BlockStorage.getUniversalInventory(target); UniversalBlockMenu menu = BlockStorage.getUniversalInventory(target);
@ -422,6 +427,7 @@ abstract class ChestTerminalNetwork extends Network {
} }
} }
@ParametersAreNonnullByDefault
private void gatherItemsFromBarrel(Location l, BlockMenu blockMenu, List<ItemStackAndInteger> items) { private void gatherItemsFromBarrel(Location l, BlockMenu blockMenu, List<ItemStackAndInteger> items) {
try { try {
Config cfg = BlockStorage.getLocationInfo(blockMenu.getLocation()); Config cfg = BlockStorage.getLocationInfo(blockMenu.getLocation());
@ -457,13 +463,15 @@ abstract class ChestTerminalNetwork extends Network {
} }
} }
@ParametersAreNonnullByDefault
private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> items, Location l) { private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> items, Location l) {
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) { for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
filter(menu.getItemInSlot(slot), items, l); filter(menu.getItemInSlot(slot), items, l);
} }
} }
private void filter(ItemStack stack, List<ItemStackAndInteger> items, Location node) { @ParametersAreNonnullByDefault
private void filter(@Nullable ItemStack stack, List<ItemStackAndInteger> items, Location node) {
if (stack != null && CargoUtils.matchesFilter(node.getBlock(), stack)) { if (stack != null && CargoUtils.matchesFilter(node.getBlock(), stack)) {
boolean add = true; boolean add = true;

View File

@ -38,7 +38,7 @@ public abstract class MedicalSupply<T extends ItemHandler> extends SimpleSlimefu
if (n.hasPotionEffect(PotionEffectType.WEAKNESS)) n.removePotionEffect(PotionEffectType.WEAKNESS); if (n.hasPotionEffect(PotionEffectType.WEAKNESS)) n.removePotionEffect(PotionEffectType.WEAKNESS);
if (n.hasPotionEffect(PotionEffectType.CONFUSION)) n.removePotionEffect(PotionEffectType.CONFUSION); if (n.hasPotionEffect(PotionEffectType.CONFUSION)) n.removePotionEffect(PotionEffectType.CONFUSION);
if (n.hasPotionEffect(PotionEffectType.BLINDNESS)) n.removePotionEffect(PotionEffectType.BLINDNESS); if (n.hasPotionEffect(PotionEffectType.BLINDNESS)) n.removePotionEffect(PotionEffectType.BLINDNESS);
if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) n.removePotionEffect(PotionEffectType.BLINDNESS); if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) n.removePotionEffect(PotionEffectType.BAD_OMEN);
} }
/** /**

View File

@ -71,13 +71,6 @@ public class BlockListener implements Listener {
} }
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true); BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
if (blockHandler != null) {
blockHandler.onPlace(e.getPlayer(), e.getBlock(), sfItem);
}
sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e)); sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e));
} }
} }

View File

@ -4,7 +4,6 @@ import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
@ -22,24 +21,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.UnregisterReason;
@FunctionalInterface @FunctionalInterface
public interface SlimefunBlockHandler { public interface SlimefunBlockHandler {
/**
* This method gets called when the {@link Block} is placed.
* Use this method to initialize block data.
*
* @deprecated Use a {@link BlockPlaceHandler} instead
*
* @param p
* The {@link Player} who placed it
* @param b
* The {@link Block} that was placed
* @param item
* The {@link SlimefunItem} that will be stored inside the {@link Block}
*/
@Deprecated
default void onPlace(Player p, Block b, SlimefunItem item) {
// This has been deprecated
}
/** /**
* This method gets called when the {@link Block} is broken. * This method gets called when the {@link Block} is broken.
* The {@link Player} will be null if the {@link Block} exploded * The {@link Player} will be null if the {@link Block} exploded

View File

@ -93,6 +93,7 @@ public final class TestUtilities {
server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED); server.createMaterialTag(NamespacedKey.minecraft("beds"), Material.RED_BED, Material.BLUE_BED);
server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON); server.createMaterialTag(NamespacedKey.minecraft("fishes"), Material.COD, Material.SALMON);
server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.OAK_DOOR, Material.IRON_DOOR); server.createMaterialTag(NamespacedKey.minecraft("doors"), Material.OAK_DOOR, Material.IRON_DOOR);
server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE);
} }
} }