mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Merge branch 'master' into EnergyConnector
This commit is contained in:
commit
eb572a1a77
9
.github/configs/wiki-schema.json
vendored
Normal file
9
.github/configs/wiki-schema.json
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"type" : "object",
|
||||||
|
"additionalProperties" : false,
|
||||||
|
"patternProperties" : {
|
||||||
|
"^[A-Z0-9_]+$" : {
|
||||||
|
"type" : "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
.github/workflows/auto-approve.yml
vendored
9
.github/workflows/auto-approve.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Approve via actions
|
- name: Approve via actions
|
||||||
uses: hmarr/auto-approve-action@v2.0.0
|
uses: hmarr/auto-approve-action@v2.0.0
|
||||||
if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]'
|
if: github.actor == 'gitlocalize-app[bot]'
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
- name: Approve via TheBusyBot
|
- name: Approve via TheBusyBot
|
||||||
@ -20,3 +20,10 @@ jobs:
|
|||||||
if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]'
|
if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]'
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.ACCESS_TOKEN }}"
|
github-token: "${{ secrets.ACCESS_TOKEN }}"
|
||||||
|
- name: Add Translations label
|
||||||
|
uses: maxkomarychev/octions/octions/issues/add-labels@master
|
||||||
|
if: github.actor == 'gitlocalize-app[bot]'
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
issue_number: ${{ github.event.pull_request.number }}
|
||||||
|
labels: 'Translations Update'
|
||||||
|
24
.github/workflows/json-validator.yml
vendored
Normal file
24
.github/workflows/json-validator.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: Validate JSON
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/main/resources/wiki.json'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/main/resources/wiki.json'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
|
||||||
|
name: Validate JSON
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Validate JSON
|
||||||
|
uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4
|
||||||
|
env:
|
||||||
|
INPUT_SCHEMA: '.github/configs/wiki-schema.json'
|
||||||
|
INPUT_JSONS: 'src/main/resources/wiki.json'
|
2
.github/workflows/yaml-linter.yml
vendored
2
.github/workflows/yaml-linter.yml
vendored
@ -20,4 +20,4 @@ jobs:
|
|||||||
- name: YAML Linter
|
- name: YAML Linter
|
||||||
uses: ibiqlik/action-yamllint@v1.0.0
|
uses: ibiqlik/action-yamllint@v1.0.0
|
||||||
with:
|
with:
|
||||||
config_file: '.github/yaml-linter-config.yml'
|
config_file: '.github/configs/yaml-linter.yml'
|
||||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -31,6 +31,11 @@
|
|||||||
* Added a config option for Grappling Hooks to not be consumed on use
|
* Added a config option for Grappling Hooks to not be consumed on use
|
||||||
* Added Talisman of the Caveman
|
* Added Talisman of the Caveman
|
||||||
* You can now convert any gold ingot into gold dust with slightly less returns
|
* You can now convert any gold ingot into gold dust with slightly less returns
|
||||||
|
* Magical Zombie Pills now also work on Zombified Piglins
|
||||||
|
* (API) Added SlimefunGuideOpenEvent
|
||||||
|
* (API) Added "NotConfigurable" attribute to disable configurability
|
||||||
|
* Added Elytra Cap
|
||||||
|
* Added Planks to Sticks recipe to the Table Saw
|
||||||
|
|
||||||
#### Changes
|
#### Changes
|
||||||
* Improved Auto-Updater (Multi-Threading and more)
|
* Improved Auto-Updater (Multi-Threading and more)
|
||||||
@ -55,6 +60,11 @@
|
|||||||
* Fixed #2360
|
* Fixed #2360
|
||||||
* Fixed #2351
|
* Fixed #2351
|
||||||
* Fixed #2357
|
* Fixed #2357
|
||||||
|
* Fixed Auto Enchanters being unaffected by speed modifications from addons
|
||||||
|
* Fixed Auto Disenchanters being unaffected by speed modifications from addons
|
||||||
|
* Fixed radioactive items still being radioactive when disabled
|
||||||
|
* Fixed #2391
|
||||||
|
* Fixed #2403
|
||||||
|
|
||||||
## Release Candidate 16 (07 Sep 2020)
|
## Release Candidate 16 (07 Sep 2020)
|
||||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16
|
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16
|
||||||
|
5
pom.xml
5
pom.xml
@ -77,6 +77,7 @@
|
|||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||||
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
||||||
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
|
||||||
<finalName>${project.name} v${project.version}</finalName>
|
<finalName>${project.name} v${project.version}</finalName>
|
||||||
|
|
||||||
@ -213,7 +214,7 @@
|
|||||||
<link>${spigot.javadocs}</link>
|
<link>${spigot.javadocs}</link>
|
||||||
</links>
|
</links>
|
||||||
|
|
||||||
<!-- We can group pakages together in our Javadocs -->
|
<!-- We can group packages together in our Javadocs -->
|
||||||
<groups>
|
<groups>
|
||||||
<group>
|
<group>
|
||||||
<title>Slimefun4 - API</title>
|
<title>Slimefun4 - API</title>
|
||||||
@ -309,7 +310,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.seeseemelk</groupId>
|
<groupId>com.github.seeseemelk</groupId>
|
||||||
<artifactId>MockBukkit-v1.16</artifactId>
|
<artifactId>MockBukkit-v1.16</artifactId>
|
||||||
<version>0.6.0</version>
|
<version>0.10.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -0,0 +1,104 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
|
||||||
|
*
|
||||||
|
* @author Linox
|
||||||
|
*
|
||||||
|
* @see SlimefunGuideLayout
|
||||||
|
*/
|
||||||
|
public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final ItemStack guide;
|
||||||
|
private SlimefunGuideLayout layout;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideLayout layout) {
|
||||||
|
Validate.notNull(p, "The Player cannot be null");
|
||||||
|
Validate.notNull(guide, "Guide cannot be null");
|
||||||
|
Validate.notNull(layout, "Layout cannot be null");
|
||||||
|
this.player = p;
|
||||||
|
this.guide = guide;
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link Player} that tries to open
|
||||||
|
* the Slimefun Guide.
|
||||||
|
*
|
||||||
|
* @return The {@link Player}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link ItemStack} that {@link Player}
|
||||||
|
* tries to open the Slimefun Guide with.
|
||||||
|
*
|
||||||
|
* @return The {@link ItemStack}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public ItemStack getGuide() {
|
||||||
|
return guide;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link SlimefunGuideLayout} of the Slimefun Guide
|
||||||
|
* that {@link Player} tries to open.
|
||||||
|
*
|
||||||
|
* @return The {@link SlimefunGuideLayout}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public SlimefunGuideLayout getGuideLayout() {
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the {@link SlimefunGuideLayout} that was tried to be opened with.
|
||||||
|
*
|
||||||
|
* @param layout
|
||||||
|
* The new {@link SlimefunGuideLayout}
|
||||||
|
*/
|
||||||
|
public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) {
|
||||||
|
Validate.notNull(layout, "You must specify a layout that is not-null!");
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return getHandlerList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -34,6 +34,7 @@ public class PlayerBackpack {
|
|||||||
|
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
private int size;
|
private int size;
|
||||||
|
private static final String CONFIG_PREFIX = "backpacks.";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor loads an existing Backpack
|
* This constructor loads an existing Backpack
|
||||||
@ -44,10 +45,10 @@ public class PlayerBackpack {
|
|||||||
* The id of this Backpack
|
* The id of this Backpack
|
||||||
*/
|
*/
|
||||||
public PlayerBackpack(@Nonnull PlayerProfile profile, int id) {
|
public PlayerBackpack(@Nonnull PlayerProfile profile, int id) {
|
||||||
this(profile, id, profile.getConfig().getInt("backpacks." + id + ".size"));
|
this(profile, id, profile.getConfig().getInt(CONFIG_PREFIX + id + ".size"));
|
||||||
|
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
inventory.setItem(i, cfg.getItem("backpacks." + id + ".contents." + i));
|
inventory.setItem(i, cfg.getItem(CONFIG_PREFIX + id + ".contents." + i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public class PlayerBackpack {
|
|||||||
this.cfg = profile.getConfig();
|
this.cfg = profile.getConfig();
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
cfg.setValue("backpacks." + id + ".size", size);
|
cfg.setValue(CONFIG_PREFIX + id + ".size", size);
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
inventory = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]");
|
inventory = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]");
|
||||||
@ -142,7 +143,7 @@ public class PlayerBackpack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
cfg.setValue("backpacks." + id + ".size", size);
|
cfg.setValue(CONFIG_PREFIX + id + ".size", size);
|
||||||
|
|
||||||
Inventory inv = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]");
|
Inventory inv = Bukkit.createInventory(null, size, "Backpack [" + size + " Slots]");
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ public class PlayerBackpack {
|
|||||||
*/
|
*/
|
||||||
public void save() {
|
public void save() {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
cfg.setValue("backpacks." + id + ".contents." + i, inventory.getItem(i));
|
cfg.setValue(CONFIG_PREFIX + id + ".contents." + i, inventory.getItem(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||||
|
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface for any {@link SlimefunItem} to prevent
|
||||||
|
* that {@link SlimefunItem} from showing up in the {@code Items.yml} config file.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface NotConfigurable {
|
||||||
|
|
||||||
|
}
|
@ -21,6 +21,11 @@ public enum ProtectionType {
|
|||||||
/**
|
/**
|
||||||
* This damage type represents damage caused by a {@link Bee}
|
* This damage type represents damage caused by a {@link Bee}
|
||||||
*/
|
*/
|
||||||
BEES;
|
BEES,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This damage type represents damage caused by flying into a wall with an elytra
|
||||||
|
*/
|
||||||
|
FLYING_INTO_WALL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,10 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
|||||||
|
|
||||||
sendHelp(sender);
|
sendHelp(sender);
|
||||||
|
|
||||||
return true;
|
// We could just return true here, but if there's no subcommands, then
|
||||||
|
// something went horribly wrong anyway. This will also stop sonarcloud
|
||||||
|
// from nagging about this always returning true...
|
||||||
|
return !commands.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendHelp(@Nonnull CommandSender sender) {
|
public void sendHelp(@Nonnull CommandSender sender) {
|
||||||
|
@ -56,6 +56,7 @@ public final class SlimefunItems {
|
|||||||
public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances");
|
public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&bReinforced Cloth", "", "&fThis cloth has been reinforced", "&fwith &bLead &fto protect against", "&fradioactive substances");
|
||||||
public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can");
|
public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&fTin Can");
|
||||||
public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision");
|
public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&aNight Vision Goggles", "", "&9+ Night Vision");
|
||||||
|
public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5Elytra Cap", "", "&7This helmet will protect you from", "&7crashing while flying with an elytra.");
|
||||||
public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops");
|
public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&eFarmer Shoes", "", "&6&oPrevents you from trampling your Crops");
|
||||||
public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items");
|
public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&aInfused Magnet", "", "&fMagical infused Magnets", "&fattract nearby Items", "&fas long as it is somewhere in", "&fyour Inventory", "", "&7Hold &eShift&7 to pick up nearby Items");
|
||||||
public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&cRag", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "&fExtinguishes Fire", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
||||||
@ -63,7 +64,7 @@ public final class SlimefunItems {
|
|||||||
public static final SlimefunItemStack SPLINT = new SlimefunItemStack("SPLINT", Material.STICK, "&cSplint", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
public static final SlimefunItemStack SPLINT = new SlimefunItemStack("SPLINT", Material.STICK, "&cSplint", "", "&aLevel I - Medical Supply", "", "&fRestores 2 Hearts", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
||||||
public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", Material.NETHER_WART, "&cVitamins", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", Material.NETHER_WART, "&cVitamins", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation", "", LoreBuilder.RIGHT_CLICK_TO_USE);
|
||||||
public static final SlimefunItemStack MEDICINE = new SlimefunItemStack("MEDICINE", Material.POTION, Color.RED, "&cMedicine", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation");
|
public static final SlimefunItemStack MEDICINE = new SlimefunItemStack("MEDICINE", Material.POTION, Color.RED, "&cMedicine", "", "&aLevel III - Medical Supply", "", "&fRestores 4 Hearts", "&fExtinguishes Fire", "&fCures Poison/Wither/Radiation");
|
||||||
public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager to", "&7instantly cure it from its curse");
|
public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6Magical Zombie Pills", "", "&eRight Click &7a Zombified Villager", "&eor &7a Zombified Piglin to", "&7instantly cure it from its curse");
|
||||||
|
|
||||||
public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&cFlask of Knowledge", "", "&fAllows you to store some of", "&fyour Experience in a Bottle", "&7Cost: &a1 Level");
|
public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&cFlask of Knowledge", "", "&fAllows you to store some of", "&fyour Experience in a Bottle", "&7Cost: &a1 Level");
|
||||||
public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge");
|
public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&aFlask of Knowledge");
|
||||||
|
@ -66,6 +66,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListene
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
|
||||||
@ -453,6 +454,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
new EntityInteractionListener(this);
|
new EntityInteractionListener(this);
|
||||||
new MobDropListener(this);
|
new MobDropListener(this);
|
||||||
new VillagerTradingListener(this);
|
new VillagerTradingListener(this);
|
||||||
|
new ElytraCrashListener(this);
|
||||||
|
|
||||||
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
||||||
new BeeListener(this);
|
new BeeListener(this);
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra.
|
||||||
|
*
|
||||||
|
* @author Seggan
|
||||||
|
*
|
||||||
|
* @see ElytraCrashListener
|
||||||
|
*/
|
||||||
|
public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, ProtectiveArmor {
|
||||||
|
|
||||||
|
private final NamespacedKey key;
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public ElytraCap(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
|
super(category, item, recipeType, recipe, null);
|
||||||
|
|
||||||
|
key = new NamespacedKey(SlimefunPlugin.instance(), "elytra_armor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDamageable() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void damageItem(Player p, ItemStack item) {
|
||||||
|
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||||
|
DamageableItem.super.damageItem(p, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public ProtectionType[] getProtectionTypes() {
|
||||||
|
return new ProtectionType[] { ProtectionType.FLYING_INTO_WALL };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFullSetRequired() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public NamespacedKey getArmorSetId() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
@ -108,7 +108,7 @@ public class AutoDisenchanter extends AContainer {
|
|||||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(disenchantedItem, ench.getEnchantment(), 0);
|
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(disenchantedItem, ench.getEnchantment(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineRecipe recipe = new MachineRecipe(90 * amount, new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book });
|
MachineRecipe recipe = new MachineRecipe(90 * amount / this.getSpeed() , new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book });
|
||||||
|
|
||||||
if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) {
|
if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -97,7 +97,7 @@ public class AutoEnchanter extends AContainer {
|
|||||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(enchantedItem, ench.getEnchantment(), ench.getLevel());
|
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(enchantedItem, ench.getEnchantment(), ench.getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
MachineRecipe recipe = new MachineRecipe(75 * amount, new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) });
|
MachineRecipe recipe = new MachineRecipe(75 * amount / this.getSpeed(), new ItemStack[] { target, item }, new ItemStack[] { enchantedItem, new ItemStack(Material.BOOK) });
|
||||||
|
|
||||||
if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) {
|
if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.magical;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.PigZombie;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.ZombieVillager;
|
import org.bukkit.entity.ZombieVillager;
|
||||||
@ -46,22 +50,15 @@ public class MagicalZombiePills extends SimpleSlimefunItem<EntityInteractHandler
|
|||||||
public EntityInteractHandler getItemHandler() {
|
public EntityInteractHandler getItemHandler() {
|
||||||
return (e, item, offhand) -> {
|
return (e, item, offhand) -> {
|
||||||
Entity entity = e.getRightClicked();
|
Entity entity = e.getRightClicked();
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (entity.getType() == EntityType.ZOMBIE_VILLAGER) {
|
if (entity instanceof ZombieVillager) {
|
||||||
Player p = e.getPlayer();
|
useItem(p);
|
||||||
|
healZombieVillager((ZombieVillager) entity, p);
|
||||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
}
|
||||||
ItemUtils.consumeItem(item, false);
|
else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie) {
|
||||||
}
|
useItem(p);
|
||||||
|
healZombifiedPiglin((PigZombie) entity);
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1, 1);
|
|
||||||
|
|
||||||
ZombieVillager zombieVillager = (ZombieVillager) entity;
|
|
||||||
zombieVillager.setConversionTime(1);
|
|
||||||
|
|
||||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
|
||||||
zombieVillager.setConversionPlayer(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -74,4 +71,27 @@ public class MagicalZombiePills extends SimpleSlimefunItem<EntityInteractHandler
|
|||||||
public ItemUseHandler onRightClick() {
|
public ItemUseHandler onRightClick() {
|
||||||
return PlayerRightClickEvent::cancel;
|
return PlayerRightClickEvent::cancel;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void useItem(@Nonnull Player p) {
|
||||||
|
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||||
|
ItemUtils.consumeItem(item, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void healZombieVillager(@Nonnull ZombieVillager zombieVillager, @Nonnull Player p) {
|
||||||
|
zombieVillager.setConversionTime(1);
|
||||||
|
|
||||||
|
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
||||||
|
zombieVillager.setConversionPlayer(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void healZombifiedPiglin(@Nonnull PigZombie zombiePiglin) {
|
||||||
|
Location loc = zombiePiglin.getLocation();
|
||||||
|
|
||||||
|
zombiePiglin.remove();
|
||||||
|
loc.getWorld().spawnEntity(loc, EntityType.PIGLIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,9 +17,13 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter;
|
import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link TableSaw} is an implementation of a {@link MultiBlockMachine} that allows
|
* The {@link TableSaw} is an implementation of a {@link MultiBlockMachine} that allows
|
||||||
* you to turn Logs into Wooden Planks.
|
* you to turn Logs into Wooden Planks.
|
||||||
@ -27,6 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* It also replaced the old "Saw Mill" from earlier versions.
|
* It also replaced the old "Saw Mill" from earlier versions.
|
||||||
*
|
*
|
||||||
* @author dniym
|
* @author dniym
|
||||||
|
* @author svr333
|
||||||
*
|
*
|
||||||
* @see MultiBlockMachine
|
* @see MultiBlockMachine
|
||||||
*
|
*
|
||||||
@ -46,6 +51,11 @@ public class TableSaw extends MultiBlockMachine {
|
|||||||
displayedRecipes.add(new ItemStack(planks.get(), 8));
|
displayedRecipes.add(new ItemStack(planks.get(), 8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Material plank : Tag.PLANKS.getValues()) {
|
||||||
|
displayedRecipes.add(new ItemStack(plank));
|
||||||
|
displayedRecipes.add(new ItemStack(Material.STICK, 4));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,28 +64,50 @@ public class TableSaw extends MultiBlockMachine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteract(Player p, Block b) {
|
public void onInteract(@Nonnull Player p, @Nonnull Block b) {
|
||||||
ItemStack log = p.getInventory().getItemInMainHand();
|
ItemStack item = p.getInventory().getItemInMainHand();
|
||||||
|
ItemStack output = getItemsToOutput(item.getType());
|
||||||
|
|
||||||
Optional<Material> planks = MaterialConverter.getPlanksFromLog(log.getType());
|
if (output == null) {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (planks.isPresent()) {
|
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
ItemUtils.consumeItem(item, true);
|
||||||
ItemUtils.consumeItem(log, true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack output = new ItemStack(planks.get(), 8);
|
outputItems(b, output);
|
||||||
Inventory outputChest = findOutputChest(b, output);
|
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType());
|
||||||
|
}
|
||||||
|
|
||||||
if (outputChest != null) {
|
@Nullable
|
||||||
outputChest.addItem(output);
|
private ItemStack getItemsToOutput(@Nonnull Material item) {
|
||||||
|
if (Tag.LOGS.isTagged(item)) {
|
||||||
|
Optional<Material> planks = MaterialConverter.getPlanksFromLog(item);
|
||||||
|
if (planks.isPresent()) {
|
||||||
|
return new ItemStack(planks.get(), 8);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
b.getWorld().dropItemNaturally(b.getLocation(), output);
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, log.getType());
|
else if (Tag.PLANKS.isTagged(item)) {
|
||||||
|
return new ItemStack(Material.STICK, 4);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void outputItems(@Nonnull Block b, @Nonnull ItemStack output) {
|
||||||
|
Inventory outputChest = findOutputChest(b, output);
|
||||||
|
|
||||||
|
if (outputChest != null) {
|
||||||
|
outputChest.addItem(output);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b.getWorld().dropItemNaturally(b.getLocation(), output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.tools;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
@ -12,19 +14,33 @@ import org.bukkit.potion.PotionEffect;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link GrapplingHook} is a simple {@link SlimefunItem} which allows a {@link Player}
|
||||||
|
* to launch towards a target destination via right click.
|
||||||
|
* It also has a cool visual effect where it shows a leash following a fired {@link Arrow}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see GrapplingHookListener
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
||||||
|
|
||||||
private final ItemSetting<Boolean> consumeOnUse = new ItemSetting<>("consume-on-use", true);
|
private final ItemSetting<Boolean> consumeOnUse = new ItemSetting<>("consume-on-use", true);
|
||||||
private final ItemSetting<Integer> despawnTicks = new ItemSetting<>("despawn-seconds", 60);
|
private final ItemSetting<Integer> despawnTicks = new ItemSetting<>("despawn-seconds", 60);
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public GrapplingHook(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
|
||||||
@ -37,7 +53,7 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
return e -> {
|
return e -> {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
boolean consumeOnUseValue = consumeOnUse.getValue();
|
boolean isConsumed = consumeOnUse.getValue();
|
||||||
|
|
||||||
if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) {
|
if (!e.getClickedBlock().isPresent() && !SlimefunPlugin.getGrapplingHookListener().isGrappling(uuid)) {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
@ -49,11 +65,9 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
|
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
|
|
||||||
if (item.getType() == Material.LEAD) {
|
if (item.getType() == Material.LEAD && isConsumed) {
|
||||||
//If consume on use is enabled, the if statement below will take 1 grappling hook out of player's hand
|
// If consume on use is enabled, consume one item
|
||||||
if (consumeOnUseValue) {
|
ItemUtils.consumeItem(item, false);
|
||||||
item.setAmount(item.getAmount() - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
|
Vector direction = p.getEyeLocation().getDirection().multiply(2.0);
|
||||||
@ -69,7 +83,7 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemUseHandler> {
|
|||||||
bat.setLeashHolder(arrow);
|
bat.setLeashHolder(arrow);
|
||||||
|
|
||||||
boolean state = item.getType() != Material.SHEARS;
|
boolean state = item.getType() != Material.SHEARS;
|
||||||
SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), consumeOnUseValue);
|
SlimefunPlugin.getGrapplingHookListener().addGrapplingHook(p, arrow, bat, state, despawnTicks.getValue(), isConsumed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,6 @@ public class TapeMeasure extends SimpleSlimefunItem<ItemUseHandler> implements N
|
|||||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.anchor-set", msg -> msg.replace("%anchor%", anchor));
|
SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.anchor-set", msg -> msg.replace("%anchor%", anchor));
|
||||||
|
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Listener} for the {@link ElytraCap}.
|
||||||
|
*
|
||||||
|
* @author Seggan
|
||||||
|
*
|
||||||
|
* @see ElytraCap
|
||||||
|
*/
|
||||||
|
public class ElytraCrashListener implements Listener {
|
||||||
|
|
||||||
|
public ElytraCrashListener(@Nonnull SlimefunPlugin plugin) {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerCrash(EntityDamageEvent e) {
|
||||||
|
if (!(e.getEntity() instanceof Player)) {
|
||||||
|
// We only wanna handle damaged Players
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL) {
|
||||||
|
Player p = (Player) e.getEntity();
|
||||||
|
|
||||||
|
if (p.isGliding()) {
|
||||||
|
Optional<PlayerProfile> optional = PlayerProfile.find(p);
|
||||||
|
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
PlayerProfile.request(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerProfile profile = optional.get();
|
||||||
|
Optional<SlimefunArmorPiece> helmet = profile.getArmor()[0].getItem();
|
||||||
|
|
||||||
|
if (helmet.isPresent()) {
|
||||||
|
SlimefunItem item = helmet.get();
|
||||||
|
|
||||||
|
if (Slimefun.hasUnlocked(p, item, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) {
|
||||||
|
e.setDamage(0);
|
||||||
|
p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1);
|
||||||
|
|
||||||
|
if (item instanceof DamageableItem) {
|
||||||
|
((DamageableItem) item).damageItem(p, p.getInventory().getHelmet());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,12 +33,10 @@ final class GrapplingHookEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drop(@Nonnull Location l) {
|
public void drop(@Nonnull Location l) {
|
||||||
if (dropItem) {
|
// If a grappling hook was consumed, drop one grappling hook on the floor
|
||||||
//If a grappling hook was consumed, then the below if statement will be executed and will drop one grappling hook on the floor
|
if (dropItem && wasConsumed) {
|
||||||
if (wasConsumed) {
|
Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone());
|
||||||
Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone());
|
item.setPickupDelay(16);
|
||||||
item.setPickupDelay(16);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event.Result;
|
import org.bukkit.event.Event.Result;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -11,6 +12,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||||
@ -45,23 +47,23 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
public void onInteract(PlayerRightClickEvent e) {
|
public void onInteract(PlayerRightClickEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (openGuide(e, SlimefunGuideLayout.BOOK) == Result.ALLOW) {
|
if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SlimefunGuide.openGuide(p, SlimefunGuideLayout.BOOK);
|
openGuide(p, e, SlimefunGuideLayout.BOOK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (openGuide(e, SlimefunGuideLayout.CHEST) == Result.ALLOW) {
|
else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SlimefunGuide.openGuide(p, SlimefunGuideLayout.CHEST);
|
openGuide(p, e, SlimefunGuideLayout.CHEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (openGuide(e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) {
|
else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
}
|
}
|
||||||
@ -72,16 +74,24 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
||||||
|
SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
e.cancel();
|
||||||
|
SlimefunGuide.openGuide(p, event.getGuideLayout());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private Result openGuide(PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
||||||
Player p = e.getPlayer();
|
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
|
|
||||||
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
||||||
e.cancel();
|
|
||||||
|
|
||||||
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-item", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-item", true);
|
||||||
return Result.DENY;
|
return Result.DENY;
|
||||||
|
@ -286,7 +286,8 @@ public final class ResearchSetup {
|
|||||||
register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK);
|
register("climbing_pick", 265, "Block Raider", 20, SlimefunItems.CLIMBING_PICK);
|
||||||
register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR);
|
register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR);
|
||||||
register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN);
|
register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN);
|
||||||
register("energy_connectors", 268, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
|
register("elytra_cap", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP);
|
||||||
|
register("energy_connectors", 269, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
|
||||||
|
|
||||||
plugin = null;
|
plugin = null;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAn
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.WoodcutterAndroid;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.WoodcutterAndroid;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute;
|
||||||
@ -133,11 +134,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Knowledge
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundRune;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundRune;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.StormStaff;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.StormStaff;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WaterStaff;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WaterStaff;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WindStaff;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WindStaff;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman;
|
||||||
@ -3079,6 +3080,10 @@ public final class SlimefunItemSetup {
|
|||||||
new SlimefunItemStack(SlimefunItems.VILLAGER_RUNE, 3))
|
new SlimefunItemStack(SlimefunItems.VILLAGER_RUNE, 3))
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new ElytraCap(categories.magicalArmor, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE,
|
||||||
|
new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)})
|
||||||
|
.register(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) {
|
private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) {
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -30,6 +31,7 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemExcepti
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
|
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
||||||
@ -360,15 +362,18 @@ public class SlimefunItem implements Placeable {
|
|||||||
SlimefunPlugin.getRegistry().getAllSlimefunItems().add(this);
|
SlimefunPlugin.getRegistry().getAllSlimefunItems().add(this);
|
||||||
SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this);
|
SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this);
|
||||||
|
|
||||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".enabled", true);
|
// Items that are "not-configurable" cannot be configured.
|
||||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench);
|
if (!(this instanceof NotConfigurable)) {
|
||||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden);
|
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".enabled", true);
|
||||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable);
|
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench);
|
||||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable);
|
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden);
|
||||||
|
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable);
|
||||||
|
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable);
|
||||||
|
|
||||||
// Load all item settings
|
// Load all item settings
|
||||||
for (ItemSetting<?> setting : itemSettings) {
|
for (ItemSetting<?> setting : itemSettings) {
|
||||||
setting.load(this);
|
setting.load(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticking && !SlimefunPlugin.getCfg().getBoolean("URID.enable-tickers")) {
|
if (ticking && !SlimefunPlugin.getCfg().getBoolean("URID.enable-tickers")) {
|
||||||
@ -376,26 +381,17 @@ public class SlimefunItem implements Placeable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this instanceof Radioactive) {
|
if (this instanceof NotConfigurable) {
|
||||||
SlimefunPlugin.getRegistry().getRadioactiveItems().add(this);
|
// Not-configurable items will be enabled.
|
||||||
}
|
// Any other settings will remain as default.
|
||||||
|
state = ItemState.ENABLED;
|
||||||
if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) {
|
}
|
||||||
|
else if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) {
|
||||||
if (!category.isRegistered()) {
|
|
||||||
category.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
state = ItemState.ENABLED;
|
state = ItemState.ENABLED;
|
||||||
checkForDeprecations(getClass());
|
|
||||||
|
|
||||||
useableInWorkbench = SlimefunPlugin.getItemCfg().getBoolean(id + ".can-be-used-in-workbenches");
|
useableInWorkbench = SlimefunPlugin.getItemCfg().getBoolean(id + ".can-be-used-in-workbenches");
|
||||||
hidden = SlimefunPlugin.getItemCfg().getBoolean(id + ".hide-in-guide");
|
hidden = SlimefunPlugin.getItemCfg().getBoolean(id + ".hide-in-guide");
|
||||||
enchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-enchanting");
|
enchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-enchanting");
|
||||||
disenchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-disenchanting");
|
disenchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-disenchanting");
|
||||||
|
|
||||||
SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this);
|
|
||||||
loadItemHandlers();
|
|
||||||
}
|
}
|
||||||
else if (this instanceof VanillaItem) {
|
else if (this instanceof VanillaItem) {
|
||||||
state = ItemState.VANILLA_FALLBACK;
|
state = ItemState.VANILLA_FALLBACK;
|
||||||
@ -404,19 +400,53 @@ public class SlimefunItem implements Placeable {
|
|||||||
state = ItemState.DISABLED;
|
state = ItemState.DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now we can be certain this item should be enabled
|
||||||
|
if (state == ItemState.ENABLED) {
|
||||||
|
onEnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lock the SlimefunItemStack from any accidental manipulations
|
||||||
if (item instanceof SlimefunItemStack && isItemStackImmutable()) {
|
if (item instanceof SlimefunItemStack && isItemStackImmutable()) {
|
||||||
((SlimefunItemStack) item).lock();
|
((SlimefunItemStack) item).lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
postRegister();
|
postRegister();
|
||||||
|
|
||||||
|
// handle runtime-registrations / auto-loading
|
||||||
if (SlimefunPlugin.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) {
|
if (SlimefunPlugin.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) {
|
||||||
info("Item was registered during runtime.");
|
info("Item was registered during runtime.");
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception x) {
|
catch (Exception x) {
|
||||||
error("Registering " + toString() + " has failed", x);
|
error("Registering " + toString() + " has failed!", x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when this {@link SlimefunItem} is currently being registered
|
||||||
|
* and we are certain that it will be enabled.
|
||||||
|
*
|
||||||
|
* <strong>This method is for internal purposes, like {@link Category} registration only</strong>
|
||||||
|
*/
|
||||||
|
private final void onEnable() {
|
||||||
|
// Register the Category too if it hasn't been registered yet
|
||||||
|
if (!category.isRegistered()) {
|
||||||
|
category.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send out deprecation warnings for any classes or intefaces
|
||||||
|
checkForDeprecations(getClass());
|
||||||
|
|
||||||
|
// Add it to the list of enabled items
|
||||||
|
SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this);
|
||||||
|
|
||||||
|
// Load our Item Handlers
|
||||||
|
loadItemHandlers();
|
||||||
|
|
||||||
|
// Properly mark this Item as radioactive
|
||||||
|
if (this instanceof Radioactive) {
|
||||||
|
SlimefunPlugin.getRegistry().getRadioactiveItems().add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,9 +461,10 @@ public class SlimefunItem implements Placeable {
|
|||||||
// Make developers or at least Server admins aware that
|
// Make developers or at least Server admins aware that
|
||||||
// an Item is using a deprecated ItemHandler
|
// an Item is using a deprecated ItemHandler
|
||||||
checkForDeprecations(handler.getClass());
|
checkForDeprecations(handler.getClass());
|
||||||
// A bit too spammy atm, will enable it again later
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If this ItemHandler is "public" (not bound to this SlimefunItem),
|
||||||
|
// we add it to the list of public Item handlers
|
||||||
if (!handler.isPrivate()) {
|
if (!handler.isPrivate()) {
|
||||||
Set<ItemHandler> handlerset = getPublicItemHandlers(handler.getIdentifier());
|
Set<ItemHandler> handlerset = getPublicItemHandlers(handler.getIdentifier());
|
||||||
handlerset.add(handler);
|
handlerset.add(handler);
|
||||||
@ -464,7 +495,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
* @param c
|
* @param c
|
||||||
* The {@link Class} from which to start this operation.
|
* The {@link Class} from which to start this operation.
|
||||||
*/
|
*/
|
||||||
private void checkForDeprecations(Class<?> c) {
|
private void checkForDeprecations(@Nullable Class<?> c) {
|
||||||
if (SlimefunPlugin.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) {
|
if (SlimefunPlugin.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) {
|
||||||
// This method is currently way too spammy with all the restructuring going on...
|
// This method is currently way too spammy with all the restructuring going on...
|
||||||
// Since DEV builds are anyway under "development", things may be relocated.
|
// Since DEV builds are anyway under "development", things may be relocated.
|
||||||
@ -526,6 +557,12 @@ public class SlimefunItem implements Placeable {
|
|||||||
this.recipeType = type;
|
this.recipeType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets the {@link Category} in which this {@link SlimefunItem} will be displayed.
|
||||||
|
*
|
||||||
|
* @param category
|
||||||
|
* The new {@link Category}
|
||||||
|
*/
|
||||||
public void setCategory(@Nonnull Category category) {
|
public void setCategory(@Nonnull Category category) {
|
||||||
Validate.notNull(category, "The Category is not allowed to be null!");
|
Validate.notNull(category, "The Category is not allowed to be null!");
|
||||||
|
|
||||||
@ -590,6 +627,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the given item is a SlimefunitemStack, simply compare the id
|
||||||
if (item instanceof SlimefunItemStack) {
|
if (item instanceof SlimefunItemStack) {
|
||||||
return getID().equals(((SlimefunItemStack) item).getItemId());
|
return getID().equals(((SlimefunItemStack) item).getItemId());
|
||||||
}
|
}
|
||||||
@ -670,6 +708,10 @@ public class SlimefunItem implements Placeable {
|
|||||||
throw new UnsupportedOperationException("You cannot add an ItemSetting after the SlimefunItem was registered.");
|
throw new UnsupportedOperationException("You cannot add an ItemSetting after the SlimefunItem was registered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this instanceof NotConfigurable) {
|
||||||
|
throw new UnsupportedOperationException("This Item has been marked as NotConfigurable and cannot accept Item Settings!");
|
||||||
|
}
|
||||||
|
|
||||||
for (ItemSetting<?> setting : settings) {
|
for (ItemSetting<?> setting : settings) {
|
||||||
if (setting != null) {
|
if (setting != null) {
|
||||||
// Prevent two Item Settings with the same key
|
// Prevent two Item Settings with the same key
|
||||||
@ -817,12 +859,28 @@ public class SlimefunItem implements Placeable {
|
|||||||
return getDrops();
|
return getDrops();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void info(String message) {
|
/**
|
||||||
|
* This will send an info message to the console and signal that this message came
|
||||||
|
* from this {@link SlimefunItem}, the message will be sent using the {@link Logger}
|
||||||
|
* of the {@link SlimefunAddon} which registered this {@link SlimefunItem}.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* The message to send
|
||||||
|
*/
|
||||||
|
public void info(@Nonnull String message) {
|
||||||
String msg = toString() + ": " + message;
|
String msg = toString() + ": " + message;
|
||||||
addon.getLogger().log(Level.INFO, msg);
|
addon.getLogger().log(Level.INFO, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void warn(String message) {
|
/**
|
||||||
|
* This will send a warning to the console and signal that this warning came from
|
||||||
|
* this {@link SlimefunItem}, the warning will be sent using the {@link Logger}
|
||||||
|
* of the {@link SlimefunAddon} which registered this {@link SlimefunItem}.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* The message to send
|
||||||
|
*/
|
||||||
|
public void warn(@Nonnull String message) {
|
||||||
String msg = toString() + ": " + message;
|
String msg = toString() + ": " + message;
|
||||||
addon.getLogger().log(Level.WARNING, msg);
|
addon.getLogger().log(Level.WARNING, msg);
|
||||||
|
|
||||||
@ -841,7 +899,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
* @param throwable
|
* @param throwable
|
||||||
* The {@link Throwable} to throw as a stacktrace.
|
* The {@link Throwable} to throw as a stacktrace.
|
||||||
*/
|
*/
|
||||||
public void error(String message, Throwable throwable) {
|
public void error(@Nonnull String message, @Nonnull Throwable throwable) {
|
||||||
addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[] { id, addon.getName(), addon.getPluginVersion() });
|
addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[] { id, addon.getName(), addon.getPluginVersion() });
|
||||||
|
|
||||||
if (addon.getBugTrackerURL() != null) {
|
if (addon.getBugTrackerURL() != null) {
|
||||||
|
@ -128,6 +128,7 @@ public class DirtyChestMenu extends ChestMenu {
|
|||||||
if (ItemUtils.canStack(wrapper, stack)) {
|
if (ItemUtils.canStack(wrapper, stack)) {
|
||||||
amount -= (stack.getMaxStackSize() - stack.getAmount());
|
amount -= (stack.getMaxStackSize() - stack.getAmount());
|
||||||
stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize()));
|
stack.setAmount(Math.min(stack.getAmount() + item.getAmount(), stack.getMaxStackSize()));
|
||||||
|
item.setAmount(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,3 +245,4 @@ slimefun:
|
|||||||
tape_measure: Tape Measure
|
tape_measure: Tape Measure
|
||||||
iron_golem_assembler: Automated Iron Golems
|
iron_golem_assembler: Automated Iron Golems
|
||||||
villager_rune: Reset Villager Trades
|
villager_rune: Reset Villager Trades
|
||||||
|
elytra_cap: Crash Gear
|
||||||
|
@ -99,5 +99,149 @@
|
|||||||
"ORE_CRUSHER" : "Ore-Crusher",
|
"ORE_CRUSHER" : "Ore-Crusher",
|
||||||
"PRESSURE_CHAMBER" : "Pressure-Chamber",
|
"PRESSURE_CHAMBER" : "Pressure-Chamber",
|
||||||
"GRIND_STONE" : "Grind-Stone",
|
"GRIND_STONE" : "Grind-Stone",
|
||||||
"MAGIC_WORKBENCH" : "Magic-Workbench"
|
"MAGIC_WORKBENCH" : "Magic-Workbench",
|
||||||
|
"PORTABLE_CRAFTER" : "Portable-Crafter",
|
||||||
|
"PORTABLE_DUSTBIN" : "Portable-Dustbin",
|
||||||
|
"COOLER" : "Cooler",
|
||||||
|
"ALUMINUM_BRASS_INGOT" : "Aluminum-Brass-Ingot",
|
||||||
|
"ALUMINUM_BRONZE_INGOT" : "Aluminum-Bronze-Ingot",
|
||||||
|
"ALUMINUM_DUST" : "Aluminum-Dust",
|
||||||
|
"ALUMINUM_INGOT" : "Aluminum-Ingot",
|
||||||
|
"GLOWSTONE_HELMET" : "Magical-Armor",
|
||||||
|
"GLOWSTONE_CHESTPLATE" : "Magical-Armor",
|
||||||
|
"GLOWSTONE_LEGGINGS" : "Magical-Armor",
|
||||||
|
"GLOWSTONE_BOOTS" : "Magical-Armor",
|
||||||
|
"ENDER_HELMET" : "Magical-Armor",
|
||||||
|
"ENDER_CHESTPLATE" : "Magical-Armor",
|
||||||
|
"ENDER_LEGGINGS" : "Magical-Armor",
|
||||||
|
"ENDER_BOOTS" : "Magical-Armor",
|
||||||
|
"SLIME_HELMET" : "Magical-Armor",
|
||||||
|
"SLIME_CHESTPLATE" : "Magical-Armor",
|
||||||
|
"SLIME_LEGGINGS" : "Magical-Armor",
|
||||||
|
"SLIME_BOOTS" : "Magical-Armor",
|
||||||
|
"CACTUS_HELMET" : "Armor",
|
||||||
|
"CACTUS_CHESTPLATE" : "Armor",
|
||||||
|
"CACTUS_LEGGINGS" : "Armor",
|
||||||
|
"CACTUS_BOOTS" : "Armor",
|
||||||
|
"DAMASCUS_STEEL_HELMET" : "Armor",
|
||||||
|
"DAMASCUS_STEEL_CHESTPLATE" : "Armor",
|
||||||
|
"DAMASCUS_STEEL_LEGGINGS" : "Armor",
|
||||||
|
"DAMASCUS_STEEL_BOOTS" : "Armor",
|
||||||
|
"REINFORCED_ALLOY_HELMET" : "Armor",
|
||||||
|
"REINFORCED_ALLOY_CHESTPLATE" : "Armor",
|
||||||
|
"REINFORCED_ALLOY_LEGGINGS" : "Armor",
|
||||||
|
"REINFORCED_ALLOY_BOOTS" : "Armor",
|
||||||
|
"GILDED_IRON_HELMET" : "Armor",
|
||||||
|
"GILDED_IRON_CHESTPLATE" : "Armor",
|
||||||
|
"GILDED_IRON_LEGGINGS" : "Armor",
|
||||||
|
"GILDED_IRON_BOOTS" : "Armor",
|
||||||
|
"GOLD_12K_HELMET" : "Armor",
|
||||||
|
"GOLD_12K_CHESTPLATE" : "Armor",
|
||||||
|
"GOLD_12K_LEGGINGS" : "Armor",
|
||||||
|
"GOLD_12K_BOOTS" : "Armor",
|
||||||
|
"SLIME_STEEL_HELMET" : "Magical-Armor",
|
||||||
|
"SLIME_STEEL_CHESTPLATE" : "Magical-Armor",
|
||||||
|
"SLIME_STEEL_LEGGINGS" : "Magical-Armor",
|
||||||
|
"SLIME_STEEL_BOOTS" : "Magical-Armor",
|
||||||
|
"BILLON_INGOT" : "Billon-Ingot",
|
||||||
|
"BLOCK_PLACER" : "Block-Placer",
|
||||||
|
"EXPLOSIVE_BOW" : "Bows",
|
||||||
|
"ICY_BOW" : "Bows",
|
||||||
|
"BRASS_INGOT" : "Brass-Ingot",
|
||||||
|
"BRONZE_INGOT" : "Bronze-Ingot",
|
||||||
|
"CHRISTMAS_MILK" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_CHOCOLATE_MILK" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_EGG_NOG" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_APPLE_CIDER" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_COOKIE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_FRUIT_CAKE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_APPLE_PIE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_HOT_CHOCOLATE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_CAKE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_CARAMEL" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_CARAMEL_APPLE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_CHOCOLATE_APPLE" : "Christmas-Items",
|
||||||
|
"CHRISTMAS_PRESENT" : "Christmas-Items",
|
||||||
|
"RAINBOW_WOOL_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"RAINBOW_GLASS_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"RAINBOW_CLAY_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"RAINBOW_GLASS_PANE_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"RAINBOW_CONCRETE_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"RAINBOW_GLAZED_TERRACOTTA_XMAS" : "Christmas-Seasonal-Category",
|
||||||
|
"COBALT_INGOT" : "Cobalt-Ingot",
|
||||||
|
"COPPER_DUST" : "Copper-Dust",
|
||||||
|
"COPPER_INGOT" : "Copper-Ingot",
|
||||||
|
"CORINTHIAN_BRONZE_INGOT" : "Corinthian-Bronze-Ingot",
|
||||||
|
"DAMASCUS_STEEL_INGOT" : "Damascus-Steel-Ingot",
|
||||||
|
"DURALUMIN_INGOT" : "Duralumin-Ingot",
|
||||||
|
"ELEVATOR_PLATE" : "Elevator-Plate",
|
||||||
|
"ELYTRA_SCALE" : "Elytras",
|
||||||
|
"INFUSED_ELYTRA" : "Elytras",
|
||||||
|
"SOULBOUND_ELYTRA" : "Elytras",
|
||||||
|
"ENHANCED_FURNACE" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_2" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_3" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_4" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_5" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_6" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_7" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_8" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_9" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_10" : "Enhanced-Furnaces",
|
||||||
|
"ENHANCED_FURNACE_11" : "Enhanced-Furnaces",
|
||||||
|
"REINFORCED_FURNACE" : "Enhanced-Furnaces",
|
||||||
|
"CARBONADO_EDGED_FURNACE" : "Enhanced-Furnaces",
|
||||||
|
"FERROSILICON" : "Ferrosilicon",
|
||||||
|
"GEO_MINER" : "GEO-Miner",
|
||||||
|
"GPS_ACTIVATION_DEVICE_SHARED" : "GPS-Activation-Device",
|
||||||
|
"GPS_ACTIVATION_DEVICE_PERSONAL" : "GPS-Activation-Device",
|
||||||
|
"GPS_CONTROL_PANEL" : "GPS-Control-Panel",
|
||||||
|
"GPS_EMERGENCY_TRANSMITTER" : "GPS-Emergency-Transmitter",
|
||||||
|
"GPS_GEO_SCANNER" : "GPS-Geo-Scanner",
|
||||||
|
"GPS_MARKER_TOOL" : "GPS-Marker-Tool",
|
||||||
|
"GPS_TELEPORTATION_MATRIX" : "GPS-Teleporter-Matrix",
|
||||||
|
"GPS_TELEPORTER_PYLON" : "GPS-Teleporter-Pylon",
|
||||||
|
"GPS_TRANSMITTER" : "GPS-Transmitter",
|
||||||
|
"GILDED_IRON" : "Gilded-Iron",
|
||||||
|
"HARDENED_METAL_INGOT" : "Hardened-Metal",
|
||||||
|
"LEAD_DUST" : "Lead-Dust",
|
||||||
|
"LEAD_INGOT" : "Lead-Ingot",
|
||||||
|
"MAGNESIUM_DUST" : "Magnesium-Dust",
|
||||||
|
"MAGNESIUM_INGOT" : "Magnesium-Ingot",
|
||||||
|
"NICKEL_INGOT" : "Nickel-Ingot",
|
||||||
|
"OIL_PUMP" : "Oil-Pump",
|
||||||
|
"PORTABLE_GEO_SCANNER" : "Portable-Geo-Scanner",
|
||||||
|
"RAINBOW_WOOL" : "Rainbow-Blocks",
|
||||||
|
"RAINBOW_GLASS" : "Rainbow-Blocks",
|
||||||
|
"RAINBOW_CLAY" : "Rainbow-Blocks",
|
||||||
|
"RAINBOW_GLASS_PANE" : "Rainbow-Blocks",
|
||||||
|
"RAINBOW_CONCRETE" : "Rainbow-Blocks",
|
||||||
|
"RAINBOW_GLAZED_TERRACOTTA" : "Rainbow-Blocks",
|
||||||
|
"REDSTONE_ALLOY" : "Redstone-Alloy-Ingot",
|
||||||
|
"REINFORCED_ALLOY_INGOT" : "Reinforced-Alloy-Ingot",
|
||||||
|
"SILVER_DUST" : "Silver-Dust",
|
||||||
|
"SILVER_INGOT" : "Silver-Ingot",
|
||||||
|
"SOLDER_INGOT" : "Solder-Ingot",
|
||||||
|
"SOULBOUND_HELMET" : "Soulbound-Armor",
|
||||||
|
"SOULBOUND_CHESTPLATE" : "Soulbound-Armor",
|
||||||
|
"SOULBOUND_LEGGINGS" : "Soulbound-Armor",
|
||||||
|
"SOULBOUND_BOOTS" : "Soulbound-Armor",
|
||||||
|
"ANCIENT_RUNE_SOULBOUND" : "Soulbound-Rune",
|
||||||
|
"SOULBOUND_SWORD" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_BOW" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_PICKAXE" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_AXE" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_SHOVEL" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_HOE" : "Soulbound-Weapons",
|
||||||
|
"SOULBOUND_TRIDENT" : "Soulbound-Weapons",
|
||||||
|
"STEEL_INGOT" : "Steel-Ingot",
|
||||||
|
"SWORD_OF_BEHEADING" : "Sword-of-Beheading",
|
||||||
|
"COMMON_TALISMAN" : "Talismans",
|
||||||
|
"ENDER_TALISMAN" : "Talismans",
|
||||||
|
"TIN_DUST" : "Tin-Dust",
|
||||||
|
"TIN_INGOT" : "Tin-Ingot",
|
||||||
|
"GRANDMAS_WALKING_STICK" : "Walking-Sticks",
|
||||||
|
"GRANDPAS_WALKING_STICK" : "Walking-Sticks",
|
||||||
|
"ZINC_DUST" : "Zinc-Dust",
|
||||||
|
"ZINC_INGOT" : "Zinc-Ingot"
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.testing;
|
package io.github.thebusybiscuit.slimefun4.testing;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
import static org.mockito.Mockito.when;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import java.util.concurrent.TimeUnit;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import io.github.thebusybiscuit.slimefun4.testing.mocks.MockSlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import javax.annotation.Nonnull;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -19,11 +18,14 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import java.util.concurrent.TimeUnit;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||||
import static org.mockito.Mockito.when;
|
import io.github.thebusybiscuit.slimefun4.testing.mocks.MockSlimefunItem;
|
||||||
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
public final class TestUtilities {
|
public final class TestUtilities {
|
||||||
|
|
||||||
@ -55,7 +57,8 @@ public final class TestUtilities {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerProfile awaitProfile(OfflinePlayer player) throws InterruptedException {
|
@Nonnull
|
||||||
|
public static PlayerProfile awaitProfile(@Nonnull OfflinePlayer player) throws InterruptedException {
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
AtomicReference<PlayerProfile> ref = new AtomicReference<>();
|
AtomicReference<PlayerProfile> ref = new AtomicReference<>();
|
||||||
|
|
||||||
@ -68,64 +71,4 @@ public final class TestUtilities {
|
|||||||
latch.await(2, TimeUnit.SECONDS);
|
latch.await(2, TimeUnit.SECONDS);
|
||||||
return ref.get();
|
return ref.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerDefaultTags(ServerMock server) {
|
|
||||||
// We really don't need these to be accurate, just fill them with some examples
|
|
||||||
// that approximate the actual content
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("logs"), Material.OAK_LOG,
|
|
||||||
Material.STRIPPED_OAK_LOG, Material.OAK_WOOD, Material.STRIPPED_OAK_WOOD,
|
|
||||||
Material.ACACIA_LOG, Material.STRIPPED_ACACIA_LOG, Material.ACACIA_WOOD, Material.STRIPPED_ACACIA_WOOD
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_trapdoors"), Material.OAK_TRAPDOOR,
|
|
||||||
Material.BIRCH_TRAPDOOR, Material.SPRUCE_TRAPDOOR, Material.JUNGLE_TRAPDOOR,
|
|
||||||
Material.ACACIA_TRAPDOOR, Material.DARK_OAK_TRAPDOOR
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_slabs"), Material.OAK_SLAB, Material.BIRCH_SLAB,
|
|
||||||
Material.JUNGLE_SLAB, Material.SPRUCE_SLAB, Material.ACACIA_SLAB, Material.DARK_OAK_SLAB
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_fences"), Material.OAK_FENCE, Material.BIRCH_FENCE,
|
|
||||||
Material.JUNGLE_FENCE, Material.SPRUCE_FENCE, Material.ACACIA_FENCE, Material.DARK_OAK_FENCE
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("planks"), Material.OAK_PLANKS, Material.BIRCH_PLANKS,
|
|
||||||
Material.SPRUCE_PLANKS, Material.JUNGLE_PLANKS, Material.ACACIA_PLANKS, Material.DARK_OAK_PLANKS
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("small_flowers"), Material.POPPY, Material.DANDELION,
|
|
||||||
Material.AZURE_BLUET, Material.LILY_OF_THE_VALLEY
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("leaves"), Material.OAK_LEAVES, Material.BIRCH_LEAVES,
|
|
||||||
Material.SPRUCE_LEAVES, Material.JUNGLE_LEAVES, Material.ACACIA_LEAVES, Material.DARK_OAK_LEAVES
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("saplings"), Material.OAK_SAPLING, Material.BIRCH_SAPLING,
|
|
||||||
Material.SPRUCE_SAPLING, Material.JUNGLE_SAPLING, Material.ACACIA_SAPLING, Material.DARK_OAK_SAPLING
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("coral_blocks"), Material.BRAIN_CORAL_BLOCK,
|
|
||||||
Material.BUBBLE_CORAL_BLOCK, Material.FIRE_CORAL_BLOCK, Material.HORN_CORAL_BLOCK, Material.TUBE_CORAL_BLOCK
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("corals"), Material.BRAIN_CORAL, Material.BUBBLE_CORAL,
|
|
||||||
Material.FIRE_CORAL, Material.HORN_CORAL, Material.TUBE_CORAL
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("ice"), Material.ICE, Material.PACKED_ICE,
|
|
||||||
Material.FROSTED_ICE, Material.BLUE_ICE
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("fire"), Material.FIRE, Material.SOUL_FIRE);
|
|
||||||
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("boats"), Material.BIRCH_BOAT, Material.ACACIA_BOAT,
|
|
||||||
Material.DARK_OAK_BOAT, Material.JUNGLE_BOAT, Material.OAK_BOAT, Material.SPRUCE_BOAT
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_buttons"), Material.BIRCH_BUTTON,
|
|
||||||
Material.ACACIA_BUTTON, Material.SPRUCE_BUTTON, Material.DARK_OAK_BUTTON,
|
|
||||||
Material.JUNGLE_BOAT, Material.OAK_BUTTON
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("signs"), Material.SPRUCE_SIGN, Material.ACACIA_SIGN,
|
|
||||||
Material.OAK_SIGN, Material.JUNGLE_SIGN, Material.DARK_OAK_SIGN, Material.BIRCH_SIGN
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_doors"), Material.SPRUCE_DOOR, Material.ACACIA_DOOR,
|
|
||||||
Material.OAK_DOOR, Material.JUNGLE_DOOR, Material.DARK_OAK_DOOR, Material.BIRCH_DOOR
|
|
||||||
);
|
|
||||||
server.createMaterialTag(NamespacedKey.minecraft("wooden_pressure_plates"), Material.SPRUCE_PRESSURE_PLATE,
|
|
||||||
Material.ACACIA_PRESSURE_PLATE, Material.OAK_PRESSURE_PLATE, Material.JUNGLE_PRESSURE_PLATE,
|
|
||||||
Material.DARK_OAK_PRESSURE_PLATE, Material.BIRCH_PRESSURE_PLATE
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -17,11 +17,9 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.junit.jupiter.api.TestMethodOrder;
|
import org.junit.jupiter.api.TestMethodOrder;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
|
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
|
import io.github.thebusybiscuit.slimefun4.implementation.setup.SlimefunItemSetup;
|
||||||
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
|
||||||
@TestMethodOrder(value = OrderAnnotation.class)
|
@TestMethodOrder(value = OrderAnnotation.class)
|
||||||
@ -31,9 +29,8 @@ class TestItemSetup {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ServerMock server = MockBukkit.mock();
|
MockBukkit.mock();
|
||||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||||
TestUtilities.registerDefaultTags(server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
@ -32,7 +32,6 @@ class TestClimbingPick implements SlimefunItemTest<ClimbingPick> {
|
|||||||
public static void load() {
|
public static void load() {
|
||||||
server = MockBukkit.mock();
|
server = MockBukkit.mock();
|
||||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||||
TestUtilities.registerDefaultTags(server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
@ -35,7 +35,6 @@ class TestMultiblockListener {
|
|||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void load() {
|
public static void load() {
|
||||||
server = MockBukkit.mock();
|
server = MockBukkit.mock();
|
||||||
TestUtilities.registerDefaultTags(server);
|
|
||||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||||
listener = new MultiBlockListener(plugin);
|
listener = new MultiBlockListener(plugin);
|
||||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItem(Material.DIAMOND, "&9Some multiblock item"));
|
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MULTIBLOCK_LISTENER_TEST", new CustomItem(Material.DIAMOND, "&9Some multiblock item"));
|
||||||
|
@ -9,7 +9,6 @@ import org.junit.jupiter.api.DisplayName;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
@ -22,8 +21,7 @@ class TestMultiBlocks {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void load() {
|
public static void load() {
|
||||||
ServerMock server = MockBukkit.mock();
|
MockBukkit.mock();
|
||||||
TestUtilities.registerDefaultTags(server);
|
|
||||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user