mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
commit
57a861b235
17
.github/workflows/pulls.yml
vendored
Normal file
17
.github/workflows/pulls.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
name: PR Categorization
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened]
|
||||
|
||||
jobs:
|
||||
assign_labels:
|
||||
runs-on: ubuntu-latest
|
||||
name: Categorize Pull Requests
|
||||
steps:
|
||||
- name: Branch Categorization
|
||||
uses: TheBusyBiscuit/branch-cat@v1.0.6
|
||||
with:
|
||||
rules: '{ "fix\/.+" : "Bug Fix" }'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
118
pom.xml
118
pom.xml
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>me.mrCookieSlime</groupId>
|
||||
<artifactId>Slimefun</artifactId>
|
||||
@ -29,10 +30,10 @@
|
||||
<url>https://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi-repo</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
@ -41,6 +42,7 @@
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
<finalName>${project.name} v${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -54,34 +56,31 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.bstats</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
@ -94,61 +93,62 @@
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.15-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||
<artifactId>CS-CoreLib</artifactId>
|
||||
<version>6e17183656</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
<version>0.7.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.1</version>
|
||||
<version>ec5b4c24e3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
<version>0.7.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.minebuilders</groupId>
|
||||
<artifactId>clearlag-core</artifactId>
|
||||
<version>2.9.7</version>
|
||||
<version>2.9.7</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Clearlag.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mrCookieSlime</groupId>
|
||||
<artifactId>EmeraldEnchants</artifactId>
|
||||
<version>2.0</version>
|
||||
<version>2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/EmeraldEnchants v2.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mrCookieSlime</groupId>
|
||||
<artifactId>ExoticGarden</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.2.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/ExoticGarden v1.2.0.jar</systemPath>
|
||||
</dependency>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.api;
|
||||
package io.github.thebusybiscuit.slimefun4.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -20,22 +20,18 @@ import org.bukkit.plugin.Plugin;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.TickerTask;
|
||||
|
||||
public class ErrorReport {
|
||||
|
||||
private File file;
|
||||
|
||||
public ErrorReport(Throwable throwable, Consumer<PrintStream> printer) {
|
||||
SlimefunPlugin.instance.getServer().getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> {
|
||||
String path = "plugins/Slimefun/error-reports/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
||||
file = new File(path + ".err");
|
||||
|
||||
if (file.exists()) {
|
||||
IntStream stream = IntStream.iterate(1, i -> i + 1).filter(i -> !new File(path + " (" + i + ").err").exists());
|
||||
int id = stream.findFirst().getAsInt();
|
||||
|
||||
file = new File(path + " (" + id + ").err");
|
||||
}
|
||||
Slimefun.runSync(() -> {
|
||||
file = getNewFile();
|
||||
|
||||
try (PrintStream stream = new PrintStream(file)) {
|
||||
stream.println();
|
||||
@ -55,18 +51,7 @@ public class ErrorReport {
|
||||
List<String> plugins = new ArrayList<>();
|
||||
List<String> addons = new ArrayList<>();
|
||||
|
||||
for (Plugin p: Bukkit.getPluginManager().getPlugins()) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled(p)) {
|
||||
plugins.add(" + " + p.getName() + ' ' + p.getDescription().getVersion());
|
||||
if (p.getDescription().getDepend().contains("Slimefun") || p.getDescription().getSoftDepend().contains("Slimefun"))
|
||||
addons.add(" + " + p.getName() + ' ' + p.getDescription().getVersion());
|
||||
}
|
||||
else {
|
||||
plugins.add(" - " + p.getName() + ' ' + p.getDescription().getVersion());
|
||||
if (p.getDescription().getDepend().contains("Slimefun") || p.getDescription().getSoftDepend().contains("Slimefun"))
|
||||
addons.add(" - " + p.getName() + ' ' + p.getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
scanPlugins(plugins, addons);
|
||||
|
||||
stream.println("Installed Addons (" + addons.size() + ")");
|
||||
addons.forEach(stream::println);
|
||||
@ -155,6 +140,37 @@ public class ErrorReport {
|
||||
});
|
||||
}
|
||||
|
||||
private void scanPlugins(List<String> plugins, List<String> addons) {
|
||||
String dependency = "Slimefun";
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled(plugin)) {
|
||||
plugins.add(" + " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||
if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency))
|
||||
addons.add(" + " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||
}
|
||||
else {
|
||||
plugins.add(" - " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||
if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency))
|
||||
addons.add(" - " + plugin.getName() + ' ' + plugin.getDescription().getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private File getNewFile() {
|
||||
String path = "plugins/Slimefun/error-reports/" + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
|
||||
File newFile = new File(path + ".err");
|
||||
|
||||
if (newFile.exists()) {
|
||||
IntStream stream = IntStream.iterate(1, i -> i + 1).filter(i -> !new File(path + " (" + i + ").err").exists());
|
||||
int id = stream.findFirst().getAsInt();
|
||||
|
||||
newFile = new File(path + " (" + id + ").err");
|
||||
}
|
||||
|
||||
return newFile;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
public abstract class JsonDataHolder {
|
||||
|
||||
protected JsonObject data;
|
||||
private boolean dirty;
|
||||
|
||||
public JsonDataHolder() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public JsonDataHolder(JsonObject data) {
|
||||
this.data = data != null ? data: new JsonObject();
|
||||
this.dirty = false;
|
||||
}
|
||||
|
||||
public void markDirty() {
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public void markClean() {
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setString(String key, String value) {
|
||||
data.addProperty(key, value);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setInt(String key, int value) {
|
||||
data.addProperty(key, value);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setBoolean(String key, boolean value) {
|
||||
data.addProperty(key, value);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setFloat(String key, float value) {
|
||||
data.addProperty(key, value);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setStringArray(String key, String[] array) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (String value: array) json.add(value);
|
||||
data.add(key, json);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setIntArray(String key, int[] array) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (int value: array) json.add(value);
|
||||
data.add(key, json);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setBooleanArray(String key, boolean[] array) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (boolean value: array) json.add(value);
|
||||
data.add(key, json);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void setFloatArray(String key, float[] array) {
|
||||
JsonArray json = new JsonArray();
|
||||
for (float value: array) json.add(value);
|
||||
data.add(key, json);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
// Getters
|
||||
public Optional<String> getString(String key) {
|
||||
return getPrimitive(key, JsonElement::getAsString);
|
||||
}
|
||||
public String getString(String key, String defaultValue) {
|
||||
return getString(key).orElse(defaultValue);
|
||||
}
|
||||
|
||||
public Optional<Integer> getInt(String key) {
|
||||
return getPrimitive(key, JsonElement::getAsInt);
|
||||
}
|
||||
public int getInt(String key, int defaultValue) {
|
||||
return getInt(key).orElse(defaultValue);
|
||||
}
|
||||
|
||||
public Optional<Boolean> getBoolean(String key) {
|
||||
return getPrimitive(key, JsonElement::getAsBoolean);
|
||||
}
|
||||
public boolean getBoolean(String key, boolean defaultValue) {
|
||||
return getBoolean(key).orElse(defaultValue);
|
||||
}
|
||||
|
||||
public Optional<Float> getFloat(String key) {
|
||||
return getPrimitive(key, JsonElement::getAsFloat);
|
||||
}
|
||||
public float getFloat(String key, float defaultValue) {
|
||||
return getFloat(key).orElse(defaultValue);
|
||||
}
|
||||
|
||||
public Optional<String[]> getStringArray(String key) {
|
||||
return getArray(key, String[]::new, JsonElement::getAsString);
|
||||
}
|
||||
|
||||
public Optional<Integer[]> getIntArray(String key) {
|
||||
return getArray(key, Integer[]::new, JsonElement::getAsInt);
|
||||
}
|
||||
|
||||
public Optional<Boolean[]> getBooleanArray(String key) {
|
||||
return getArray(key, Boolean[]::new, JsonElement::getAsBoolean);
|
||||
}
|
||||
|
||||
public Optional<Float[]> getFloatArray(String key) {
|
||||
return getArray(key, Float[]::new, JsonElement::getAsFloat);
|
||||
}
|
||||
|
||||
protected <T> Optional<T[]> getArray(String key, IntFunction<T[]> constructor, Function<JsonElement, T> getter) {
|
||||
JsonElement element = data.get(key);
|
||||
|
||||
if (element instanceof JsonArray) {
|
||||
JsonArray json = (JsonArray) element;
|
||||
T[] array = constructor.apply(json.size());
|
||||
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
array[i] = getter.apply(json.get(i));
|
||||
}
|
||||
|
||||
return Optional.of(array);
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> Optional<T> getPrimitive(String key, Function<JsonElement, T> getter) {
|
||||
JsonElement element = data.get(key);
|
||||
|
||||
if (element instanceof JsonPrimitive) {
|
||||
return Optional.of(getter.apply(element));
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.blocks.SlimefunBlock;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemRestriction;
|
||||
import io.github.thebusybiscuit.slimefun4.core.SlimefunWorld;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
|
||||
/**
|
||||
* This class will hold the declarations of important API methods for Slimefun.
|
||||
* Normally these methods will not be implemented in this interface, but some
|
||||
* methods will have a default implementation for convenience.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public interface SlimefunAPI {
|
||||
|
||||
/**
|
||||
* This method will register the given restriction.
|
||||
* Calling this should directly influence the outcome of {@link SlimefunAPI#getItemRestrictions()}.
|
||||
*
|
||||
* @param restriction The restriction to register
|
||||
*/
|
||||
void addItemRestriction(ItemRestriction restriction);
|
||||
|
||||
/**
|
||||
* This method will return a {@link Set} of all instances of {@link ItemRestriction} that will directly
|
||||
* affect the outcome of {@link SlimefunAPI#isAllowedToUse(Player, ItemStack, boolean)}
|
||||
*
|
||||
* @return The Set of all registered item restrictions
|
||||
*/
|
||||
Set<ItemRestriction> getItemRestrictions();
|
||||
|
||||
/**
|
||||
* This method will return whether a Player is allowed to use the given {@link ItemStack}.
|
||||
* If warningMessages is set to true, the Player will be informed about the outcome of this method.
|
||||
*
|
||||
* Internally this method will loop through {@link SlimefunAPI#getItemRestrictions()} and perform
|
||||
* checks using all available instances of {@link ItemRestriction}.
|
||||
*
|
||||
* Do NOT warn Players about a restriction if this method returns false.
|
||||
* Warnings should be exclusively handled via {@link ItemRestriction#warnPlayer(PlayerProfile, Player, SlimefunItem, ItemStack)}
|
||||
*
|
||||
* @param p The Player to perform the check on
|
||||
* @param item The Item to perform the check on
|
||||
* @param sendWarnings Whether to warn the Player about not being able to use the given item
|
||||
* @return Whether the Player is allowed to use the given item
|
||||
*/
|
||||
default boolean isAllowedToUse(Player p, ItemStack item, boolean sendWarnings) {
|
||||
PlayerProfile profile = PlayerProfile.get(p);
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
|
||||
for (ItemRestriction restriction : getItemRestrictions()) {
|
||||
if (!restriction.isAllowed(profile, p, sfItem, item)) {
|
||||
if (sendWarnings) restriction.warnPlayer(profile, p, sfItem, item);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a {@link Set} of all registered instances of {@link Category}.
|
||||
*
|
||||
* @return A Set of all Categories
|
||||
*/
|
||||
Set<Category> getCategories();
|
||||
|
||||
/**
|
||||
* This method returns A {@link Set} of all registered instances of {@link SlimefunItem}.
|
||||
* Its default implementation generates a new Set based on all items found in the categories
|
||||
* returned by {@link SlimefunAPI#getCategories()}
|
||||
*
|
||||
* @return A Set of all SlimefunItems
|
||||
*/
|
||||
default Set<SlimefunItem> getItems() {
|
||||
return getCategories().stream().flatMap(cat -> cat.getItems().stream()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
Optional<SlimefunItem> fromItemStack(ItemStack item);
|
||||
|
||||
Optional<SlimefunBlock> fromBlock();
|
||||
|
||||
SlimefunWorld fromWorld(World world);
|
||||
|
||||
PlayerProfile fromPlayer(OfflinePlayer player);
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.blocks;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public final class BlockLocation {
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
public BlockLocation(Block b) {
|
||||
this(b.getX(), b.getY(), b.getZ());
|
||||
}
|
||||
|
||||
public BlockLocation(Location l) {
|
||||
this(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
public BlockLocation(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof BlockLocation) {
|
||||
BlockLocation l = (BlockLocation) obj;
|
||||
return l.getX() == x && l.getY() == y && l.getZ() == z;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + x + " | " + y + " | " + z + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.blocks;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.JsonDataHolder;
|
||||
|
||||
public class SlimefunBlock extends JsonDataHolder {
|
||||
|
||||
private String id;
|
||||
|
||||
public SlimefunBlock(String id) {
|
||||
this(id, null);
|
||||
}
|
||||
|
||||
public SlimefunBlock(String id, JsonObject data) {
|
||||
super(data);
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.androids.AndroidEntity;
|
||||
|
||||
/**
|
||||
* This event is fired before a miner android mines a block.
|
||||
* If this event is cancelled, the block will not be mined.
|
||||
*/
|
||||
public class AndroidMineEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final Block block;
|
||||
private final AndroidEntity android;
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* @param block - mined block
|
||||
* @param android - the block of the android
|
||||
*/
|
||||
public AndroidMineEvent(Block block, AndroidEntity android) {
|
||||
this.block = block;
|
||||
this.android = android;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the mined block
|
||||
*
|
||||
* @return the mined block
|
||||
*/
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the block of the
|
||||
* android who wants to mine a block.
|
||||
*
|
||||
* @return the block of the android
|
||||
*/
|
||||
public AndroidEntity getAndroid() {
|
||||
return android;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Events;
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
@ -14,6 +14,7 @@ public class AutoDisenchantEvent extends Event implements Cancellable {
|
||||
|
||||
public AutoDisenchantEvent(ItemStack item) {
|
||||
super(true);
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Events;
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.MultiBlock;
|
||||
|
||||
@ -12,9 +12,9 @@ public class MultiBlockInteractEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player p;
|
||||
private MultiBlock mb;
|
||||
private Block b;
|
||||
private Player player;
|
||||
private MultiBlock multiBlock;
|
||||
private Block clickedBlock;
|
||||
private boolean cancelled;
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
@ -26,21 +26,21 @@ public class MultiBlockInteractEvent extends Event implements Cancellable {
|
||||
}
|
||||
|
||||
public MultiBlockInteractEvent(Player p, MultiBlock mb, Block clicked) {
|
||||
this.p = p;
|
||||
this.mb = mb;
|
||||
this.b = clicked;
|
||||
this.player = p;
|
||||
this.multiBlock = mb;
|
||||
this.clickedBlock = clicked;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.p;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public MultiBlock getMultiBlock() {
|
||||
return this.mb;
|
||||
return this.multiBlock;
|
||||
}
|
||||
|
||||
public Block getClickedBlock() {
|
||||
return this.b;
|
||||
return this.clickedBlock;
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Events;
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||
|
||||
@ -11,8 +11,8 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player p;
|
||||
private Research r;
|
||||
private Player player;
|
||||
private Research research;
|
||||
private boolean cancelled;
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
@ -23,17 +23,17 @@ public class ResearchUnlockEvent extends Event implements Cancellable {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public ResearchUnlockEvent(Player p, Research res) {
|
||||
this.p = p;
|
||||
this.r = res;
|
||||
public ResearchUnlockEvent(Player p, Research research) {
|
||||
this.player = p;
|
||||
this.research = research;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.p;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Research getResearch() {
|
||||
return this.r;
|
||||
return this.research;
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,36 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
|
||||
public interface ItemRestriction {
|
||||
|
||||
/**
|
||||
* This method represents a check.
|
||||
* The returned boolean will decide whether to allow the action.
|
||||
*
|
||||
* @param profile The Player's profile
|
||||
* @param p The Player itself
|
||||
* @param item The SlimefunItem that the {@link ItemStack} represents
|
||||
* @param itemstack The ItemStack that is being tested.
|
||||
*/
|
||||
boolean isAllowed(PlayerProfile profile, Player p, SlimefunItem item, ItemStack itemstack);
|
||||
|
||||
/**
|
||||
* This method is executed if an ItemRestriction took affect.
|
||||
* Override it to send a message to the Player telling them they cannot
|
||||
* use that item, or do something else in there.
|
||||
*
|
||||
* @param profile The Player's profile
|
||||
* @param p The Player to warn
|
||||
* @param item The SlimefunItem that the {@link ItemStack} represents
|
||||
* @param itemstack The ItemStack that was prevented from being used
|
||||
*/
|
||||
void warnPlayer(PlayerProfile profile, Player p, SlimefunItem item, ItemStack itemstack);
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface Placeable {
|
||||
|
||||
boolean isTicking();
|
||||
|
||||
Collection<ItemStack> getDrops();
|
||||
Collection<ItemStack> getDrops(Player p);
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.recipes;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface ContextualRecipe extends Predicate<ItemStack[]> {
|
||||
|
||||
boolean isShapeless();
|
||||
|
||||
ItemStack getOutput(ItemStack[] input);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.TileState;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.OptionalMap;
|
||||
import io.github.thebusybiscuit.slimefun4.api.blocks.BlockLocation;
|
||||
import io.github.thebusybiscuit.slimefun4.api.blocks.SlimefunBlock;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
public class SlimefunWorld {
|
||||
|
||||
private final UUID uuid;
|
||||
private final OptionalMap<BlockLocation, SlimefunBlock> blocks = new OptionalMap<>(HashMap::new);
|
||||
|
||||
public SlimefunWorld(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return the {@link UUID} of this instance.
|
||||
* The {@link UUID} will be the same for {@link SlimefunWorld} and the corresponding instance
|
||||
* of {@link World}.
|
||||
*
|
||||
* @return This world's {@link UUID}
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will reliably get the instance of {@link SlimefunBlock} associated with the given
|
||||
* {@link Block}.
|
||||
*
|
||||
* @param b The {@link Block} to query
|
||||
* @return An {@link Optional} of the requested {@link SlimefunBlock}, empty if none was found
|
||||
*/
|
||||
public Optional<SlimefunBlock> getBlock(Block b) {
|
||||
if (b.getState() instanceof TileState) {
|
||||
Optional<String> blockData = SlimefunPlugin.getBlockDataService().getBlockData((TileState) b.getState());
|
||||
|
||||
if (blockData.isPresent()) {
|
||||
return Optional.of(new SlimefunBlock(blockData.get()));
|
||||
}
|
||||
}
|
||||
|
||||
return blocks.get(new BlockLocation(b));
|
||||
}
|
||||
|
||||
public boolean isBlock(Block b, String id) {
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("Cannot check blocks for id: null");
|
||||
}
|
||||
|
||||
Optional<SlimefunBlock> block = getBlock(b);
|
||||
|
||||
return block.isPresent() && block.get().getID().equals(id);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -9,12 +9,13 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.PlayerRunnable;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Chat.TellRawMessage.HoverAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.CustomBookOverlay;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -87,25 +88,25 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
actions.add(null);
|
||||
}
|
||||
}
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', "&8\u21E8 &6Tier " + tier));
|
||||
texts.add(ChatColors.color("&8\u21E8 &6Tier " + tier));
|
||||
tooltips.add(null);
|
||||
actions.add(null);
|
||||
}
|
||||
if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
|
||||
StringBuilder parents = new StringBuilder(ChatColor.translateAlternateColorCodes('&', "&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n"));
|
||||
StringBuilder parents = new StringBuilder(ChatColors.color("&4&lLOCKED\n\n&7In order to unlock this Category,\n&7you need to unlock all Items from\n&7the following Categories first:\n"));
|
||||
|
||||
for (Category parent: ((LockedCategory) category).getParents()) {
|
||||
parents.append(ChatColor.translateAlternateColorCodes('&', "\n&c" + StringUtils.formatItemName(parent.getItem(), false)));
|
||||
parents.append(ChatColors.color("\n&c" + ItemUtils.getItemName(parent.getItem())));
|
||||
}
|
||||
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&c" , StringUtils.formatItemName(category.getItem(), false))));
|
||||
texts.add(ChatColors.color(shorten("&c" , ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(parents.toString());
|
||||
actions.add(null);
|
||||
}
|
||||
else if (category instanceof SeasonalCategory) {
|
||||
if (((SeasonalCategory) category).isUnlocked()) {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)));
|
||||
texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem())));
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
@ -115,8 +116,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(category.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&eClick to open the following Category:\n" + StringUtils.formatItemName(category.getItem(), false)));
|
||||
texts.add(ChatColors.color(shorten("&a", ItemUtils.getItemName(category.getItem()))));
|
||||
tooltips.add(ChatColors.color("&eClick to open the following Category:\n" + ItemUtils.getItemName(category.getItem())));
|
||||
actions.add(new PlayerRunnable(1) {
|
||||
@Override
|
||||
public void run(final Player p) {
|
||||
@ -141,7 +142,7 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
for (int i = 0; i < texts.size(); i = i + 10) {
|
||||
TellRawMessage pageMessage = new TellRawMessage();
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n"));
|
||||
pageMessage.addText(ChatColors.color("&b&l- Slimefun Guide -\n\n"));
|
||||
for (int j = i; j < texts.size() && j < i + 10; j++) {
|
||||
pageMessage.addText(texts.get(j) + "\n");
|
||||
if (tooltips.get(j) != null) pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, tooltips.get(j));
|
||||
@ -175,8 +176,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
if (survival && !Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) {
|
||||
final Research research = item.getResearch();
|
||||
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&7", StringUtils.formatItemName(item.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', StringUtils.formatItemName(item.getItem(), false) + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock"));
|
||||
texts.add(ChatColors.color(shorten("&7", item.getItemName())));
|
||||
tooltips.add(ChatColors.color(item.getItemName() + "\n&c&lLOCKED\n\n&7Cost: " + (p.getLevel() >= research.getCost() ? "&b": "&4") + research.getCost() + " Levels\n\n&a> Click to unlock"));
|
||||
actions.add(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
||||
@ -207,11 +208,11 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
});
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&a", StringUtils.formatItemName(item.getItem(), false))));
|
||||
texts.add(ChatColors.color(shorten("&a", item.getItemName())));
|
||||
|
||||
StringBuilder tooltip = new StringBuilder();
|
||||
|
||||
tooltip.append(StringUtils.formatItemName(item.getItem(), false));
|
||||
tooltip.append(item.getItemName());
|
||||
|
||||
if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasLore()) {
|
||||
for (String line : item.getItem().getItemMeta().getLore()) {
|
||||
@ -219,7 +220,7 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
|
||||
tooltip.append(ChatColor.translateAlternateColorCodes('&', "\n\n&e&oClick for more Info"));
|
||||
tooltip.append(ChatColors.color("\n\n&e&oClick for more Info"));
|
||||
|
||||
tooltips.add(tooltip.toString());
|
||||
actions.add(new PlayerRunnable(2) {
|
||||
@ -233,15 +234,15 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
}
|
||||
else {
|
||||
texts.add(ChatColor.translateAlternateColorCodes('&', shorten("&4", StringUtils.formatItemName(item.getItem(), false))));
|
||||
tooltips.add(ChatColor.translateAlternateColorCodes('&', "&cNo Permission!"));
|
||||
texts.add(ChatColors.color(shorten("&4", ItemUtils.getItemName(item.getItem()))));
|
||||
tooltips.add(ChatColors.color("&cNo Permission!"));
|
||||
actions.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < texts.size(); i = i + 10) {
|
||||
TellRawMessage pageMessage = new TellRawMessage();
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&b&l- Slimefun Guide -\n\n"));
|
||||
pageMessage.addText(ChatColors.color("&b&l- Slimefun Guide -\n\n"));
|
||||
|
||||
for (int j = i; j < texts.size() && j < i + 10; j++) {
|
||||
pageMessage.addText(texts.get(j) + "\n");
|
||||
@ -250,8 +251,8 @@ public class BookSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
|
||||
pageMessage.addText("\n");
|
||||
pageMessage.addText(ChatColor.translateAlternateColorCodes('&', "&6\u21E6 &lBack"));
|
||||
pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, ChatColor.translateAlternateColorCodes('&', "&eClick to go back to the Category Overview"));
|
||||
pageMessage.addText(ChatColors.color("&6\u21E6 &lBack"));
|
||||
pageMessage.addHoverEvent(HoverAction.SHOW_TEXT, ChatColors.color("&eClick to go back to the Category Overview"));
|
||||
pageMessage.addClickEvent(new PlayerRunnable(2) {
|
||||
|
||||
@Override
|
@ -1,6 +1,7 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -13,6 +14,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
import org.bukkit.inventory.RecipeChoice;
|
||||
@ -21,9 +23,8 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.String.StringUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -92,7 +93,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
Category category = categories.get(target);
|
||||
boolean locked = true;
|
||||
|
||||
for (SlimefunItem item: category.getItems()) {
|
||||
for (SlimefunItem item : category.getItems()) {
|
||||
if (Slimefun.isEnabled(p, item, false)) {
|
||||
locked = false;
|
||||
break;
|
||||
@ -260,7 +261,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
}
|
||||
else {
|
||||
List<String> message = sfitem.getNoPermissionTooltip();
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, StringUtils.formatItemName(sfitem.getItem(), false), message.toArray(new String[message.size()])));
|
||||
menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[message.size()])));
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> false);
|
||||
index++;
|
||||
}
|
||||
@ -312,22 +313,32 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
if (index == 44) break;
|
||||
|
||||
if (!itemName.isEmpty()) {
|
||||
if (itemName.equals(searchTerm) || itemName.contains(searchTerm)) {
|
||||
menu.addItem(index, item.getItem());
|
||||
menu.addMenuClickHandler(index, (pl, slot, itm, action) -> {
|
||||
if (!survival) {
|
||||
pl.getInventory().addItem(item.getItem().clone());
|
||||
}
|
||||
else {
|
||||
displayItem(profile, item, true);
|
||||
}
|
||||
if (!itemName.isEmpty() && (itemName.equals(searchTerm) || itemName.contains(searchTerm))) {
|
||||
ItemStack itemstack = new CustomItem(item.getItem(), meta -> {
|
||||
List<String> lore = null;
|
||||
Category category = item.getCategory();
|
||||
|
||||
return false;
|
||||
});
|
||||
if (category != null && category.getItem() != null && category.getItem().hasItemMeta() && category.getItem().getItemMeta().hasDisplayName()) {
|
||||
lore = Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.RESET + item.getCategory().getItem().getItemMeta().getDisplayName());
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
meta.setLore(lore);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS);
|
||||
});
|
||||
|
||||
menu.addItem(index, itemstack);
|
||||
menu.addMenuClickHandler(index, (pl, slot, itm, action) -> {
|
||||
if (!survival) {
|
||||
pl.getInventory().addItem(item.getItem().clone());
|
||||
}
|
||||
else {
|
||||
displayItem(profile, item, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,7 +441,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
if (Slimefun.getItemConfig().contains(item.getID() + ".youtube")) {
|
||||
try {
|
||||
menu.addItem(7, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch"));
|
||||
menu.addItem(7, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzNTNmZDBmODYzMTQzNTM4NzY1ODYwNzViOWJkZjBjNDg0YWFiMDMzMWI4NzJkZjExYmQ1NjRmY2IwMjllZCJ9fX0="), "&rDemonstration Video &7(Youtube)", "", "&7\u21E8 Click to watch"));
|
||||
menu.addMenuClickHandler(7, (pl, slot, itemstack, action) -> {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
@ -570,7 +581,7 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
if (playerHistory.size() > 1) {
|
||||
|
||||
menu.addItem(slot, new CustomItem(new ItemStack(Material.ENCHANTED_BOOK),
|
||||
menu.addItem(slot, new CustomItem(SlimefunGuide.getItem(SlimefunGuideLayout.CHEST),
|
||||
"&7\u21E6 Back", "",
|
||||
"&rLeft Click: &7Go back to previous Page",
|
||||
"&rShift + left Click: &7Go back to Main Menu")
|
||||
@ -652,14 +663,14 @@ public class ChestSlimefunGuide implements ISlimefunGuide {
|
||||
|
||||
if ((i + (page * 18)) < recipes.size()) {
|
||||
if (page == 0) {
|
||||
menu.replaceExistingItem(slot, recipes.get(i + (page * 18)));
|
||||
menu.replaceExistingItem(slot, recipes.get(i + (page * 18)).clone());
|
||||
menu.addMenuClickHandler(slot, (pl, s, itemstack, action) -> {
|
||||
displayItem(profile, itemstack, true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(slot, recipes.get(i + (page * 18)));
|
||||
menu.replaceExistingItem(slot, recipes.get(i + (page * 18)).clone());
|
||||
}
|
||||
}
|
||||
else {
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
@ -7,7 +7,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -16,16 +15,17 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor;
|
||||
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.core.utils.NumberUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.CSCoreLib;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.hooks.github.Contributor;
|
||||
import me.mrCookieSlime.Slimefun.hooks.github.IntegerFormat;
|
||||
import me.mrCookieSlime.Slimefun.utils.ChatUtils;
|
||||
|
||||
public final class GuideSettings {
|
||||
|
||||
@ -50,7 +50,7 @@ public final class GuideSettings {
|
||||
menu.addMenuClickHandler(i, (pl, slot, item, action) -> false);
|
||||
}
|
||||
|
||||
if (SlimefunManager.isItemSimiliar(guide, getItem(SlimefunGuideLayout.CHEST), true)) {
|
||||
if (SlimefunManager.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEST), true)) {
|
||||
if (p.hasPermission("slimefun.cheat.items")) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.CHEST), "&7Guide Layout: &eChest GUI", "", "&aChest GUI", "&7Book GUI", "&7Cheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
@ -68,7 +68,7 @@ public final class GuideSettings {
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(guide, getItem(SlimefunGuideLayout.BOOK), true)) {
|
||||
else if (SlimefunManager.isItemSimilar(guide, getItem(SlimefunGuideLayout.BOOK), true)) {
|
||||
if (p.hasPermission("slimefun.cheat.items")) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.BOOK), "&7Guide Layout: &eBook GUI", "", "&7Chest GUI", "&aBook GUI", "&7Cheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
@ -86,7 +86,7 @@ public final class GuideSettings {
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(guide, getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
||||
else if (SlimefunManager.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
||||
menu.addItem(19, new CustomItem(new ItemStack(Material.COMMAND_BLOCK), "&7Guide Layout: &eCheat Sheet", "", "&7Chest GUI", "&7Book GUI", "&aCheat Sheet", "", "&e Click &8\u21E8 &7Change Layout"));
|
||||
menu.addMenuClickHandler(19, (pl, slot, item, action) -> {
|
||||
pl.getInventory().setItemInMainHand(getItem(SlimefunGuideLayout.CHEST));
|
||||
@ -101,7 +101,7 @@ public final class GuideSettings {
|
||||
"&7Slimefun Version: &a" + Slimefun.getVersion(),
|
||||
"&7CS-CoreLib Version: &a" + CSCoreLib.getLib().getDescription().getVersion(),
|
||||
"&7Installed Addons: &b" + Slimefun.getInstalledAddons().size(),
|
||||
"&7Contributors: &e" + SlimefunPlugin.getUtilities().contributors.size(),
|
||||
"&7Contributors: &e" + SlimefunPlugin.getGitHubService().getContributors().size(),
|
||||
"",
|
||||
"&7\u21E8 Click to see the people behind this Plugin"
|
||||
));
|
||||
@ -111,7 +111,7 @@ public final class GuideSettings {
|
||||
});
|
||||
|
||||
try {
|
||||
menu.addItem(5, new CustomItem(new ItemStack(Material.COMPARATOR), "&eSource Code", "", "&7Bytes of Code: &6" + IntegerFormat.formatBigNumber(SlimefunPlugin.getUtilities().codeBytes), "&7Last Update: &a" + IntegerFormat.timeDelta(SlimefunPlugin.getUtilities().lastUpdate) + " ago", "&7Forks: &e" + SlimefunPlugin.getUtilities().forks, "&7Stars: &e" + SlimefunPlugin.getUtilities().stars, "", "&7&oSlimefun 4 is a community project,", "&7&othe source code is available on GitHub", "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", "", "&7\u21E8 Click to go to GitHub"));
|
||||
menu.addItem(5, new CustomItem(new ItemStack(Material.COMPARATOR), "&eSource Code", "", "&7Bytes of Code: &6" + NumberUtils.formatBigNumber(SlimefunPlugin.getGitHubService().getCodeSize()), "&7Last Activity: &a" + NumberUtils.timeDelta(SlimefunPlugin.getGitHubService().getLastUpdate()) + " ago", "&7Forks: &e" + SlimefunPlugin.getGitHubService().getForks(), "&7Stars: &e" + SlimefunPlugin.getGitHubService().getStars(), "", "&7&oSlimefun 4 is a community project,", "&7&othe source code is available on GitHub", "&7&oand if you want to keep this Plugin alive,", "&7&othen please consider contributing to it", "", "&7\u21E8 Click to go to GitHub"));
|
||||
menu.addMenuClickHandler(5, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
ChatUtils.sendURL(pl, "https://github.com/TheBusyBiscuit/Slimefun4");
|
||||
@ -128,7 +128,7 @@ public final class GuideSettings {
|
||||
return false;
|
||||
});
|
||||
|
||||
menu.addItem(20, new CustomItem(new ItemStack(Material.REDSTONE), "&4Report a bug", "", "&7Open Issues: &a" + SlimefunPlugin.getUtilities().issues, "&7Pending Pull Requests: &a" + SlimefunPlugin.getUtilities().prs, "", "&7\u21E8 Click to go to the Slimefun Bug Tracker"));
|
||||
menu.addItem(20, new CustomItem(new ItemStack(Material.REDSTONE), "&4Report a bug", "", "&7Open Issues: &a" + SlimefunPlugin.getGitHubService().getIssues(), "&7Pending Pull Requests: &a" + SlimefunPlugin.getGitHubService().getPullRequests(), "", "&7\u21E8 Click to go to the Slimefun Bug Tracker"));
|
||||
menu.addMenuClickHandler(20, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
ChatUtils.sendURL(pl, "https://github.com/TheBusyBiscuit/Slimefun4/issues");
|
||||
@ -167,7 +167,7 @@ public final class GuideSettings {
|
||||
}
|
||||
}
|
||||
|
||||
List<Contributor> contributors = new ArrayList<>(SlimefunPlugin.getUtilities().contributors.values());
|
||||
List<Contributor> contributors = new ArrayList<>(SlimefunPlugin.getGitHubService().getContributors().values());
|
||||
contributors.sort(Comparator.comparingInt(Contributor::index));
|
||||
|
||||
boolean hasPrevious = page > 0;
|
||||
@ -183,19 +183,27 @@ public final class GuideSettings {
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
|
||||
try {
|
||||
skull = CustomSkull.getItem(contributor.getTexture());
|
||||
skull = SkullItem.fromBase64(contributor.getTexture());
|
||||
} catch (Exception e) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while inserting a Contributors head.", e);
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occurred while inserting a Contributors head.", e);
|
||||
}
|
||||
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.GRAY + contributor.getName());
|
||||
meta.setDisplayName(ChatColor.GRAY + contributor.getName()
|
||||
+ (!contributor.getName().equals(contributor.getMinecraftName()) ? ChatColor.DARK_GRAY + " (MC: " + contributor.getMinecraftName() + ")" : "")
|
||||
);
|
||||
|
||||
List<String> lore = new LinkedList<>();
|
||||
lore.add("");
|
||||
|
||||
for (Map.Entry<String, Integer> entry: contributor.getContributions().entrySet()) {
|
||||
lore.add(ChatColors.color(entry.getKey() + " &7(" + entry.getValue() + " Commit" + (entry.getValue() > 1 ? "s": "") + ")"));
|
||||
for (Map.Entry<String, Integer> entry : contributor.getContributions().entrySet()) {
|
||||
String info = entry.getKey();
|
||||
|
||||
if (entry.getValue() > 0) {
|
||||
info += " &7(" + entry.getValue() + " Commit" + (entry.getValue() > 1 ? "s": "") + ")";
|
||||
}
|
||||
|
||||
lore.add(ChatColors.color(info));
|
||||
}
|
||||
|
||||
lore.add("");
|
||||
@ -203,8 +211,8 @@ public final class GuideSettings {
|
||||
meta.setLore(lore);
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
menu.addItem(i + 9, skull);
|
||||
menu.addMenuClickHandler(i + 9, (pl, slot, item, action) -> {
|
||||
menu.addItem(i - page * 36 + 9, skull);
|
||||
menu.addMenuClickHandler(i - page * 36 + 9, (pl, slot, item, action) -> {
|
||||
pl.closeInventory();
|
||||
ChatUtils.sendURL(pl, contributor.getProfile());
|
||||
return false;
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
@ -22,8 +22,12 @@ public interface ISlimefunGuide {
|
||||
void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory);
|
||||
|
||||
default String shorten(String string, String string2) {
|
||||
if (ChatColor.stripColor(string + string2).length() > 19) return (string + ChatColor.stripColor(string2)).substring(0, 18) + "...";
|
||||
else return (string + ChatColor.stripColor(string2));
|
||||
if (ChatColor.stripColor(string + string2).length() > 19) {
|
||||
return (string + ChatColor.stripColor(string2)).substring(0, 18) + "...";
|
||||
}
|
||||
else {
|
||||
return string + ChatColor.stripColor(string2);
|
||||
}
|
||||
}
|
||||
|
||||
default Object getLastEntry(PlayerProfile profile, boolean remove) {
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.guides;
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
public enum SlimefunGuideLayout {
|
||||
|
@ -0,0 +1,28 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
|
||||
public class BlockDataService {
|
||||
|
||||
private final NamespacedKey namespacedKey;
|
||||
|
||||
public BlockDataService(Plugin plugin, String key) {
|
||||
namespacedKey = new NamespacedKey(plugin, key);
|
||||
}
|
||||
|
||||
public void setBlockData(TileState tileEntity, String value) {
|
||||
PersistentDataAPI.setString(tileEntity, namespacedKey, value);
|
||||
tileEntity.update();
|
||||
}
|
||||
|
||||
public Optional<String> getBlockData(TileState tileEntity) {
|
||||
return PersistentDataAPI.getOptionalString(tileEntity, namespacedKey);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.services;
|
||||
package io.github.thebusybiscuit.slimefun4.core.services;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -1,6 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.services;
|
||||
|
||||
import java.util.Collection;
|
||||
package io.github.thebusybiscuit.slimefun4.core.services;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -12,23 +10,37 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
public class CustomTextureService {
|
||||
|
||||
private final Config config;
|
||||
private boolean modified = false;
|
||||
|
||||
public CustomTextureService(Plugin plugin) {
|
||||
this.config = new Config(plugin, "item-models.yml");
|
||||
}
|
||||
|
||||
public void setup(Collection<SlimefunItem> items) {
|
||||
public void setup(Iterable<SlimefunItem> items) {
|
||||
config.setDefaultValue("SLIMEFUN_GUIDE", 0);
|
||||
|
||||
|
||||
for (SlimefunItem item : items) {
|
||||
if (item != null && item.getID() != null) {
|
||||
config.setDefaultValue(item.getID(), 0);
|
||||
|
||||
if (config.getInt(item.getID()) != 0) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return config.getString("version");
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public int getModelData(String id) {
|
||||
return config.getInt(id);
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
public class MetricsService extends Metrics {
|
||||
|
||||
public MetricsService(SlimefunPlugin plugin) {
|
||||
super(plugin);
|
||||
|
||||
addCustomChart(new SimplePie("auto_updates", () ->
|
||||
SlimefunPlugin.getCfg().getBoolean("options.auto-update") ? "enabled": "disabled"
|
||||
));
|
||||
|
||||
addCustomChart(new SimplePie("resourcepack", () -> {
|
||||
String version = SlimefunPlugin.getItemTextureService().getVersion();
|
||||
|
||||
if (SlimefunPlugin.getItemTextureService().isActive()) {
|
||||
return "Custom / Modified";
|
||||
}
|
||||
else if (version != null) {
|
||||
return version + " (Official)";
|
||||
}
|
||||
else {
|
||||
return "None";
|
||||
}
|
||||
}));
|
||||
|
||||
addCustomChart(new SimplePie("branch", () -> {
|
||||
if (plugin.getDescription().getVersion().startsWith("DEV - ")) {
|
||||
return "master";
|
||||
}
|
||||
else if (plugin.getDescription().getVersion().startsWith("RC - ")) {
|
||||
return "stable";
|
||||
}
|
||||
else {
|
||||
return "Unknown";
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package me.mrCookieSlime.Slimefun.hooks.github;
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.github;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
|
||||
public class ContributionsConnector extends GitHubConnector {
|
||||
|
||||
// GitHub Bots that do not count as Contributors
|
||||
@ -16,14 +16,33 @@ public class ContributionsConnector extends GitHubConnector {
|
||||
private static final List<String> blacklist = Arrays.asList(
|
||||
"invalid-email-address",
|
||||
"renovate-bot",
|
||||
"ImgBotApp"
|
||||
"ImgBotApp",
|
||||
"TheBusyBot",
|
||||
"imgbot"
|
||||
);
|
||||
|
||||
// Matches a GitHub name with a Minecraft name.
|
||||
private static final Map<String, String> aliases = new HashMap<>();
|
||||
|
||||
// Should probably be switched to UUIDs at some point...
|
||||
static {
|
||||
aliases.put("WalshyDev", "HumanRightsAct");
|
||||
aliases.put("J3fftw1", "_lagpc_");
|
||||
aliases.put("ajan-12", "ajan_12");
|
||||
aliases.put("LinoxGH", "ajan_12");
|
||||
aliases.put("NihilistBrew", "ma1yang2");
|
||||
aliases.put("NihilistBrew", "ma1yang2");
|
||||
aliases.put("mrcoffee1026", "mr_coffee1026");
|
||||
aliases.put("BluGhostYT", "CyberPatriot");
|
||||
}
|
||||
|
||||
private final String prefix;
|
||||
private final String repository;
|
||||
private final String role;
|
||||
|
||||
public ContributionsConnector(String prefix, String repository, String role) {
|
||||
public ContributionsConnector(GitHubService github, String prefix, String repository, String role) {
|
||||
super(github);
|
||||
|
||||
this.prefix = prefix;
|
||||
this.repository = repository;
|
||||
this.role = role;
|
||||
@ -46,7 +65,7 @@ public class ContributionsConnector extends GitHubConnector {
|
||||
|
||||
@Override
|
||||
public String getURLSuffix() {
|
||||
return "/contributors";
|
||||
return "/contributors?per_page=100";
|
||||
}
|
||||
|
||||
private void computeContributors(JsonArray array) {
|
||||
@ -58,7 +77,10 @@ public class ContributionsConnector extends GitHubConnector {
|
||||
String profile = object.get("html_url").getAsString();
|
||||
|
||||
if (!blacklist.contains(name)) {
|
||||
Contributor contributor = SlimefunPlugin.getUtilities().contributors.computeIfAbsent(name, key -> new Contributor(name, profile));
|
||||
Contributor contributor = github.getContributors().computeIfAbsent(
|
||||
name,
|
||||
key -> new Contributor(aliases.getOrDefault(name, name), profile)
|
||||
);
|
||||
contributor.setContribution(role, commits);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.hooks.github;
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.github;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@ -14,14 +14,20 @@ public class Contributor {
|
||||
|
||||
private static final String PLACEHOLDER_HEAD = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDZiYTYzMzQ0ZjQ5ZGQxYzRmNTQ4OGU5MjZiZjNkOWUyYjI5OTE2YTZjNTBkNjEwYmI0MGE1MjczZGM4YzgyIn19fQ==";
|
||||
|
||||
private String name;
|
||||
private String profile;
|
||||
private Optional<String> headTexture;
|
||||
private final String ghName;
|
||||
private final String mcName;
|
||||
private String profileLink;
|
||||
private final ConcurrentMap<String, Integer> contributions = new ConcurrentHashMap<>();
|
||||
|
||||
// This field is nullable.
|
||||
// null = "Texture was not pulled yet or failed to pull, it will try again next time"
|
||||
// empty Optional = "No Texture could be found for this person.
|
||||
private Optional<String> headTexture;
|
||||
|
||||
public Contributor(String name, String profile) {
|
||||
this.name = name;
|
||||
this.profile = profile;
|
||||
this.ghName = profile.substring(profile.lastIndexOf('/') + 1);
|
||||
this.mcName = name;
|
||||
this.profileLink = profile;
|
||||
}
|
||||
|
||||
public void setContribution(String role, int commits) {
|
||||
@ -35,7 +41,17 @@ public class Contributor {
|
||||
* @since 4.1.13
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
return this.ghName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MC name of the contributor.
|
||||
* This may be the same as {@link #getName()}.
|
||||
*
|
||||
* @return The MC username of this contributor.
|
||||
*/
|
||||
public String getMinecraftName() {
|
||||
return this.mcName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +61,7 @@ public class Contributor {
|
||||
* @since 4.1.13
|
||||
*/
|
||||
public String getProfile() {
|
||||
return this.profile;
|
||||
return this.profileLink;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getContributions() {
|
||||
@ -53,7 +69,10 @@ public class Contributor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this Creator's head texture
|
||||
* Returns this Creator's head texture.
|
||||
* If no texture could be found, or it hasn't been pulled yet,
|
||||
* then it will return a placeholder texture.
|
||||
*
|
||||
* @return A Base64-Head Texture
|
||||
*/
|
||||
public String getTexture() {
|
||||
@ -65,6 +84,12 @@ public class Contributor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return whether this instance of {@link Contributor} has
|
||||
* pulled a texture yet.
|
||||
*
|
||||
* @return Whether this {@link Contributor} has been assigned a texture yet
|
||||
*/
|
||||
public boolean hasTexture() {
|
||||
return headTexture != null;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.hooks.github;
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.github;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -14,16 +14,17 @@ import java.util.logging.Level;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public abstract class GitHubConnector {
|
||||
|
||||
private File file;
|
||||
protected final File file;
|
||||
protected final GitHubService github;
|
||||
|
||||
public GitHubConnector() {
|
||||
this.file = new File("plugins/Slimefun/cache/github/" + this.getFileName() + ".json");
|
||||
SlimefunPlugin.getUtilities().connectors.add(this);
|
||||
public GitHubConnector(GitHubService github) {
|
||||
this.github = github;
|
||||
|
||||
file = new File("plugins/Slimefun/cache/github/" + this.getFileName() + ".json");
|
||||
}
|
||||
|
||||
public abstract String getFileName();
|
||||
@ -36,7 +37,7 @@ public abstract class GitHubConnector {
|
||||
}
|
||||
|
||||
public void pullFile() {
|
||||
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) {
|
||||
if (github.isLoggingEnabled()) {
|
||||
Slimefun.getLogger().log(Level.INFO, "Retrieving '" + this.getFileName() + ".json' from GitHub...");
|
||||
}
|
||||
|
||||
@ -55,7 +56,7 @@ public abstract class GitHubConnector {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (SlimefunPlugin.getCfg().getBoolean("options.print-out-github-data-retrieving")) {
|
||||
if (github.isLoggingEnabled()) {
|
||||
Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time.");
|
||||
}
|
||||
|
@ -0,0 +1,165 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.services.github;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.utils.NumberUtils;
|
||||
|
||||
public class GitHubService {
|
||||
|
||||
private final String repository;
|
||||
private final Set<GitHubConnector> connectors;
|
||||
private final ConcurrentMap<String, Contributor> contributors;
|
||||
|
||||
private boolean logging = false;
|
||||
|
||||
private int issues = 0;
|
||||
private int pullRequests = 0;
|
||||
private int forks = 0;
|
||||
private int stars = 0;
|
||||
private int codeBytes = 0;
|
||||
private Date lastUpdate = new Date();
|
||||
|
||||
public GitHubService(String repository) {
|
||||
this.repository = repository;
|
||||
|
||||
connectors = new HashSet<>();
|
||||
contributors = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public void connect(boolean logging) {
|
||||
this.logging = logging;
|
||||
|
||||
connectors.add(new ContributionsConnector(this, "code", repository, "&6Developer"));
|
||||
connectors.add(new ContributionsConnector(this, "wiki", "TheBusyBiscuit/Slimefun4-wiki", "&3Wiki Editor"));
|
||||
connectors.add(new ContributionsConnector(this, "resourcepack", "TheBusyBiscuit/Slimefun4-Resourcepack", "&cResourcepack Artist"));
|
||||
|
||||
connectors.add(new GitHubConnector(this) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(JsonElement element) {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
forks = object.get("forks").getAsInt();
|
||||
stars = object.get("stargazers_count").getAsInt();
|
||||
lastUpdate = NumberUtils.parseGitHubDate(object.get("pushed_at").getAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "repo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getURLSuffix() {
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
connectors.add(new GitHubConnector(this) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(JsonElement element) {
|
||||
JsonArray array = element.getAsJsonArray();
|
||||
|
||||
int issueCount = 0;
|
||||
int prCount = 0;
|
||||
|
||||
for (JsonElement elem : array) {
|
||||
JsonObject obj = elem.getAsJsonObject();
|
||||
if (obj.has("pull_request")) prCount++;
|
||||
else issueCount++;
|
||||
}
|
||||
|
||||
issues = issueCount;
|
||||
pullRequests = prCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "issues";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getURLSuffix() {
|
||||
return "/issues";
|
||||
}
|
||||
});
|
||||
|
||||
connectors.add(new GitHubConnector(this) {
|
||||
|
||||
@Override
|
||||
public void onSuccess(JsonElement element) {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
codeBytes = object.get("Java").getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return "languages";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getURLSuffix() {
|
||||
return "/languages";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Set<GitHubConnector> getConnectors() {
|
||||
return connectors;
|
||||
}
|
||||
|
||||
public ConcurrentMap<String, Contributor> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
public int getForks() {
|
||||
return forks;
|
||||
}
|
||||
|
||||
public int getStars() {
|
||||
return stars;
|
||||
}
|
||||
|
||||
public int getIssues() {
|
||||
return issues;
|
||||
}
|
||||
|
||||
public int getPullRequests() {
|
||||
return pullRequests;
|
||||
}
|
||||
|
||||
public int getCodeSize() {
|
||||
return codeBytes;
|
||||
}
|
||||
|
||||
public Date getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
protected boolean isLoggingEnabled() {
|
||||
return logging;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package me.mrCookieSlime.Slimefun.utils;
|
||||
package io.github.thebusybiscuit.slimefun4.core.utils;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
@ -10,9 +11,13 @@ public final class ChatUtils {
|
||||
|
||||
public static void sendURL(Player p, String url) {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(ChatColors.color("&7&oClick here:"));
|
||||
p.sendMessage(ChatColors.color("&eClick here:"));
|
||||
p.sendMessage(ChatColors.color("&7&o" + url));
|
||||
p.sendMessage("");
|
||||
}
|
||||
|
||||
public static String christmas(String text) {
|
||||
return ChatColors.alternating(text, ChatColor.GREEN, ChatColor.RED);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.hooks.github;
|
||||
package io.github.thebusybiscuit.slimefun4.core.utils;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
@ -9,17 +9,18 @@ import java.util.logging.Level;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public final class IntegerFormat {
|
||||
public final class NumberUtils {
|
||||
|
||||
private IntegerFormat() {}
|
||||
private NumberUtils() {}
|
||||
|
||||
public static String formatBigNumber(int i) {
|
||||
return NumberFormat.getNumberInstance(Locale.US).format(i);
|
||||
}
|
||||
|
||||
public static Date parseGitHubDate(String str) {
|
||||
public static Date parseGitHubDate(String date) {
|
||||
try {
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(str.replace('T', ' ').replace("Z", ""));
|
||||
// We have to create this instance here because it is not thread-safe and should not exist on a static level.
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(date.replace('T', ' ').replace("Z", ""));
|
||||
} catch (ParseException x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while parsing a GitHub-Date for Slimefun " + Slimefun.getVersion(), x);
|
||||
return null;
|
@ -7,9 +7,9 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
@ -33,7 +33,7 @@ public final class GEOScanner {
|
||||
}
|
||||
|
||||
try {
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQ0OWI5MzE4ZTMzMTU4ZTY0YTQ2YWIwZGUxMjFjM2Q0MDAwMGUzMzMyYzE1NzQ5MzJiM2M4NDlkOGZhMGRjMiJ9fX0="), "&eScanned Chunk", "", "&8\u21E8 &7World: " + chunk.getWorld().getName(), "&8\u21E8 &7X: " + chunk.getX() + " Z: " + chunk.getZ()), (pl, slot, stack, action) -> false);
|
||||
menu.addItem(4, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODQ0OWI5MzE4ZTMzMTU4ZTY0YTQ2YWIwZGUxMjFjM2Q0MDAwMGUzMzMyYzE1NzQ5MzJiM2M4NDlkOGZhMGRjMiJ9fX0="), "&eScanned Chunk", "", "&8\u21E8 &7World: " + chunk.getWorld().getName(), "&8\u21E8 &7X: " + chunk.getX() + " Z: " + chunk.getZ()), (pl, slot, stack, action) -> false);
|
||||
} catch (Exception e) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "Error while scanning a chunk for Slimefun " + Slimefun.getVersion(), e);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.logging.Level;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
@ -23,15 +23,17 @@ public final class OreGenSystem {
|
||||
public static void registerResource(OreGenResource resource) {
|
||||
Config cfg = new Config("plugins/Slimefun/generators/" + resource.getName() + ".yml");
|
||||
cfg.setDefaultValue("enabled", true);
|
||||
for (Biome biome: Biome.values()) {
|
||||
|
||||
for (Biome biome : Biome.values()) {
|
||||
cfg.setDefaultValue("spawn-rates." + biome.toString(), resource.getDefaultSupply(biome));
|
||||
}
|
||||
|
||||
cfg.save();
|
||||
|
||||
if (cfg.getBoolean("enabled")) {
|
||||
Slimefun.getLogger().log(Level.INFO, "Registering Ore Gen: " + resource.getName());
|
||||
SlimefunPlugin.getUtilities().resources.put(resource.getName(), resource);
|
||||
SlimefunPlugin.getUtilities().resource_configs.put(resource.getName(), cfg);
|
||||
SlimefunPlugin.getUtilities().resourceConfigs.put(resource.getName(), cfg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +46,7 @@ public final class OreGenSystem {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
int supply = SlimefunPlugin.getUtilities().resource_configs.get(resource.getName()).getInt("spawn-rates." + biome.toString());
|
||||
int supply = SlimefunPlugin.getUtilities().resourceConfigs.get(resource.getName()).getInt("spawn-rates." + biome.toString());
|
||||
return supply > 0 ? (supply + ThreadLocalRandom.current().nextInt(3)): 0;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public final class Elevator {
|
||||
pl.closeInventory();
|
||||
pl.sendMessage("");
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &ePlease enter a Name for this Floor in your Chat!"));
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &e(Chat Colors are supported!"));
|
||||
pl.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&l>> &e(Chat Colors are supported!)"));
|
||||
pl.sendMessage("");
|
||||
|
||||
ChatInput.waitForPlayer(SlimefunPlugin.instance, pl, message -> {
|
||||
|
@ -18,16 +18,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric.gps.GPSTransmitter;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public class GPSNetwork {
|
||||
|
||||
@ -84,18 +84,18 @@ public class GPSNetwork {
|
||||
}
|
||||
|
||||
try {
|
||||
menu.addItem(2, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &e(Selected)"));
|
||||
menu.addItem(2, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &e(Selected)"));
|
||||
menu.addMenuClickHandler(2,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
int complexity = getNetworkComplexity(p.getUniqueId());
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + complexity));
|
||||
menu.addItem(4, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + complexity));
|
||||
menu.addMenuClickHandler(4,
|
||||
(pl, slot, item, action) -> false
|
||||
);
|
||||
|
||||
menu.addItem(6, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &r(Select)"));
|
||||
menu.addItem(6, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &r(Select)"));
|
||||
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
|
||||
openWaypointControlPanel(pl);
|
||||
return false;
|
||||
@ -106,14 +106,14 @@ public class GPSNetwork {
|
||||
if (index >= inventory.length) break;
|
||||
|
||||
SlimefunItem sfi = BlockStorage.check(l);
|
||||
if (!(sfi instanceof GPSTransmitter)) continue;
|
||||
if (sfi instanceof GPSTransmitter) {
|
||||
int slot = inventory[index];
|
||||
|
||||
int slot = inventory[index];
|
||||
menu.addItem(slot, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&bGPS Transmitter", "&8\u21E8 &7World: &r" + l.getWorld().getName(), "&8\u21E8 &7X: &r" + l.getX(), "&8\u21E8 &7Y: &r" + l.getY(), "&8\u21E8 &7Z: &r" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &r" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &r" + DoubleHandler.fixDouble(1000D / l.getY()) + "ms"));
|
||||
menu.addMenuClickHandler(slot, (pl, slotn, item, action) -> false);
|
||||
|
||||
menu.addItem(slot, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&bGPS Transmitter", "&8\u21E8 &7World: &r" + l.getWorld().getName(), "&8\u21E8 &7X: &r" + l.getX(), "&8\u21E8 &7Y: &r" + l.getY(), "&8\u21E8 &7Z: &r" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &r" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &r" + DoubleHandler.fixDouble(1000D / l.getY()) + "ms"));
|
||||
menu.addMenuClickHandler(slot, (pl, slotn, item, action) -> false);
|
||||
|
||||
index++;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
} catch(Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while creating the GPS Transmitter Panel for Slimefun " + Slimefun.getVersion(), x);
|
||||
@ -126,16 +126,16 @@ public class GPSNetwork {
|
||||
Location l = entry.getValue();
|
||||
|
||||
if (entry.getKey().startsWith("&4Deathpoint")) {
|
||||
return CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWFlMzg1NWY5NTJjZDRhMDNjMTQ4YTk0NmUzZjgxMmE1OTU1YWQzNWNiY2I1MjYyN2VhNGFjZDQ3ZDMwODEifX19");
|
||||
return SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWFlMzg1NWY5NTJjZDRhMDNjMTQ4YTk0NmUzZjgxMmE1OTU1YWQzNWNiY2I1MjYyN2VhNGFjZDQ3ZDMwODEifX19");
|
||||
}
|
||||
else if (l.getWorld().getEnvironment() == Environment.NETHER) {
|
||||
return CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDgzNTcxZmY1ODlmMWE1OWJiMDJiODA4MDBmYzczNjExNmUyN2MzZGNmOWVmZWJlZGU4Y2YxZmRkZSJ9fX0=");
|
||||
return SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDgzNTcxZmY1ODlmMWE1OWJiMDJiODA4MDBmYzczNjExNmUyN2MzZGNmOWVmZWJlZGU4Y2YxZmRkZSJ9fX0=");
|
||||
}
|
||||
else if (l.getWorld().getEnvironment() == Environment.THE_END) {
|
||||
return CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzZjYWM1OWIyYWFlNDg5YWEwNjg3YjVkODAyYjI1NTVlYjE0YTQwYmQ2MmIyMWViMTE2ZmE1NjljZGI3NTYifX19");
|
||||
return SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzZjYWM1OWIyYWFlNDg5YWEwNjg3YjVkODAyYjI1NTVlYjE0YTQwYmQ2MmIyMWViMTE2ZmE1NjljZGI3NTYifX19");
|
||||
}
|
||||
else {
|
||||
return CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=");
|
||||
return SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0=");
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,17 +147,17 @@ public class GPSNetwork {
|
||||
}
|
||||
|
||||
try {
|
||||
menu.addItem(2, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &r(Select)"));
|
||||
menu.addItem(2, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBjOWMxYTAyMmY0MGI3M2YxNGI0Y2JhMzdjNzE4YzZhNTMzZjNhMjg2NGI2NTM2ZDVmNDU2OTM0Y2MxZiJ9fX0="), "&7Transmitter Overview &r(Select)"));
|
||||
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
|
||||
openTransmitterControlPanel(pl);
|
||||
return false;
|
||||
});
|
||||
|
||||
int complexity = getNetworkComplexity(p.getUniqueId());
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + complexity));
|
||||
menu.addItem(4, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGRjZmJhNThmYWYxZjY0ODQ3ODg0MTExODIyYjY0YWZhMjFkN2ZjNjJkNDQ4MWYxNGYzZjNiY2I2MzMwIn19fQ=="), "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE": "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &r" + complexity));
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> false);
|
||||
|
||||
menu.addItem(6, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Selected)"));
|
||||
menu.addItem(6, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Selected)"));
|
||||
menu.addMenuClickHandler(6, (pl, slot, item, action) -> false);
|
||||
|
||||
int index = 0;
|
||||
@ -256,7 +256,7 @@ public class GPSNetwork {
|
||||
}
|
||||
|
||||
try {
|
||||
menu.addItem(4, new CustomItem(CustomSkull.getItem("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Select a Destination)"));
|
||||
menu.addItem(4, new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzljODg4MWU0MjkxNWE5ZDI5YmI2MWExNmZiMjZkMDU5OTEzMjA0ZDI2NWRmNWI0MzliM2Q3OTJhY2Q1NiJ9fX0="), "&7Waypoint Overview &e(Select a Destination)"));
|
||||
menu.addMenuClickHandler(4, (pl, slot, item, action) -> false);
|
||||
|
||||
final Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D);
|
||||
|
@ -82,7 +82,7 @@ public final class TeleportationSequence {
|
||||
}
|
||||
|
||||
destination.getWorld().spawnParticle(Particle.PORTAL,new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()),progress * 2, 0.2F, 0.8F, 0.2F );
|
||||
destination.getWorld().playSound(destination, Sound.ENTITY_BLAZE_DEATH, 1F, 1.4F);
|
||||
destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F);
|
||||
SlimefunPlugin.getUtilities().teleporterUsers.remove(uuid);
|
||||
}
|
||||
else {
|
||||
@ -93,7 +93,7 @@ public final class TeleportationSequence {
|
||||
subtitle.send(TitleType.SUBTITLE, p);
|
||||
|
||||
source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F);
|
||||
source.getWorld().playSound(source, Sound.UI_BUTTON_CLICK, 1F, 0.6F);
|
||||
source.getWorld().playSound(source, Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package me.mrCookieSlime.Slimefun.Lists;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomArmor;
|
||||
import io.github.thebusybiscuit.slimefun4.core.utils.ChatUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.LockedCategory;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SeasonalCategory;
|
||||
import me.mrCookieSlime.Slimefun.utils.Christmas;
|
||||
|
||||
/**
|
||||
* Built-in categories.
|
||||
@ -23,29 +21,29 @@ public final class Categories {
|
||||
|
||||
private static final String LORE = "&a> Click to open";
|
||||
|
||||
public static final Category WEAPONS = new Category(new CustomItem(Material.GOLDEN_SWORD, "&7Weapons", "", LORE), 1);
|
||||
public static final Category WEAPONS = new Category(new CustomItem(SlimefunItems.BLADE_OF_VAMPIRES, "&7Weapons", "", LORE), 1);
|
||||
public static final Category TOOLS = new Category(new CustomItem(SlimefunItems.AUTO_SMELT_PICKAXE, "&7Tools", "", LORE), 1);
|
||||
public static final Category PORTABLE = new Category(new CustomItem(SlimefunItems.BACKPACK_MEDIUM, "&7Items", "", LORE), 1);
|
||||
public static final Category FOOD = new Category(new CustomItem(Material.APPLE, "&7Food", "", LORE), 2);
|
||||
public static final Category FOOD = new Category(new CustomItem(SlimefunItems.FORTUNE_COOKIE, "&7Food", "", LORE), 2);
|
||||
public static final Category MACHINES_1 = new Category(new CustomItem(Material.SMITHING_TABLE, "&7Basic Machines", "", LORE), 1);
|
||||
public static final LockedCategory ELECTRICITY = new LockedCategory(new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity", "", LORE), 4, MACHINES_1);
|
||||
public static final LockedCategory GPS = new LockedCategory(new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines", "", LORE), 4, MACHINES_1);
|
||||
public static final Category ARMOR = new Category(new CustomItem(Material.IRON_CHESTPLATE, "&7Armor", "", LORE), 2);
|
||||
public static final Category ARMOR = new Category(new CustomItem(SlimefunItems.DAMASCUS_STEEL_CHESTPLATE, "&7Armor", "", LORE), 2);
|
||||
public static final Category LUMPS_AND_MAGIC = new Category(new CustomItem(SlimefunItems.RUNE_ENDER, "&7Magical Items", "", LORE), 2);
|
||||
public static final Category MAGIC = new Category(new CustomItem(Material.ELYTRA, "&7Magical Gadgets", "", LORE), 3);
|
||||
public static final Category MAGIC = new Category(new CustomItem(SlimefunItems.INFUSED_ELYTRA, "&7Magical Gadgets", "", LORE), 3);
|
||||
public static final Category MISC = new Category(new CustomItem(SlimefunItems.CAN, "&7Miscellaneous", "", LORE), 2);
|
||||
public static final Category TECH = new Category(new CustomArmor(new CustomItem(Material.LEATHER_CHESTPLATE, "&7Technical Gadgets", "", LORE), Color.SILVER), 3);
|
||||
public static final Category TECH = new Category(new CustomItem(SlimefunItems.STEEL_JETPACK, "&7Technical Gadgets", "", LORE), 3);
|
||||
public static final Category RESOURCES = new Category(new CustomItem(SlimefunItems.SYNTHETIC_SAPPHIRE, "&7Resources", "", LORE), 1);
|
||||
public static final Category CARGO = new LockedCategory(new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management", "", LORE), 4, MACHINES_1);
|
||||
public static final Category TECH_MISC = new Category(new CustomItem(SlimefunItems.HEATING_COIL, "&7Technical Components", "", LORE), 2);
|
||||
public static final Category MAGIC_ARMOR = new Category(new CustomItem(SlimefunItems.ENDER_HELMET, "&7Magical Armor", "", LORE), 2);
|
||||
public static final Category TALISMANS_1 = new Category(new CustomItem(Material.EMERALD, "&7Talismans - &aTier I", "", LORE), 2);
|
||||
public static final LockedCategory TALISMANS_2 = new LockedCategory(new CustomItem(Material.EMERALD, "&7Talismans - &aTier II", "", LORE), 3, TALISMANS_1);
|
||||
public static final Category TOOLS = new Category(new CustomItem(Material.GOLDEN_PICKAXE, "&7Tools", "", LORE), 1);
|
||||
public static final Category TALISMANS_1 = new Category(new CustomItem(SlimefunItems.TALISMAN, "&7Talismans - &aTier I", "", LORE), 2);
|
||||
public static final LockedCategory TALISMANS_2 = new LockedCategory(new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II", "", LORE), 3, TALISMANS_1);
|
||||
|
||||
// Seasonal Categories
|
||||
public static final SeasonalCategory CHRISTMAS = new SeasonalCategory(12, 1, new CustomItem(Material.NETHER_STAR, Christmas.color("Christmas"), "", "&c> Click to help &aSanta"));
|
||||
public static final SeasonalCategory VALENTINES_DAY = new SeasonalCategory(2, 2, new CustomItem(Material.POPPY, "&dValentine's Day", "", "&d> Click to celebrate Love"));
|
||||
public static final SeasonalCategory EASTER = new SeasonalCategory(4, 2, new CustomItem(Material.EGG, "&6Easter", "", "&a> Click to paint some Eggs"));
|
||||
public static final SeasonalCategory CHRISTMAS = new SeasonalCategory(12, 1, new CustomItem(Material.NETHER_STAR, ChatUtils.christmas("Christmas") + " &7(December)", "", "&c> Click to help &aSanta"));
|
||||
public static final SeasonalCategory VALENTINES_DAY = new SeasonalCategory(2, 2, new CustomItem(Material.POPPY, "&dValentine's Day" + " &7(February)", "", "&d> Click to celebrate Love"));
|
||||
public static final SeasonalCategory EASTER = new SeasonalCategory(4, 2, new CustomItem(Material.EGG, "&6Easter" + " &7(April)", "", "&a> Click to paint some Eggs"));
|
||||
public static final SeasonalCategory BIRTHDAY = new SeasonalCategory(10, 1, new CustomItem(Material.FIREWORK_ROCKET, "&a&lTheBusyBiscuit's Birthday &7(26th October)", "", "&a> Click to celebrate with me"));
|
||||
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class RecipeType {
|
||||
|
||||
public static ItemStack getRecipeOutput(SlimefunItem machine, ItemStack input) {
|
||||
List<ItemStack[]> recipes = (machine instanceof SlimefunMachine ? ((SlimefunMachine) machine).getRecipes(): ((SlimefunGadget) machine).getRecipes());
|
||||
return recipes.get(((getRecipeInputs(machine).indexOf(input) * 2) + 1))[0];
|
||||
return recipes.get(((getRecipeInputs(machine).indexOf(input) * 2) + 1))[0].clone();
|
||||
}
|
||||
|
||||
public static ItemStack getRecipeOutputList(SlimefunItem machine, ItemStack[] input) {
|
||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
@ -18,11 +17,10 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomPotion;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.World.CustomSkull;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items.StormStaff;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.utils.Christmas;
|
||||
import me.mrCookieSlime.Slimefun.utils.MachineTier;
|
||||
@ -157,7 +155,7 @@ public final class SlimefunItems {
|
||||
public static final ItemStack CHRISTMAS_APPLE_PIE = new CustomItem(Material.PUMPKIN_PIE, "&rApple Pie");
|
||||
public static final ItemStack CHRISTMAS_HOT_CHOCOLATE = new CustomPotion("&6Hot Chocolate", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 14, 0), "", "&7&oRestores &b&o" + "7.0" + " &7&oHunger");
|
||||
public static final ItemStack CHRISTMAS_CAKE = new CustomItem(Material.PUMPKIN_PIE, Christmas.color("Christmas Cake"));
|
||||
public static final ItemStack CHRISTMAS_CARAMEL = new CustomItem(Material.BRICKS, "&6Caramel");
|
||||
public static final ItemStack CHRISTMAS_CARAMEL = new CustomItem(Material.BRICK, "&6Caramel");
|
||||
public static final ItemStack CHRISTMAS_CARAMEL_APPLE = new CustomItem(Material.APPLE, "&6Caramel Apple");
|
||||
public static final ItemStack CHRISTMAS_CHOCOLATE_APPLE = new CustomItem(Material.APPLE, "&6Chocolate Apple");
|
||||
public static final ItemStack CHRISTMAS_PRESENT = new CustomItem(Material.CHEST, Christmas.color("Christmas Present"), "&7From: &emrCookieSlime", "&7To: &eYou", "", "&eRight Click&7 to open");
|
||||
@ -462,6 +460,8 @@ public final class SlimefunItems {
|
||||
|
||||
/* Talisman */
|
||||
public static final ItemStack TALISMAN = new SlimefunItemStack("COMMON_TALISMAN", Material.EMERALD, "&6Common Talisman");
|
||||
public static final ItemStack ENDER_TALISMAN = new SlimefunItemStack("ENDER_TALISMAN", Material.EMERALD, "&5Ender Talisman");
|
||||
|
||||
public static final ItemStack TALISMAN_ANVIL = new SlimefunItemStack("ANVIL_TALISMAN", Material.EMERALD, "&aTalisman of the Anvil", "", "&rEach Talisman can prevent", "&r1 Tool from breaking, but will then", "&rbe consumed", "", "&4&lWARNING:", "&4This Talisman does not work on", "&4Tools which are too powerful", "&4due to their complexity");
|
||||
public static final ItemStack TALISMAN_MINER = new SlimefunItemStack("MINER_TALISMAN", Material.EMERALD, "&aTalisman of the Miner", "", "&rWhile you have this Talisman", "&rin your Inventory it has", "&ra 20% chance of doubling", "&rall Ores you mine");
|
||||
public static final ItemStack TALISMAN_HUNTER = new SlimefunItemStack("HUNTER_TALISMAN", Material.EMERALD, "&aTalisman of the Hunter", "", "&rWhile you have this Talisman", "&rin your Inventory it has", "&ra 20% chance of doubling", "&rall Drops from Mobs you kill");
|
||||
@ -543,6 +543,7 @@ public final class SlimefunItems {
|
||||
public static final ItemStack SOULBOUND_AXE = new SlimefunItemStack("SOULBOUND_AXE", Material.DIAMOND_AXE, "&cSoulbound Axe");
|
||||
public static final ItemStack SOULBOUND_SHOVEL = new SlimefunItemStack("SOULBOUND_SHOVEL", Material.DIAMOND_SHOVEL, "&cSoulbound Shovel");
|
||||
public static final ItemStack SOULBOUND_HOE = new SlimefunItemStack("SOULBOUND_HOE", Material.DIAMOND_HOE, "&cSoulbound Hoe");
|
||||
public static final ItemStack SOULBOUND_TRIDENT = new SlimefunItemStack("SOULBOUND_TRIDENT", Material.TRIDENT, "&cSoulbound Trident");
|
||||
|
||||
public static final ItemStack SOULBOUND_HELMET = new SlimefunItemStack("SOULBOUND_HELMET", Material.DIAMOND_HELMET, "&cSoulbound Helmet");
|
||||
public static final ItemStack SOULBOUND_CHESTPLATE = new SlimefunItemStack("SOULBOUND_CHESTPLATE", Material.DIAMOND_CHESTPLATE, "&cSoulbound Chestplate");
|
||||
@ -726,6 +727,9 @@ public final class SlimefunItems {
|
||||
public static final ItemStack ELECTRIC_SMELTERY = new SlimefunItemStack("ELECTRIC_SMELTERY", Material.FURNACE, "&cElectric Smeltery", "", "&4Alloys-Only, doesn't smelt Dust into Ingots", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 1x", "&8\u21E8 &e\u26A1 &720 J/s");
|
||||
public static final ItemStack ELECTRIC_SMELTERY_2 = new SlimefunItemStack("ELECTRIC_SMELTERY_2", Material.FURNACE, "&cElectric Smeltery &7- &eII", "", "&4Alloys-Only, doesn't smelt Dust into Ingots", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 3x", "&8\u21E8 &e\u26A1 &740 J/s");
|
||||
|
||||
public static final ItemStack ELECTRIC_PRESS = new SlimefunItemStack("ELECTRIC_PRESS", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGQ1Y2Y5MmJjNzllYzE5ZjQxMDY0NDFhZmZmZjE0MDZhMTM2NzAxMGRjYWZiMTk3ZGQ5NGNmY2ExYTZkZTBmYyJ9fX0=", "&eElectric Press", "", MachineTier.MEDIUM.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 1x", "&8\u21E8 &e\u26A1 &716 J/s");
|
||||
public static final ItemStack ELECTRIC_PRESS_2 = new SlimefunItemStack("ELECTRIC_PRESS_2", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGQ1Y2Y5MmJjNzllYzE5ZjQxMDY0NDFhZmZmZjE0MDZhMTM2NzAxMGRjYWZiMTk3ZGQ5NGNmY2ExYTZkZTBmYyJ9fX0=", "&eElectric Press &7- &eII", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 3x", "&8\u21E8 &e\u26A1 &740 J/s");
|
||||
|
||||
public static final ItemStack ELECTRIFIED_CRUCIBLE = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE", Material.RED_TERRACOTTA, "&cElectrified Crucible", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 1x", "&8\u21E8 &e\u26A1 &748 J/s");
|
||||
public static final ItemStack ELECTRIFIED_CRUCIBLE_2 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_2", Material.RED_TERRACOTTA, "&cElectrified Crucible &7- &eII", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 2x", "&8\u21E8 &e\u26A1 &780 J/s");
|
||||
public static final ItemStack ELECTRIFIED_CRUCIBLE_3 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_3", Material.RED_TERRACOTTA, "&cElectrified Crucible &7- &eIII", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &7Speed: 4x", "&8\u21E8 &e\u26A1 &7120 J/s");
|
||||
@ -757,7 +761,7 @@ public final class SlimefunItems {
|
||||
|
||||
public static final ItemStack AUTO_BREEDER = new SlimefunItemStack("AUTO_BREEDER", Material.HAY_BLOCK, "&eAuto-Breeder", "", "&rRuns on &aOrganic Food", "", MachineTier.END_GAME.and(MachineType.MACHINE), "&8\u21E8 &e\u26A1 &71024 J Buffer", "&8\u21E8 &e\u26A1 &760 J/Animal");
|
||||
|
||||
public static final ItemStack ORGANIC_FOOD = new CustomItem(getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ=="), "&aOrganic Food", "&7Content: &9X");
|
||||
public static final ItemStack ORGANIC_FOOD = new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ=="), "&aOrganic Food", "&7Content: &9X");
|
||||
public static final ItemStack WHEAT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_WHEAT", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Food", "&7Content: &9Wheat");
|
||||
public static final ItemStack CARROT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_CARROT", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Food", "&7Content: &9Carrots");
|
||||
public static final ItemStack POTATO_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_POTATO", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Food", "&7Content: &9Potatoes");
|
||||
@ -767,7 +771,7 @@ public final class SlimefunItems {
|
||||
public static final ItemStack APPLE_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_APPLE", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Food", "&7Content: &9Apple");
|
||||
public static final ItemStack SWEET_BERRIES_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SWEET_BERRIES", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Food", "&7Content: &9Sweet Berries");
|
||||
|
||||
public static final ItemStack FERTILIZER = new CustomItem(getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ=="), "&aOrganic Fertilizer", "&7Content: &9X");
|
||||
public static final ItemStack FERTILIZER = new CustomItem(SkullItem.fromBase64("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ=="), "&aOrganic Fertilizer", "&7Content: &9X");
|
||||
public static final ItemStack WHEAT_FERTILIZER = new SlimefunItemStack("FERTILIZER_WHEAT", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Fertilizer", "&7Content: &9Wheat");
|
||||
public static final ItemStack CARROT_FERTILIZER = new SlimefunItemStack("FERTILIZER_CARROT", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Fertilizer", "&7Content: &9Carrots");
|
||||
public static final ItemStack POTATO_FERTILIZER = new SlimefunItemStack("FERTILIZER_POTATO", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjQzOWUzZjVhY2JlZTliZTRjNDI1OTI4OWQ2ZDlmMzVjNjM1ZmZhNjYxMTE0Njg3YjNlYTZkZGE4Yzc5In19fQ==", "&aOrganic Fertilizer", "&7Content: &9Potatoes");
|
||||
@ -830,19 +834,8 @@ public final class SlimefunItems {
|
||||
|
||||
// ChestTerminal Addon
|
||||
|
||||
public static final ItemStack CHEST_TERMINAL = new CustomItem(getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2E0NGZmM2E1ZjQ5YzY5Y2FiNjc2YmFkOGQ5OGEwNjNmYTc4Y2ZhNjE5MTZmZGVmM2UyNjc1NTdmZWMxODI4MyJ9fX0="), "&3CT Access Terminal", "&7If this Block is connected to a", "&7Cargo Network, it will allow you to remotely", "&7interact with any Items supplied by", "&7Nodes tuned into the ChestTerminal Channel");
|
||||
public static final ItemStack CT_IMPORT_BUS = new CustomItem(getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTEzZGIyZTdlNzJlYTQ0MzJlZWZiZDZlNThhODVlYWEyNDIzZjgzZTY0MmNhNDFhYmM2YTkzMTc3NTdiODg5In19fQ=="), "&3CT Import Bus", "&7If this Block is connected to a", "&7Cargo Network, it will pull any Items from", "&7the Inventory it is attached to and place it", "&7into the CT Network Channel");
|
||||
public static final ItemStack CT_EXPORT_BUS = new CustomItem(getSkull("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTEzZGIyZTdlNzJlYTQ0MzJlZWZiZDZlNThhODVlYWEyNDIzZjgzZTY0MmNhNDFhYmM2YTkzMTc3NTdiODg5In19fQ=="), "&3CT Export Bus", "&7If this Block is connected to a", "&7Cargo Network, it will pull any Items from", "&7the CT Network Channel and place these", "&7into the Inventory it is attached to");
|
||||
|
||||
private static ItemStack getSkull(String texture) {
|
||||
try {
|
||||
return CustomSkull.getItem(texture);
|
||||
}
|
||||
catch(Exception x) {
|
||||
Slimefun.getLogger().log(Level.SEVERE, "An Error occured while initializing the Items for Slimefun " + Slimefun.getVersion(), x);
|
||||
|
||||
return new ItemStack(Material.PLAYER_HEAD);
|
||||
}
|
||||
}
|
||||
public static final ItemStack CHEST_TERMINAL = new SlimefunItemStack("CHEST_TERMINAL", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2E0NGZmM2E1ZjQ5YzY5Y2FiNjc2YmFkOGQ5OGEwNjNmYTc4Y2ZhNjE5MTZmZGVmM2UyNjc1NTdmZWMxODI4MyJ9fX0=", "&3CT Access Terminal", "&7If this Block is connected to a", "&7Cargo Network, it will allow you to remotely", "&7interact with any Items supplied by", "&7Nodes tuned into the ChestTerminal Channel");
|
||||
public static final ItemStack CT_IMPORT_BUS = new SlimefunItemStack("CT_IMPORT_BUS", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTEzZGIyZTdlNzJlYTQ0MzJlZWZiZDZlNThhODVlYWEyNDIzZjgzZTY0MmNhNDFhYmM2YTkzMTc3NTdiODg5In19fQ==", "&3CT Import Bus", "&7If this Block is connected to a", "&7Cargo Network, it will pull any Items from", "&7the Inventory it is attached to and place it", "&7into the CT Network Channel");
|
||||
public static final ItemStack CT_EXPORT_BUS = new SlimefunItemStack("CT_EXPORT_BUS", "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTEzZGIyZTdlNzJlYTQ0MzJlZWZiZDZlNThhODVlYWEyNDIzZjgzZTY0MmNhNDFhYmM2YTkzMTc3NTdiODg5In19fQ==", "&3CT Export Bus", "&7If this Block is connected to a", "&7Cargo Network, it will pull any Items from", "&7the CT Network Channel and place these", "&7into the Inventory it is attached to");
|
||||
|
||||
}
|
||||
|
@ -111,7 +111,6 @@ public class LockedCategory extends Category {
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasUnlocked(Player p) {
|
||||
return hasUnlocked(p, PlayerProfile.get(p));
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Particles.FireworkShow;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Events.ResearchUnlockEvent;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Setup.ResearchSetup;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
@ -228,16 +228,15 @@ public class Research {
|
||||
* @since 4.0
|
||||
*/
|
||||
public void unlock(final Player p, boolean instant) {
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", "0%"));
|
||||
}, 10L);
|
||||
if (!instant) {
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", "0%"));
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
PlayerProfile.get(p, profile -> {
|
||||
if (!profile.hasUnlocked(this)) {
|
||||
ResearchUnlockEvent event = new ResearchUnlockEvent(p, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
Runnable runnable = () -> {
|
||||
profile.setResearched(this, true);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.unlocked", true, msg -> msg.replace("%research%", getName()));
|
||||
@ -247,29 +246,34 @@ public class Research {
|
||||
}
|
||||
};
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (instant) {
|
||||
runnable.run();
|
||||
}
|
||||
else if (!SlimefunPlugin.getUtilities().researching.contains(p.getUniqueId())){
|
||||
SlimefunPlugin.getUtilities().researching.add(p.getUniqueId());
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.start", true, msg -> msg.replace("%research%", getName()));
|
||||
Slimefun.runSync(() -> {
|
||||
ResearchUnlockEvent event = new ResearchUnlockEvent(p, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
for (int i = 1; i < research_progress.length + 1; i++) {
|
||||
int j = i;
|
||||
if (!event.isCancelled()) {
|
||||
if (instant) {
|
||||
runnable.run();
|
||||
}
|
||||
else if (!SlimefunPlugin.getUtilities().researching.contains(p.getUniqueId())){
|
||||
SlimefunPlugin.getUtilities().researching.add(p.getUniqueId());
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.start", true, msg -> msg.replace("%research%", getName()));
|
||||
|
||||
for (int i = 1; i < research_progress.length + 1; i++) {
|
||||
int j = i;
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", research_progress[j - 1] + "%"));
|
||||
}, i * 20L);
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.progress", true, msg -> msg.replace("%research%", getName()).replace("%progress%", research_progress[j - 1] + "%"));
|
||||
}, i * 20L);
|
||||
runnable.run();
|
||||
SlimefunPlugin.getUtilities().researching.remove(p.getUniqueId());
|
||||
}, (research_progress.length + 1) * 20L);
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
runnable.run();
|
||||
SlimefunPlugin.getUtilities().researching.remove(p.getUniqueId());
|
||||
}, (research_progress.length + 1) * 20L);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
|
||||
@ -11,4 +12,8 @@ public class HandledBlock extends SlimefunItem {
|
||||
super(category, item, id, recipeType, recipe);
|
||||
}
|
||||
|
||||
public HandledBlock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,22 +12,49 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class MultiTool extends DamagableChargableItem {
|
||||
|
||||
private static final String PREFIX = "mode.";
|
||||
|
||||
private List<Integer> modes;
|
||||
|
||||
public MultiTool(ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) {
|
||||
super(Categories.TECH, item, id, recipeType, recipe, "Multi Tool", keys, values);
|
||||
public MultiTool(SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String... items) {
|
||||
super(Categories.TECH, item, recipeType, recipe, "Multi Tool", getKeys(items), getValues(items));
|
||||
}
|
||||
|
||||
public MultiTool(SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, String[] keys, Object[] values) {
|
||||
super(Categories.TECH, item, recipeType, recipe, "Multi Tool", keys, values);
|
||||
private static String[] getKeys(String... items) {
|
||||
String[] keys = new String[items.length * 2];
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
keys[i * 2] = PREFIX + i + ".enabled";
|
||||
keys[i * 2 + 1] = PREFIX + i + ".item";
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
private static Object[] getValues(String... items) {
|
||||
Object[] values = new Object[items.length * 2];
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
values[i * 2] = true;
|
||||
values[i * 2 + 1] = items[i];
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
if (Slimefun.getItemValue(this.getID(), "mode." + i + ".enabled") != null && (boolean) Slimefun.getItemValue(this.getID(), "mode." + i + ".enabled")) list.add(i);
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (Slimefun.getItemValue(this.getID(), PREFIX + i + ".enabled") != null) {
|
||||
if ((boolean) Slimefun.getItemValue(this.getID(), PREFIX + i + ".enabled")) {
|
||||
list.add(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
this.modes = list;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -13,9 +14,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.Placeable;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
@ -33,7 +36,7 @@ import me.mrCookieSlime.Slimefun.api.energy.EnergyNet;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyNetComponent;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.EnergyTicker;
|
||||
|
||||
public class SlimefunItem {
|
||||
public class SlimefunItem implements Placeable {
|
||||
|
||||
private String id;
|
||||
private ItemState state;
|
||||
@ -139,8 +142,7 @@ public class SlimefunItem {
|
||||
* @since 4.1.11
|
||||
*/
|
||||
public String getPermission() { return permission; }
|
||||
public List<String> getNoPermissionTooltip() { return noPermissionTooltip; }
|
||||
public boolean isTicking() { return ticking; }
|
||||
public List<String> getNoPermissionTooltip() { return noPermissionTooltip; }
|
||||
|
||||
/**
|
||||
* @since 4.1.11, rename of {@link #getTicker()}.
|
||||
@ -312,8 +314,8 @@ public class SlimefunItem {
|
||||
return sfi;
|
||||
}
|
||||
}
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BROKEN_SPAWNER, false)) return getByID("BROKEN_SPAWNER");
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.REPAIRED_SPAWNER, false)) return getByID("REINFORCED_SPAWNER");
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.BROKEN_SPAWNER, false)) return getByID("BROKEN_SPAWNER");
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.REPAIRED_SPAWNER, false)) return getByID("REINFORCED_SPAWNER");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -327,11 +329,11 @@ public class SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
if (this instanceof ChargableItem && SlimefunManager.isItemSimiliar(item, this.item, false)) return true;
|
||||
else if (this instanceof DamagableChargableItem && SlimefunManager.isItemSimiliar(item, this.item, false)) return true;
|
||||
else if (this instanceof ChargedItem && SlimefunManager.isItemSimiliar(item, this.item, false)) return true;
|
||||
else if (this instanceof SlimefunBackpack && SlimefunManager.isItemSimiliar(item, this.item, false)) return true;
|
||||
else return SlimefunManager.isItemSimiliar(item, this.item, true);
|
||||
if (this instanceof ChargableItem && SlimefunManager.isItemSimilar(item, this.item, false)) return true;
|
||||
else if (this instanceof DamagableChargableItem && SlimefunManager.isItemSimilar(item, this.item, false)) return true;
|
||||
else if (this instanceof ChargedItem && SlimefunManager.isItemSimilar(item, this.item, false)) return true;
|
||||
else if (this instanceof SlimefunBackpack && SlimefunManager.isItemSimilar(item, this.item, false)) return true;
|
||||
else return SlimefunManager.isItemSimilar(item, this.item, true);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@ -481,7 +483,7 @@ public class SlimefunItem {
|
||||
ItemStack[] recipe = sfi.getRecipe();
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (SlimefunManager.isItemSimiliar(recipe[i], old, true)) recipe[i] = stack;
|
||||
if (SlimefunManager.isItemSimilar(recipe[i], old, true)) recipe[i] = stack;
|
||||
}
|
||||
sfi.setRecipe(recipe);
|
||||
}
|
||||
@ -612,8 +614,22 @@ public class SlimefunItem {
|
||||
itemhandlers.stream().filter(c::isInstance).map(c::cast).forEach(callable);
|
||||
}
|
||||
|
||||
public boolean isTicking() {
|
||||
return ticking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SlimefunItem: " + id + " (" + state + ", vanilla=" + !addon + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops() {
|
||||
return Arrays.asList(item.clone());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getDrops(Player p) {
|
||||
return getDrops();
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.Soulbound;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SoulboundBackpack extends SlimefunBackpack {
|
||||
public class SoulboundBackpack extends SlimefunBackpack implements Soulbound {
|
||||
|
||||
public SoulboundBackpack(int size, Category category, SlimefunItemStack item, ItemStack[] recipe) {
|
||||
super(size, category, item, RecipeType.MAGIC_WORKBENCH, recipe);
|
||||
|
@ -125,6 +125,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock
|
||||
List<ItemStack> displayRecipes = new ArrayList<>(recipes.size() * 2);
|
||||
|
||||
for (MachineRecipe recipe: recipes) {
|
||||
if (recipe.getInput().length != 1) continue;
|
||||
|
||||
displayRecipes.add(recipe.getInput()[0]);
|
||||
displayRecipes.add(recipe.getOutput()[0]);
|
||||
}
|
||||
@ -192,7 +194,10 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock
|
||||
}
|
||||
else {
|
||||
inv.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||
pushItems(b, processing.get(b).getOutput().clone());
|
||||
|
||||
for (ItemStack output: processing.get(b).getOutput()) {
|
||||
inv.pushItem(output.clone(), getOutputSlots());
|
||||
}
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
@ -205,7 +210,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock
|
||||
for (MachineRecipe recipe: recipes) {
|
||||
for (ItemStack input: recipe.getInput()) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(inv.getItemInSlot(slot), input, true)) {
|
||||
if (SlimefunManager.isItemSimilar(inv.getItemInSlot(slot), input, true)) {
|
||||
found.put(slot, input.getAmount());
|
||||
break;
|
||||
}
|
||||
|
@ -188,9 +188,9 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
||||
}
|
||||
else {
|
||||
ItemStack fuel = processing.get(l).getInput();
|
||||
if (SlimefunManager.isItemSimiliar(fuel, new ItemStack(Material.LAVA_BUCKET), true)
|
||||
|| SlimefunManager.isItemSimiliar(fuel, SlimefunItems.BUCKET_OF_FUEL, true)
|
||||
|| SlimefunManager.isItemSimiliar(fuel, SlimefunItems.BUCKET_OF_OIL, true)) {
|
||||
if (SlimefunManager.isItemSimilar(fuel, new ItemStack(Material.LAVA_BUCKET), true)
|
||||
|| SlimefunManager.isItemSimilar(fuel, SlimefunItems.BUCKET_OF_FUEL, true)
|
||||
|| SlimefunManager.isItemSimilar(fuel, SlimefunItems.BUCKET_OF_OIL, true)) {
|
||||
inv.pushItem(new ItemStack(Material.BUCKET), getOutputSlots());
|
||||
}
|
||||
inv.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||
@ -226,7 +226,7 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
||||
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||
for (MachineFuel recipe: recipes) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||
found.put(slot, recipe.getInput().getAmount());
|
||||
return recipe;
|
||||
}
|
||||
@ -261,7 +261,6 @@ public abstract class AGenerator extends SlimefunItem implements RecipeDisplayIt
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
if (list.size() % 2 != 0) list.add(null);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
if (coolant) {
|
||||
if (port != null) {
|
||||
for (int slot: getCoolantSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), getCoolant(), true)) {
|
||||
if (SlimefunManager.isItemSimilar(port.getItemInSlot(slot), getCoolant(), true)) {
|
||||
port.replaceExistingItem(slot, menu.pushItem(port.getItemInSlot(slot), getCoolantSlots()));
|
||||
}
|
||||
}
|
||||
@ -291,7 +291,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
|
||||
boolean explosion = true;
|
||||
for (int slot: getCoolantSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), getCoolant(), true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), getCoolant(), true)) {
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
ReactorHologram.update(l, "&b\u2744 &7100%");
|
||||
explosion = false;
|
||||
@ -372,7 +372,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
private void restockFuel(BlockMenu menu, BlockMenu port) {
|
||||
for (int slot: getFuelSlots()) {
|
||||
for (MachineFuel recipe: recipes) {
|
||||
if (SlimefunManager.isItemSimiliar(port.getItemInSlot(slot), recipe.getInput(), true) && menu.fits(new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots())) {
|
||||
if (SlimefunManager.isItemSimilar(port.getItemInSlot(slot), recipe.getInput(), true) && menu.fits(new CustomItem(port.getItemInSlot(slot), 1), getFuelSlots())) {
|
||||
port.replaceExistingItem(slot, menu.pushItem(port.getItemInSlot(slot), getFuelSlots()));
|
||||
return;
|
||||
}
|
||||
@ -383,7 +383,7 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
private MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
|
||||
for (MachineFuel recipe: recipes) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), recipe.getInput(), true)) {
|
||||
found.put(slot, recipe.getInput().getAmount());
|
||||
return recipe;
|
||||
}
|
||||
@ -427,7 +427,6 @@ public abstract class AReactor extends SlimefunItem implements RecipeDisplayItem
|
||||
list.add(item);
|
||||
}
|
||||
|
||||
if (list.size() % 2 != 0) list.add(null);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,18 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class MachineFuel {
|
||||
|
||||
private int seconds;
|
||||
private int ticks;
|
||||
private ItemStack fuel;
|
||||
private ItemStack output;
|
||||
|
||||
public MachineFuel(int seconds, ItemStack fuel) {
|
||||
this.seconds = seconds * 2;
|
||||
this.ticks = seconds * 2;
|
||||
this.fuel = fuel;
|
||||
this.output = null;
|
||||
}
|
||||
|
||||
public MachineFuel(int seconds, ItemStack fuel, ItemStack output) {
|
||||
this.seconds = seconds * 2;
|
||||
this.ticks = seconds * 2;
|
||||
this.fuel = fuel;
|
||||
this.output = output;
|
||||
}
|
||||
@ -29,7 +29,7 @@ public class MachineFuel {
|
||||
}
|
||||
|
||||
public int getTicks() {
|
||||
return seconds;
|
||||
return ticks;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class DietCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@ -21,7 +20,7 @@ public class DietCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
p.sendMessage(ChatColor.YELLOW + "You feel so light...");
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_GENERIC_EAT, 1, 1);
|
||||
|
||||
|
@ -4,11 +4,9 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class EnderBackpack extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -20,7 +18,7 @@ public class EnderBackpack extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.ENDER_BACKPACK, true)) {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(p.getEnderChest());
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
|
@ -11,7 +11,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class FortuneCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@ -25,7 +24,7 @@ public class FortuneCookie extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
List<String> messages = SlimefunPlugin.getLocal().getMessages("messages.fortune-cookie");
|
||||
String message = messages.get(random.nextInt(messages.size()));
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -24,11 +22,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implements RecipeDisplayItem {
|
||||
|
||||
private final List<ItemStack> recipes;
|
||||
|
||||
private int chanceSiftedOre;
|
||||
private int chanceFlint;
|
||||
private int chanceClay;
|
||||
private int chanceIronNuggets;
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
private int weights;
|
||||
|
||||
public GoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe, new String[] {"chance.FLINT", "chance.CLAY", "chance.SIFTED_ORE", "chance.IRON_NUGGET"}, new Integer[] {40, 20, 35, 5});
|
||||
@ -43,10 +38,19 @@ public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implemen
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
chanceSiftedOre = (int) Slimefun.getItemValue(getID(), "chance.SIFTED_ORE");
|
||||
chanceClay = (int) Slimefun.getItemValue(getID(), "chance.CLAY");
|
||||
chanceFlint = (int) Slimefun.getItemValue(getID(), "chance.FLINT");
|
||||
chanceIronNuggets = (int) Slimefun.getItemValue(getID(), "chance.IRON_NUGGET");
|
||||
add(SlimefunItems.SIFTED_ORE, (int) Slimefun.getItemValue(getID(), "chance.SIFTED_ORE"));
|
||||
add(new ItemStack(Material.CLAY_BALL), (int) Slimefun.getItemValue(getID(), "chance.CLAY"));
|
||||
add(new ItemStack(Material.FLINT), (int) Slimefun.getItemValue(getID(), "chance.FLINT"));
|
||||
add(new ItemStack(Material.IRON_NUGGET), (int) Slimefun.getItemValue(getID(), "chance.IRON_NUGGET"));
|
||||
|
||||
if (weights < 100) {
|
||||
add(new ItemStack(Material.AIR), 100 - weights);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(ItemStack item, int chance) {
|
||||
randomizer.add(item, chance);
|
||||
weights += chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,19 +58,13 @@ public class GoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implemen
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.GRAVEL && SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
Random random = ThreadLocalRandom.current();
|
||||
|
||||
if (random.nextInt(100) < chanceSiftedOre) drops.add(SlimefunItems.SIFTED_ORE);
|
||||
else if (random.nextInt(100) < chanceClay) drops.add(new ItemStack(Material.CLAY_BALL));
|
||||
else if (random.nextInt(100) < chanceFlint) drops.add(new ItemStack(Material.FLINT));
|
||||
else if (random.nextInt(100) < chanceIronNuggets) drops.add(new ItemStack(Material.IRON_NUGGET));
|
||||
ItemStack output = randomizer.getRandom();
|
||||
|
||||
e.getClickedBlock().getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, e.getClickedBlock().getType());
|
||||
e.getClickedBlock().setType(Material.AIR);
|
||||
|
||||
for (ItemStack drop: drops) {
|
||||
e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), drop);
|
||||
if (output.getType() != Material.AIR) {
|
||||
e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), output.clone());
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
|
@ -18,7 +18,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.utils.Utilities;
|
||||
@ -36,7 +35,7 @@ public class GrapplingHook extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
Utilities utilities = SlimefunPlugin.getUtilities();
|
||||
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
|
||||
if (e.getClickedBlock() == null && !utilities.jumpState.containsKey(uuid)) {
|
||||
|
@ -9,7 +9,6 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
@ -26,7 +25,7 @@ public class HerculesPickaxe extends SimpleSlimefunItem<BlockBreakHandler> {
|
||||
@Override
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.HERCULES_PICKAXE, true) && e.getBlock().getType().toString().endsWith("_ORE")) {
|
||||
if (isItem(item) && e.getBlock().getType().toString().endsWith("_ORE")) {
|
||||
if (e.getBlock().getType() == Material.IRON_ORE) {
|
||||
drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2));
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class InfernalBonemeal extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -23,7 +22,7 @@ public class InfernalBonemeal extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.NETHER_WART) {
|
||||
Ageable ageable = (Ageable) e.getClickedBlock().getBlockData();
|
||||
if (ageable.getAge() < ageable.getMaximumAge()) {
|
||||
|
@ -10,13 +10,11 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Research;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.PlayerProfile;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
@ -29,26 +27,26 @@ public class KnowledgeTome extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
List<String> lore = item.getItemMeta().getLore();
|
||||
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
||||
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
||||
if (isItem(item)) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
im.setLore(lore);
|
||||
item.setItemMeta(im);
|
||||
p.getEquipment().setItemInMainHand(item);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||
return true;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(item, getItem(), false)) {
|
||||
PlayerProfile.get(p, profile -> {
|
||||
PlayerProfile.fromUUID(UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1))), owner -> {
|
||||
List<String> lore = im.getLore();
|
||||
if (lore.get(1).isEmpty()) {
|
||||
lore.set(0, ChatColor.translateAlternateColorCodes('&', "&7Owner: &b" + p.getName()));
|
||||
lore.set(1, ChatColor.BLACK + "" + p.getUniqueId());
|
||||
im.setLore(lore);
|
||||
item.setItemMeta(im);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F);
|
||||
} else {
|
||||
UUID uuid = UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1)));
|
||||
if (p.getUniqueId().equals(uuid))
|
||||
return true;
|
||||
PlayerProfile.get(p, profile -> PlayerProfile.fromUUID(uuid, owner -> {
|
||||
Set<Research> researches = owner.getResearches();
|
||||
researches.forEach(research -> profile.setResearched(research, true));
|
||||
});
|
||||
});
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(item, false);
|
||||
researches.forEach(research -> research.unlock(p, true));
|
||||
}));
|
||||
if (p.getGameMode() != GameMode.CREATIVE)
|
||||
item.setAmount(item.getAmount() - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
@ -16,7 +16,6 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.NotPlaceable;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements NotPlaceable {
|
||||
@ -33,7 +32,7 @@ public class LumberAxe extends SimpleSlimefunItem<BlockBreakHandler> implements
|
||||
@Override
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (SlimefunManager.isItemSimiliar(e.getPlayer().getInventory().getItemInMainHand(), getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
if (MaterialCollections.getAllLogs().contains(e.getBlock().getType())) {
|
||||
List<Block> logs = Vein.find(e.getBlock(), 100, b -> MaterialCollections.getAllLogs().contains(b.getType()));
|
||||
|
||||
|
@ -24,7 +24,12 @@ public class MagicEyeOfEnder extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
if (isItem(item)) {
|
||||
e.getParentEvent().setCancelled(true);
|
||||
|
||||
if (p.getInventory().getHelmet() != null && p.getInventory().getChestplate() != null && p.getInventory().getLeggings() != null && p.getInventory().getBoots() != null && SlimefunManager.isItemSimiliar(p.getInventory().getHelmet(), SlimefunItems.ENDER_HELMET, true) && SlimefunManager.isItemSimiliar(p.getInventory().getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) && SlimefunManager.isItemSimiliar(p.getInventory().getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) && SlimefunManager.isItemSimiliar(p.getInventory().getBoots(), SlimefunItems.ENDER_BOOTS, true)) {
|
||||
if (
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getHelmet(), SlimefunItems.ENDER_HELMET, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) &&
|
||||
SlimefunManager.isItemSimilar(p.getInventory().getBoots(), SlimefunItems.ENDER_BOOTS, true)
|
||||
) {
|
||||
p.launchProjectile(EnderPearl.class);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 1, 1);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemConsumptionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class MonsterJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@ -21,7 +20,7 @@ public class MonsterJerky extends SimpleSlimefunItem<ItemConsumptionHandler> {
|
||||
@Override
|
||||
public ItemConsumptionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
SlimefunPlugin.instance.getServer().getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
|
||||
if (p.hasPotionEffect(PotionEffectType.HUNGER)) {
|
||||
p.removePotionEffect(PotionEffectType.HUNGER);
|
||||
|
@ -1,15 +1,13 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -23,13 +21,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> implements RecipeDisplayItem {
|
||||
|
||||
private final List<ItemStack> recipes;
|
||||
|
||||
private int chanceQuartz;
|
||||
private int chanceGoldNuggets;
|
||||
private int chanceNetherWart;
|
||||
private int chanceBlazePowder;
|
||||
private int chanceGlowstoneDust;
|
||||
private int chanceGhastTear;
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
private int weights;
|
||||
|
||||
public NetherGoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe,
|
||||
@ -49,12 +42,21 @@ public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> im
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
chanceQuartz = (int) Slimefun.getItemValue(getID(), "chance.QUARTZ");
|
||||
chanceGoldNuggets = (int) Slimefun.getItemValue(getID(), "chance.GOLD_NUGGET");
|
||||
chanceNetherWart = (int) Slimefun.getItemValue(getID(), "chance.NETHER_WART");
|
||||
chanceBlazePowder = (int) Slimefun.getItemValue(getID(), "chance.BLAZE_POWDER");
|
||||
chanceGlowstoneDust = (int) Slimefun.getItemValue(getID(), "chance.GLOWSTONE_DUST");
|
||||
chanceGhastTear = (int) Slimefun.getItemValue(getID(), "chance.GHAST_TEAR");
|
||||
add(new ItemStack(Material.QUARTZ), (int) Slimefun.getItemValue(getID(), "chance.QUARTZ"));
|
||||
add(new ItemStack(Material.GOLD_NUGGET), (int) Slimefun.getItemValue(getID(), "chance.GOLD_NUGGET"));
|
||||
add(new ItemStack(Material.NETHER_WART), (int) Slimefun.getItemValue(getID(), "chance.NETHER_WART"));
|
||||
add(new ItemStack(Material.BLAZE_POWDER), (int) Slimefun.getItemValue(getID(), "chance.BLAZE_POWDER"));
|
||||
add(new ItemStack(Material.GLOWSTONE_DUST), (int) Slimefun.getItemValue(getID(), "chance.GLOWSTONE_DUST"));
|
||||
add(new ItemStack(Material.GHAST_TEAR), (int) Slimefun.getItemValue(getID(), "chance.GHAST_TEAR"));
|
||||
|
||||
if (weights < 100) {
|
||||
add(new ItemStack(Material.AIR), 100 - weights);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(ItemStack item, int chance) {
|
||||
randomizer.add(item, chance);
|
||||
weights += chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,21 +64,13 @@ public class NetherGoldPan extends SimpleSlimefunItem<ItemInteractionHandler> im
|
||||
return (e, p, item) -> {
|
||||
if (isItem(item)) {
|
||||
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.SOUL_SAND && SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.BREAK_BLOCK)) {
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
Random random = ThreadLocalRandom.current();
|
||||
|
||||
if (random.nextInt(100) < chanceQuartz) drops.add(new ItemStack(Material.QUARTZ));
|
||||
else if (random.nextInt(100) < chanceGoldNuggets) drops.add(new ItemStack(Material.GOLD_NUGGET));
|
||||
else if (random.nextInt(100) < chanceNetherWart) drops.add(new ItemStack(Material.NETHER_WART));
|
||||
else if (random.nextInt(100) < chanceBlazePowder) drops.add(new ItemStack(Material.BLAZE_POWDER));
|
||||
else if (random.nextInt(100) < chanceGlowstoneDust) drops.add(new ItemStack(Material.GLOWSTONE_DUST));
|
||||
else if (random.nextInt(100) < chanceGhastTear) drops.add(new ItemStack(Material.GHAST_TEAR));
|
||||
ItemStack output = randomizer.getRandom();
|
||||
|
||||
e.getClickedBlock().getWorld().playEffect(e.getClickedBlock().getLocation(), Effect.STEP_SOUND, e.getClickedBlock().getType());
|
||||
e.getClickedBlock().setType(Material.AIR);
|
||||
|
||||
for (ItemStack drop: drops) {
|
||||
e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), drop);
|
||||
if (output.getType() != Material.AIR) {
|
||||
e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), output.clone());
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
|
@ -14,7 +14,6 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockBreakHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
@ -32,7 +31,7 @@ public class PickaxeOfContainment extends SimpleSlimefunItem<BlockBreakHandler>
|
||||
@Override
|
||||
public BlockBreakHandler getItemHandler() {
|
||||
return (e, item, fortune, drops) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
// Refactored it into this so we don't need to call e.getBlock() all the time.
|
||||
Block b = e.getBlock();
|
||||
if (b.getType() != Material.SPAWNER) return true;
|
||||
|
@ -4,11 +4,9 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PortableCrafter extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -20,7 +18,7 @@ public class PortableCrafter extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PORTABLE_CRAFTER, true)) {
|
||||
if (isItem(item)) {
|
||||
p.openWorkbench(p.getLocation(), true);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1);
|
||||
return true;
|
||||
|
@ -6,11 +6,9 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class PortableDustbin extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -22,7 +20,7 @@ public class PortableDustbin extends SimpleSlimefunItem<ItemInteractionHandler>
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.PORTABLE_DUSTBIN, true)) {
|
||||
if (isItem(item)) {
|
||||
e.setCancelled(true);
|
||||
p.openInventory(Bukkit.createInventory(null, 9 * 3, ChatColor.DARK_RED + "Delete Items"));
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 1);
|
||||
|
@ -38,7 +38,7 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
|
||||
public ItemDropHandler getItemHandler() {
|
||||
return (e, p, i) -> {
|
||||
ItemStack item = i.getItemStack();
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.RUNE_SOULBOUND, true)) {
|
||||
if (isItem(item)) {
|
||||
|
||||
if (!Slimefun.hasUnlocked(p, SlimefunItems.RUNE_SOULBOUND, true)) {
|
||||
return true;
|
||||
@ -50,8 +50,9 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
|
||||
|
||||
Location l = i.getLocation();
|
||||
Collection<Entity> entites = l.getWorld().getNearbyEntities(l, 1.5, 1.5, 1.5,
|
||||
entity -> entity instanceof Item && !SlimefunManager.isItemSoulbound(((Item) entity).getItemStack()) &&
|
||||
!SlimefunManager.isItemSimiliar(((Item) entity).getItemStack(), SlimefunItems.RUNE_SOULBOUND, true)
|
||||
entity -> entity instanceof Item &&
|
||||
!SlimefunManager.isItemSoulbound(((Item) entity).getItemStack()) &&
|
||||
!SlimefunManager.isItemSimilar(((Item) entity).getItemStack(), SlimefunItems.RUNE_SOULBOUND, true)
|
||||
);
|
||||
|
||||
if (entites.isEmpty()) return;
|
||||
@ -68,7 +69,7 @@ public class SoulboundRune extends SimpleSlimefunItem<ItemDropHandler> {
|
||||
|
||||
// This lightning is just an effect, it deals no damage.
|
||||
l.getWorld().strikeLightningEffect(l);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> {
|
||||
Slimefun.runSync(() -> {
|
||||
|
||||
// Being sure entities are still valid and not picked up or whatsoever.
|
||||
if (i.isValid() && ent.isValid()) {
|
||||
|
@ -21,7 +21,6 @@ import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class StormStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -49,9 +48,7 @@ public class StormStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
//Not checking if lores equals because we need a special one for that.
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), false)) {
|
||||
|
||||
if (isItem(item)) {
|
||||
if (!item.hasItemMeta()) return false;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (!itemMeta.hasLore()) return false;
|
||||
|
@ -16,7 +16,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.EntityKillHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
@ -42,7 +41,7 @@ public class SwordOfBeheading extends SimpleSlimefunItem<EntityKillHandler> {
|
||||
@Override
|
||||
public EntityKillHandler getItemHandler() {
|
||||
return (e, entity, killer, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
if (e.getEntity() instanceof Zombie) {
|
||||
if (random.nextInt(100) < chanceZombie) {
|
||||
e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD));
|
||||
|
@ -13,7 +13,6 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SimpleSlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class WindStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@ -25,7 +24,7 @@ public class WindStaff extends SimpleSlimefunItem<ItemInteractionHandler> {
|
||||
@Override
|
||||
public ItemInteractionHandler getItemHandler() {
|
||||
return (e, p, item) -> {
|
||||
if (SlimefunManager.isItemSimiliar(item, getItem(), true)) {
|
||||
if (isItem(item)) {
|
||||
if (p.getFoodLevel() >= 2) {
|
||||
if (p.getInventory().getItemInMainHand().getType() != Material.SHEARS && p.getGameMode() != GameMode.CREATIVE) {
|
||||
FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2);
|
||||
|
@ -71,7 +71,7 @@ public class Composter extends SlimefunGadget {
|
||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
|
@ -3,19 +3,17 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Levelled;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.materials.MaterialCollections;
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.events.ItemUseEvent;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
@ -24,6 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemInteractionHandler;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class Crucible extends SlimefunGadget {
|
||||
@ -59,59 +58,91 @@ public class Crucible extends SlimefunGadget {
|
||||
|
||||
return items.toArray(new ItemStack[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRegister() {
|
||||
addItemHandler(new ItemInteractionHandler() {
|
||||
addItemHandler((ItemInteractionHandler) (e, p, item) -> {
|
||||
if (e.getClickedBlock() != null) {
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id != null && id.equals("CRUCIBLE")) {
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
final ItemStack input = p.getInventory().getItemInMainHand();
|
||||
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||
|
||||
@Override
|
||||
public boolean onRightClick(ItemUseEvent e, final Player p, ItemStack item) {
|
||||
if (e.getClickedBlock() != null) {
|
||||
String id = BlockStorage.checkID(e.getClickedBlock());
|
||||
if (id != null && id.equals("CRUCIBLE")) {
|
||||
if (p.hasPermission("slimefun.inventory.bypass") || SlimefunPlugin.getProtectionManager().hasPermission(p, e.getClickedBlock().getLocation(), ProtectableAction.ACCESS_INVENTORIES)) {
|
||||
final ItemStack input = p.getInventory().getItemInMainHand();
|
||||
final Block block = e.getClickedBlock().getRelative(BlockFace.UP);
|
||||
SlimefunItem machine = SlimefunItem.getByID(id);
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
||||
if (SlimefunManager.isItemSimilar(input, convert, true)) {
|
||||
e.setCancelled(true);
|
||||
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(machine)) {
|
||||
if (input != null && SlimefunManager.isItemSimiliar(input, convert, true)) {
|
||||
e.setCancelled(true);
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
ItemStack removing = input.clone();
|
||||
removing.setAmount(convert.getAmount());
|
||||
p.getInventory().removeItem(removing);
|
||||
|
||||
p.getInventory().removeItem(removing);
|
||||
|
||||
for (int i = 1; i < 9; i++) {int j = 8 - i;
|
||||
Bukkit.getScheduler().runTaskLater(SlimefunPlugin.instance, () -> {
|
||||
if (input.getType() == Material.COBBLESTONE || input.getType() == Material.TERRACOTTA || MaterialCollections.getAllTerracottaColors().contains(input.getType())) {
|
||||
block.setType(Material.LAVA);
|
||||
Levelled le = (Levelled) block.getBlockData();
|
||||
le.setLevel(j);
|
||||
block.setBlockData(le, false);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_POP, 1F, 1F);
|
||||
}
|
||||
else if (Tag.LEAVES.isTagged(input.getType())) {
|
||||
block.setType(Material.WATER);
|
||||
Levelled le = (Levelled) block.getBlockData();
|
||||
le.setLevel(j);
|
||||
block.setBlockData(le, false);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||
}
|
||||
}, i*50L);
|
||||
boolean water = Tag.LEAVES.isTagged(input.getType());
|
||||
if (block.getType() == (water ? Material.WATER : Material.LAVA)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
if (level > 7)
|
||||
level -= 8;
|
||||
if (level == 0) {
|
||||
block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F);
|
||||
} else {
|
||||
int finalLevel = 7 - level;
|
||||
Slimefun.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (block.getType() == (water ? Material.LAVA : Material.WATER)) {
|
||||
int level = ((Levelled) block.getBlockData()).getLevel();
|
||||
block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
return true;
|
||||
}
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
if (!block.getType().isAir()) {
|
||||
if (water) {
|
||||
if (block.getBlockData() instanceof Waterlogged) {
|
||||
Waterlogged wl = (Waterlogged) block.getBlockData();
|
||||
wl.setWaterlogged(true);
|
||||
block.setBlockData(wl, false);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
if (BlockStorage.hasBlockInfo(block))
|
||||
BlockStorage.clearBlockInfo(block);
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
|
||||
}
|
||||
block.setType(water ? Material.WATER : Material.LAVA);
|
||||
runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1);
|
||||
}, 50L);
|
||||
|
||||
return true;
|
||||
}
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
return true;
|
||||
}
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.wrong-item", true);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private void runPostTask(Block block, Sound sound, int times) {
|
||||
if (!(block.getBlockData() instanceof Levelled)) {
|
||||
block.getWorld().playSound(block.getLocation(), Sound.BLOCK_METAL_BREAK, 1F, 1F);
|
||||
return;
|
||||
}
|
||||
block.getWorld().playSound(block.getLocation(), sound, 1F, 1F);
|
||||
int level = 8 - times;
|
||||
Levelled le = (Levelled) block.getBlockData();
|
||||
le.setLevel(level);
|
||||
block.setBlockData(le, false);
|
||||
if (times < 8)
|
||||
Slimefun.runSync(() -> runPostTask(block, sound, times + 1), 50L);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ public class ReactorAccessPort extends SlimefunItem {
|
||||
@Override
|
||||
public int[] getSlotsAccessedByItemTransport(BlockMenu menu, ItemTransportFlow flow, ItemStack item) {
|
||||
if (flow == ItemTransportFlow.INSERT) {
|
||||
if (SlimefunManager.isItemSimiliar(item, SlimefunItems.REACTOR_COOLANT_CELL, true)) return getCoolantSlots();
|
||||
else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.NETHER_ICE_COOLANT_CELL, true)) return getCoolantSlots();
|
||||
if (SlimefunManager.isItemSimilar(item, SlimefunItems.REACTOR_COOLANT_CELL, true)) return getCoolantSlots();
|
||||
else if (SlimefunManager.isItemSimilar(item, SlimefunItems.NETHER_ICE_COOLANT_CELL, true)) return getCoolantSlots();
|
||||
else return getFuelSlots();
|
||||
}
|
||||
else return getOutputSlots();
|
||||
|
@ -90,7 +90,7 @@ public class AnimalGrowthAccelerator extends SlimefunItem implements InventoryBl
|
||||
protected void tick(Block b) {
|
||||
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 3.0, 3.0, 3.0, n -> n instanceof Ageable && n.isValid() && !((Ageable) n).isAdult())) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
if (ChargableBlock.getCharge(b) < energyConsumption) return;
|
||||
|
||||
ChargableBlock.addCharge(b, -energyConsumption);
|
||||
|
@ -66,7 +66,7 @@ public abstract class AutoAnvil extends AContainer {
|
||||
}
|
||||
else {
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||
pushItems(b, processing.get(b).getOutput());
|
||||
menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
@ -80,7 +80,7 @@ public abstract class AutoAnvil extends AContainer {
|
||||
ItemStack item = menu.getItemInSlot(slot);
|
||||
|
||||
if (item != null && item.getType().getMaxDurability() > 0 && ((Damageable) item.getItemMeta()).getDamage() > 0) {
|
||||
if (SlimefunManager.isItemSimiliar(target, SlimefunItems.DUCT_TAPE, true)) {
|
||||
if (SlimefunManager.isItemSimilar(target, SlimefunItems.DUCT_TAPE, true)) {
|
||||
ItemStack newItem = item.clone();
|
||||
short durability = (short) (((Damageable) newItem.getItemMeta()).getDamage() - (item.getType().getMaxDurability() / getRepairFactor()));
|
||||
if (durability < 0) durability = 0;
|
||||
@ -94,7 +94,7 @@ public abstract class AutoAnvil extends AContainer {
|
||||
}
|
||||
|
||||
if (recipe != null) {
|
||||
if (!fits(b, recipe.getOutput())) return;
|
||||
if (!menu.fits(recipe.getOutput()[0], getOutputSlots())) return;
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
|
@ -83,7 +83,7 @@ public class AutoBreeder extends SlimefunItem implements InventoryBlock {
|
||||
protected void tick(Block b) {
|
||||
for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), 4.0, 2.0, 4.0, n -> n instanceof Animals && n.isValid() && ((Animals) n).isAdult() && !((Animals) n).isLoveMode())) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
|
||||
if (ChargableBlock.getCharge(b) < energyConsumption) return;
|
||||
|
||||
ChargableBlock.addCharge(b, -energyConsumption);
|
||||
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Events.AutoDisenchantEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -32,6 +31,8 @@ import me.mrCookieSlime.Slimefun.utils.MachineHelper;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.Repairable;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AutoDisenchantEvent;
|
||||
|
||||
public class AutoDisenchanter extends AContainer {
|
||||
|
||||
public AutoDisenchanter(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
@ -82,7 +83,7 @@ public class AutoDisenchanter extends AContainer {
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
Set<ItemEnchantment> enchantments2 = new HashSet<>();
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
ItemStack target = menu.getItemInSlot(slot == getInputSlots()[0] ? getInputSlots()[1]: getInputSlots()[0]);
|
||||
ItemStack item = menu.getItemInSlot(slot);
|
||||
|
||||
@ -107,16 +108,18 @@ public class AutoDisenchanter extends AContainer {
|
||||
if (item != null && target != null && target.getType() == Material.BOOK) {
|
||||
int amount = 0;
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> e: item.getEnchantments().entrySet()) {
|
||||
for (Map.Entry<Enchantment, Integer> e : item.getEnchantments().entrySet()) {
|
||||
enchantments.put(e.getKey(), e.getValue());
|
||||
amount++;
|
||||
}
|
||||
|
||||
if (SlimefunPlugin.getHooks().isEmeraldEnchantsInstalled()) {
|
||||
for (ItemEnchantment enchantment: EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
||||
for (ItemEnchantment enchantment : EmeraldEnchants.getInstance().getRegistry().getEnchantments(item)) {
|
||||
amount++;
|
||||
enchantments2.add(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount > 0) {
|
||||
ItemStack newItem = item.clone();
|
||||
newItem.setAmount(1);
|
||||
@ -133,13 +136,14 @@ public class AutoDisenchanter extends AContainer {
|
||||
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getItemMeta();
|
||||
|
||||
for (Map.Entry<Enchantment,Integer> e: enchantments.entrySet()) {
|
||||
for (Map.Entry<Enchantment,Integer> e : enchantments.entrySet()) {
|
||||
newItem.removeEnchantment(e.getKey());
|
||||
meta.addStoredEnchant(e.getKey(), e.getValue(), true);
|
||||
}
|
||||
|
||||
book.setItemMeta(meta);
|
||||
|
||||
for (ItemEnchantment e: enchantments2) {
|
||||
for (ItemEnchantment e : enchantments2) {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(book, e.getEnchantment(), e.getLevel());
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(newItem, e.getEnchantment(), 0);
|
||||
}
|
||||
@ -153,7 +157,7 @@ public class AutoDisenchanter extends AContainer {
|
||||
if (recipe != null) {
|
||||
if (!fits(b, recipe.getOutput())) return;
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
for (int slot : getInputSlots()) {
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class AutoDrier extends AContainer implements RecipeDisplayItem {
|
||||
ItemStack output = null;
|
||||
|
||||
for (int i = 0; i < recipeList.size(); i += 2) {
|
||||
if (SlimefunManager.isItemSimiliar(item, recipeList.get(i), true)) {
|
||||
if (SlimefunManager.isItemSimilar(item, recipeList.get(i), true)) {
|
||||
output = recipeList.get(i + 1);
|
||||
}
|
||||
}
|
||||
|
@ -212,8 +212,8 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
|
||||
if (SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.containsKey(input)) {
|
||||
ItemStack output = SlimefunPlugin.getUtilities().automatedCraftingChamberRecipes.get(input).clone();
|
||||
|
||||
if (fits(b, output)) {
|
||||
pushItems(b, output);
|
||||
if (menu.fits(output, getOutputSlots())) {
|
||||
menu.pushItem(output, getOutputSlots());
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
for (int j = 0; j < 9; j++) {
|
||||
if (menu.getItemInSlot(getInputSlots()[j]) != null) menu.replaceExistingItem(getInputSlots()[j], InvUtils.decreaseItem(menu.getItemInSlot(getInputSlots()[j]), 1));
|
||||
|
@ -105,7 +105,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
|
||||
protected void tick(Block b) {
|
||||
if (work(b) > 0) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.FERTILIZER, false)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.FERTILIZER, false)) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
|
||||
break;
|
||||
}
|
||||
@ -121,7 +121,7 @@ public abstract class CropGrowthAccelerator extends SlimefunItem implements Inve
|
||||
Block block = b.getRelative(x, 0, z);
|
||||
if (crops.containsKey(block.getType()) && ((Ageable) block.getBlockData()).getAge() < crops.get(block.getType())) {
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.FERTILIZER, false)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.FERTILIZER, false)) {
|
||||
if (work > (getSpeed() - 1) || ChargableBlock.getCharge(b) < getEnergyConsumption()) return work;
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
|
||||
|
@ -59,7 +59,7 @@ public abstract class ElectricDustWasher extends AContainer {
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||
pushItems(b, processing.get(b).getOutput());
|
||||
menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
@ -69,7 +69,7 @@ public abstract class ElectricDustWasher extends AContainer {
|
||||
ItemStack[] items = SlimefunPlugin.getUtilities().oreWasherOutputs;
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.SIFTED_ORE, true)) {
|
||||
if (!SlimefunPlugin.getSettings().legacyDustWasher) {
|
||||
boolean emptySlot = false;
|
||||
|
||||
@ -84,15 +84,15 @@ public abstract class ElectricDustWasher extends AContainer {
|
||||
|
||||
ItemStack adding = items[new Random().nextInt(items.length)];
|
||||
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {adding});
|
||||
if (SlimefunPlugin.getSettings().legacyDustWasher && !fits(b, r.getOutput())) return;
|
||||
if (SlimefunPlugin.getSettings().legacyDustWasher && !menu.fits(r.getOutput()[0], getOutputSlots())) return;
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
break;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) {
|
||||
else if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) {
|
||||
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {SlimefunItems.PURE_ORE_CLUSTER});
|
||||
if (!fits(b, r.getOutput())) return;
|
||||
if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
|
@ -2,12 +2,12 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.InvUtils;
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.Item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
@ -18,6 +18,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecip
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.Setup.SlimefunManager;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
@ -25,23 +26,56 @@ import me.mrCookieSlime.Slimefun.utils.MachineHelper;
|
||||
|
||||
public abstract class ElectricGoldPan extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
private Random random = new Random();
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
private final RandomizedSet<ItemStack> randomizerNether = new RandomizedSet<>();
|
||||
|
||||
private final List<ItemStack> displayRecipes = Arrays.asList(
|
||||
new ItemStack(Material.GRAVEL),
|
||||
SlimefunItems.SIFTED_ORE,
|
||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT),
|
||||
new ItemStack(Material.GRAVEL), SlimefunItems.SIFTED_ORE,
|
||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.CLAY_BALL),
|
||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.IRON_NUGGET),
|
||||
|
||||
new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.FLINT),
|
||||
|
||||
new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.CLAY_BALL)
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.QUARTZ),
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GOLD_NUGGET),
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.NETHER_WART),
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.BLAZE_POWDER),
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GLOWSTONE_DUST),
|
||||
new ItemStack(Material.SOUL_SAND), new ItemStack(Material.GHAST_TEAR)
|
||||
);
|
||||
|
||||
public ElectricGoldPan(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
super.postRegister();
|
||||
|
||||
String goldPan = "GOLD_PAN";
|
||||
String netherGoldPan = "NETHER_GOLD_PAN";
|
||||
|
||||
add(false, SlimefunItems.SIFTED_ORE, (int) Slimefun.getItemValue(goldPan, "chance.SIFTED_ORE"));
|
||||
add(false, new ItemStack(Material.CLAY_BALL), (int) Slimefun.getItemValue(goldPan, "chance.CLAY"));
|
||||
add(false, new ItemStack(Material.FLINT), (int) Slimefun.getItemValue(goldPan, "chance.FLINT"));
|
||||
add(false, new ItemStack(Material.IRON_NUGGET), (int) Slimefun.getItemValue(goldPan, "chance.IRON_NUGGET"));
|
||||
|
||||
add(true, new ItemStack(Material.QUARTZ), (int) Slimefun.getItemValue(netherGoldPan, "chance.QUARTZ"));
|
||||
add(true, new ItemStack(Material.GOLD_NUGGET), (int) Slimefun.getItemValue(netherGoldPan, "chance.GOLD_NUGGET"));
|
||||
add(true, new ItemStack(Material.NETHER_WART), (int) Slimefun.getItemValue(netherGoldPan, "chance.NETHER_WART"));
|
||||
add(true, new ItemStack(Material.BLAZE_POWDER), (int) Slimefun.getItemValue(netherGoldPan, "chance.BLAZE_POWDER"));
|
||||
add(true, new ItemStack(Material.GLOWSTONE_DUST), (int) Slimefun.getItemValue(netherGoldPan, "chance.GLOWSTONE_DUST"));
|
||||
add(true, new ItemStack(Material.GHAST_TEAR), (int) Slimefun.getItemValue(netherGoldPan, "chance.GHAST_TEAR"));
|
||||
}
|
||||
|
||||
private void add(boolean nether, ItemStack item, int chance) {
|
||||
if (nether) {
|
||||
randomizerNether.add(item, chance);
|
||||
}
|
||||
else {
|
||||
randomizer.add(item, chance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryTitle() {
|
||||
return "&6Electric Gold Pan";
|
||||
@ -74,7 +108,7 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
|
||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||
|
||||
menu.replaceExistingItem(22, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||
pushItems(b, processing.get(b).getOutput());
|
||||
menu.pushItem(processing.get(b).getOutput()[0].clone(), getOutputSlots());
|
||||
|
||||
progress.remove(b);
|
||||
processing.remove(b);
|
||||
@ -82,13 +116,23 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla
|
||||
}
|
||||
else {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
|
||||
ItemStack output = SlimefunItems.SIFTED_ORE;
|
||||
if (random.nextInt(100) < 16) output = new ItemStack(Material.FLINT);
|
||||
if (random.nextInt(100) < 16) output = new ItemStack(Material.CLAY_BALL);
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.GRAVEL), true)) {
|
||||
ItemStack output = randomizer.getRandom();
|
||||
|
||||
MachineRecipe r = new MachineRecipe(3 / getSpeed(), new ItemStack[0], new ItemStack[] {output});
|
||||
if (!fits(b, r.getOutput())) return;
|
||||
if (!menu.fits(output, getOutputSlots())) return;
|
||||
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
break;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
|
||||
ItemStack output = randomizerNether.getRandom();
|
||||
|
||||
MachineRecipe r = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] {output});
|
||||
if (!menu.fits(output, getOutputSlots())) return;
|
||||
|
||||
menu.replaceExistingItem(slot, InvUtils.decreaseItem(menu.getItemInSlot(slot), 1));
|
||||
processing.put(b, r);
|
||||
progress.put(b, r.getTicks());
|
||||
|
@ -0,0 +1,56 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.machines.electric;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Lists.SlimefunItems;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.RecipeDisplayItem;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public abstract class ElectricPress extends AContainer implements RecipeDisplayItem {
|
||||
|
||||
public ElectricPress(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDefaultRecipes() {
|
||||
registerRecipe(new MachineRecipe(4, new ItemStack[] {new CustomItem(SlimefunItems.STONE_CHUNK, 3)}, new ItemStack[] {new ItemStack(Material.COBBLESTONE)}));
|
||||
registerRecipe(new MachineRecipe(4, new ItemStack[] {new ItemStack(Material.FLINT, 6)}, new ItemStack[] {new ItemStack(Material.COBBLESTONE)}));
|
||||
|
||||
registerRecipe(new MachineRecipe(6, new ItemStack[] {SlimefunItems.COPPER_INGOT}, new ItemStack[] {new CustomItem(SlimefunItems.COPPER_WIRE, 3)}));
|
||||
registerRecipe(new MachineRecipe(16, new ItemStack[] {new CustomItem(SlimefunItems.STEEL_INGOT, 8)}, new ItemStack[] {SlimefunItems.STEEL_PLATE}));
|
||||
registerRecipe(new MachineRecipe(18, new ItemStack[] {new CustomItem(SlimefunItems.REINFORCED_ALLOY_INGOT, 8)}, new ItemStack[] {SlimefunItems.REINFORCED_PLATE}));
|
||||
|
||||
registerRecipe(new MachineRecipe(8, new ItemStack[] {new ItemStack(Material.NETHER_WART)}, new ItemStack[] {new CustomItem(SlimefunItems.MAGIC_LUMP_1, 2)}));
|
||||
registerRecipe(new MachineRecipe(10, new ItemStack[] {new CustomItem(SlimefunItems.MAGIC_LUMP_1, 4)}, new ItemStack[] {SlimefunItems.MAGIC_LUMP_2}));
|
||||
registerRecipe(new MachineRecipe(12, new ItemStack[] {new CustomItem(SlimefunItems.MAGIC_LUMP_2, 4)}, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3}));
|
||||
|
||||
registerRecipe(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.ENDER_EYE)}, new ItemStack[] {new CustomItem(SlimefunItems.ENDER_LUMP_1, 2)}));
|
||||
registerRecipe(new MachineRecipe(12, new ItemStack[] {new CustomItem(SlimefunItems.ENDER_LUMP_1, 4)}, new ItemStack[] {SlimefunItems.ENDER_LUMP_2}));
|
||||
registerRecipe(new MachineRecipe(14, new ItemStack[] {new CustomItem(SlimefunItems.ENDER_LUMP_2, 4)}, new ItemStack[] {SlimefunItems.ENDER_LUMP_3}));
|
||||
|
||||
registerRecipe(new MachineRecipe(18, new ItemStack[] {new CustomItem(SlimefunItems.TINY_URANIUM, 9)}, new ItemStack[] {SlimefunItems.SMALL_URANIUM}));
|
||||
registerRecipe(new MachineRecipe(24, new ItemStack[] {new CustomItem(SlimefunItems.SMALL_URANIUM, 4)}, new ItemStack[] {SlimefunItems.URANIUM}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryTitle() {
|
||||
return "&eElectric Press";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getProgressBar() {
|
||||
return new ItemStack(Material.IRON_HOE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineIdentifier() {
|
||||
return "ELECTRIC_PRESS";
|
||||
}
|
||||
}
|
@ -58,7 +58,7 @@ public abstract class ElectricSmeltery extends AContainer {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), item, true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), item, true)) {
|
||||
slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class FluidPump extends SlimefunItem implements InventoryBlock {
|
||||
if (output != null && ChargableBlock.getCharge(b) >= energyConsumption) {
|
||||
BlockMenu menu = BlockStorage.getInventory(b);
|
||||
for (int slot : getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (!menu.fits(output, getOutputSlots())) return;
|
||||
|
||||
ChargableBlock.addCharge(b, -energyConsumption);
|
||||
|
@ -62,7 +62,7 @@ public abstract class HeatedPressureChamber extends AContainer {
|
||||
List<Integer> slots = new ArrayList<>();
|
||||
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), item, true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), item, true)) {
|
||||
slots.add(slot);
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ public abstract class HeatedPressureChamber extends AContainer {
|
||||
for (MachineRecipe recipe: recipes) {
|
||||
for (ItemStack input: recipe.getInput()) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(menu.getItemInSlot(slot), input, true)) {
|
||||
if (SlimefunManager.isItemSimilar(menu.getItemInSlot(slot), input, true)) {
|
||||
found.put(slot, input.getAmount());
|
||||
break;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public abstract class Refinery extends AContainer implements RecipeDisplayItem {
|
||||
}
|
||||
else {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.BUCKET_OF_OIL, true)) {
|
||||
MachineRecipe r = new MachineRecipe(40, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_FUEL});
|
||||
if (!fits(b, r.getOutput())) return;
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
|
||||
|
@ -98,7 +98,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
@Override
|
||||
public int[] getSlotsAccessedByItemTransport(BlockMenu menu, ItemTransportFlow flow, ItemStack item) {
|
||||
if (flow == ItemTransportFlow.INSERT) {
|
||||
if (SlimefunManager.isItemSimiliar(item, new ItemStack(Material.SOUL_SAND), true)) return getSoulSandSlots();
|
||||
if (SlimefunManager.isItemSimilar(item, new ItemStack(Material.SOUL_SAND), true)) return getSoulSandSlots();
|
||||
else return getWitherSkullSlots();
|
||||
}
|
||||
else return new int[0];
|
||||
@ -194,7 +194,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
int skulls = 0;
|
||||
|
||||
for (int slot : getSoulSandSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
|
||||
soulsand = soulsand + BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (soulsand > 3) {
|
||||
soulsand = 4;
|
||||
@ -204,7 +204,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
|
||||
for (int slot : getWitherSkullSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
|
||||
skulls = skulls + BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (skulls > 2) {
|
||||
skulls = 3;
|
||||
@ -215,7 +215,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
|
||||
if (soulsand > 3 && skulls > 2) {
|
||||
for (int slot : getSoulSandSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true)) {
|
||||
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (amount >= soulsand) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), soulsand));
|
||||
@ -229,7 +229,7 @@ public class WitherAssembler extends SlimefunItem {
|
||||
}
|
||||
|
||||
for (int slot : getWitherSkullSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
|
||||
if (SlimefunManager.isItemSimilar(BlockStorage.getInventory(b).getItemInSlot(slot), new ItemStack(Material.WITHER_SKELETON_SKULL), true)) {
|
||||
final int amount = BlockStorage.getInventory(b).getItemInSlot(slot).getAmount();
|
||||
if (amount >= skulls) {
|
||||
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), skulls));
|
||||
|
@ -45,19 +45,20 @@ public abstract class BioGenerator extends AGenerator {
|
||||
registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK)));
|
||||
registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS)));
|
||||
registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE)));
|
||||
registerFuel(new MachineFuel(2, new ItemStack(Material.SWEET_BERRIES)));
|
||||
|
||||
// Leaves
|
||||
for(Material m: Tag.LEAVES.getValues()) {
|
||||
for(Material m : Tag.LEAVES.getValues()) {
|
||||
registerFuel(new MachineFuel(1, new ItemStack(m)));
|
||||
}
|
||||
|
||||
// Saplings
|
||||
for (Material m: Tag.SAPLINGS.getValues()) {
|
||||
for (Material m : Tag.SAPLINGS.getValues()) {
|
||||
registerFuel(new MachineFuel(1, new ItemStack(m)));
|
||||
}
|
||||
|
||||
// Small Flowers (formally just dandelions and poppies.
|
||||
for (Material m: Tag.SMALL_FLOWERS.getValues()) {
|
||||
for (Material m : Tag.SMALL_FLOWERS.getValues()) {
|
||||
registerFuel(new MachineFuel(1, new ItemStack(m)));
|
||||
}
|
||||
}
|
||||
|
@ -22,17 +22,17 @@ public abstract class CoalGenerator extends AGenerator {
|
||||
registerFuel(new MachineFuel(12, new ItemStack(Material.BLAZE_ROD)));
|
||||
|
||||
// Coals
|
||||
for (Material mat: Tag.ITEMS_COALS.getValues()) {
|
||||
for (Material mat : Tag.ITEMS_COALS.getValues()) {
|
||||
registerFuel(new MachineFuel(8, new ItemStack(mat)));
|
||||
}
|
||||
|
||||
// Logs
|
||||
for (Material mat: Tag.LOGS.getValues()) {
|
||||
for (Material mat : Tag.LOGS.getValues()) {
|
||||
registerFuel(new MachineFuel(2, new ItemStack(mat)));
|
||||
}
|
||||
|
||||
// Wooden Planks
|
||||
for (Material mat: Tag.PLANKS.getValues()) {
|
||||
for (Material mat : Tag.PLANKS.getValues()) {
|
||||
registerFuel(new MachineFuel(1, new ItemStack(mat)));
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,6 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
||||
}
|
||||
}
|
||||
|
||||
if (displayRecipes.size() % 2 != 0) displayRecipes.add(null);
|
||||
return displayRecipes;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public abstract class OilPump extends AContainer {
|
||||
|
||||
if (supplies > 0) {
|
||||
for (int slot: getInputSlots()) {
|
||||
if (SlimefunManager.isItemSimiliar(inv.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
if (SlimefunManager.isItemSimilar(inv.getItemInSlot(slot), new ItemStack(Material.BUCKET), true)) {
|
||||
MachineRecipe r = new MachineRecipe(26, new ItemStack[0], new ItemStack[] {SlimefunItems.BUCKET_OF_OIL});
|
||||
|
||||
if (!inv.fits(SlimefunItems.BUCKET_OF_OIL, getOutputSlots())) {
|
||||
|
@ -44,7 +44,7 @@ public class ArmorForge extends MultiBlockMachine {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
boolean craft = true;
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
craft = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.multiblocks;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -13,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
||||
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||
@ -23,19 +21,11 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||
|
||||
public class AutomatedPanningMachine extends MultiBlockMachine {
|
||||
|
||||
// Gold Pan
|
||||
private int chanceSiftedOre;
|
||||
private int chanceFlint;
|
||||
private int chanceClay;
|
||||
private int chanceIronNuggets;
|
||||
private final RandomizedSet<ItemStack> randomizer = new RandomizedSet<>();
|
||||
private int weights;
|
||||
|
||||
// Nether Gold Pan
|
||||
private int chanceQuartz;
|
||||
private int chanceGoldNuggets;
|
||||
private int chanceNetherWart;
|
||||
private int chanceBlazePowder;
|
||||
private int chanceGlowstoneDust;
|
||||
private int chanceGhastTear;
|
||||
private final RandomizedSet<ItemStack> randomizerNether = new RandomizedSet<>();
|
||||
private int weightsNether;
|
||||
|
||||
public AutomatedPanningMachine() {
|
||||
super(
|
||||
@ -66,29 +56,51 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
|
||||
String goldPan = "GOLD_PAN";
|
||||
String netherGoldPan = "NETHER_GOLD_PAN";
|
||||
|
||||
chanceSiftedOre = (int) Slimefun.getItemValue(goldPan, "chance.SIFTED_ORE");
|
||||
chanceClay = (int) Slimefun.getItemValue(goldPan, "chance.CLAY");
|
||||
chanceFlint = (int) Slimefun.getItemValue(goldPan, "chance.FLINT");
|
||||
chanceIronNuggets = (int) Slimefun.getItemValue(goldPan, "chance.IRON_NUGGET");
|
||||
add(false, SlimefunItems.SIFTED_ORE, (int) Slimefun.getItemValue(goldPan, "chance.SIFTED_ORE"));
|
||||
add(false, new ItemStack(Material.CLAY_BALL), (int) Slimefun.getItemValue(goldPan, "chance.CLAY"));
|
||||
add(false, new ItemStack(Material.FLINT), (int) Slimefun.getItemValue(goldPan, "chance.FLINT"));
|
||||
add(false, new ItemStack(Material.IRON_NUGGET), (int) Slimefun.getItemValue(goldPan, "chance.IRON_NUGGET"));
|
||||
|
||||
chanceQuartz = (int) Slimefun.getItemValue(netherGoldPan, "chance.QUARTZ");
|
||||
chanceGoldNuggets = (int) Slimefun.getItemValue(netherGoldPan, "chance.GOLD_NUGGET");
|
||||
chanceNetherWart = (int) Slimefun.getItemValue(netherGoldPan, "chance.NETHER_WART");
|
||||
chanceBlazePowder = (int) Slimefun.getItemValue(netherGoldPan, "chance.BLAZE_POWDER");
|
||||
chanceGlowstoneDust = (int) Slimefun.getItemValue(netherGoldPan, "chance.GLOWSTONE_DUST");
|
||||
chanceGhastTear = (int) Slimefun.getItemValue(netherGoldPan, "chance.GHAST_TEAR");
|
||||
if (weights < 100) {
|
||||
add(false, new ItemStack(Material.AIR), 100 - weights);
|
||||
}
|
||||
|
||||
add(true, new ItemStack(Material.QUARTZ), (int) Slimefun.getItemValue(netherGoldPan, "chance.QUARTZ"));
|
||||
add(true, new ItemStack(Material.GOLD_NUGGET), (int) Slimefun.getItemValue(netherGoldPan, "chance.GOLD_NUGGET"));
|
||||
add(true, new ItemStack(Material.NETHER_WART), (int) Slimefun.getItemValue(netherGoldPan, "chance.NETHER_WART"));
|
||||
add(true, new ItemStack(Material.BLAZE_POWDER), (int) Slimefun.getItemValue(netherGoldPan, "chance.BLAZE_POWDER"));
|
||||
add(true, new ItemStack(Material.GLOWSTONE_DUST), (int) Slimefun.getItemValue(netherGoldPan, "chance.GLOWSTONE_DUST"));
|
||||
add(true, new ItemStack(Material.GHAST_TEAR), (int) Slimefun.getItemValue(netherGoldPan, "chance.GHAST_TEAR"));
|
||||
|
||||
|
||||
if (weightsNether < 100) {
|
||||
add(true, new ItemStack(Material.AIR), 100 - weightsNether);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(boolean nether, ItemStack item, int chance) {
|
||||
if (nether) {
|
||||
randomizerNether.add(item, chance);
|
||||
weightsNether += chance;
|
||||
}
|
||||
else {
|
||||
randomizer.add(item, chance);
|
||||
weights += chance;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInteract(Player p, Block b) {
|
||||
final ItemStack input = p.getInventory().getItemInMainHand();
|
||||
|
||||
if (SlimefunManager.isItemSimiliar(input, new ItemStack(Material.GRAVEL), true) || SlimefunManager.isItemSimiliar(input, new ItemStack(Material.SOUL_SAND), true)) {
|
||||
if (SlimefunManager.isItemSimilar(input, new ItemStack(Material.GRAVEL), true) || SlimefunManager.isItemSimilar(input, new ItemStack(Material.SOUL_SAND), true)) {
|
||||
final Material block = input.getType();
|
||||
|
||||
if (p.getGameMode() != GameMode.CREATIVE) ItemUtils.consumeItem(input, false);
|
||||
if (p.getGameMode() != GameMode.CREATIVE) {
|
||||
ItemUtils.consumeItem(input, false);
|
||||
}
|
||||
|
||||
ItemStack output = getRandomDrop(ThreadLocalRandom.current(), block);
|
||||
ItemStack output = getRandomDrop(block);
|
||||
TaskQueue queue = new TaskQueue();
|
||||
|
||||
queue.thenRepeatEvery(20, 5, () ->
|
||||
@ -96,14 +108,14 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
|
||||
);
|
||||
|
||||
queue.thenRun(20, () -> {
|
||||
if (output != null) {
|
||||
if (output.getType() != Material.AIR) {
|
||||
Inventory outputChest = findOutputChest(b.getRelative(BlockFace.DOWN), output);
|
||||
|
||||
if (outputChest != null) {
|
||||
outputChest.addItem(output);
|
||||
outputChest.addItem(output.clone());
|
||||
}
|
||||
else {
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), output);
|
||||
b.getWorld().dropItemNaturally(b.getLocation(), output.clone());
|
||||
}
|
||||
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F);
|
||||
@ -120,42 +132,15 @@ public class AutomatedPanningMachine extends MultiBlockMachine {
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getRandomDrop(Random random, Material input) {
|
||||
private ItemStack getRandomDrop(Material input) {
|
||||
if (input == Material.GRAVEL) {
|
||||
if (random.nextInt(100) < chanceSiftedOre) {
|
||||
return SlimefunItems.SIFTED_ORE;
|
||||
}
|
||||
else if (random.nextInt(100) < chanceClay) {
|
||||
return new ItemStack(Material.CLAY_BALL);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceFlint) {
|
||||
return new ItemStack(Material.FLINT);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceIronNuggets) {
|
||||
return new ItemStack(Material.IRON_NUGGET);
|
||||
}
|
||||
return randomizer.getRandom();
|
||||
}
|
||||
else if (input == Material.SOUL_SAND) {
|
||||
if (random.nextInt(100) < chanceQuartz) {
|
||||
return new ItemStack(Material.QUARTZ);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceGoldNuggets) {
|
||||
return new ItemStack(Material.GOLD_NUGGET);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceNetherWart) {
|
||||
return new ItemStack(Material.NETHER_WART);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceBlazePowder) {
|
||||
return new ItemStack(Material.BLAZE_POWDER);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceGlowstoneDust) {
|
||||
return new ItemStack(Material.GLOWSTONE_DUST);
|
||||
}
|
||||
else if (random.nextInt(100) < chanceGhastTear) {
|
||||
return new ItemStack(Material.GHAST_TEAR);
|
||||
}
|
||||
return randomizerNether.getRandom();
|
||||
}
|
||||
return null;
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class Compressor extends MultiBlockMachine {
|
||||
Inventory inv = disp.getInventory();
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(current, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
final ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
if (outputInv != null) {
|
||||
|
@ -55,9 +55,9 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
boolean craft = true;
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
|
||||
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], false)) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], false)) {
|
||||
craft = false;
|
||||
break;
|
||||
}
|
||||
@ -73,6 +73,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
final ItemStack adding = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
|
||||
if (Slimefun.hasUnlocked(p, adding, true)) {
|
||||
Inventory inv2 = Bukkit.createInventory(null, 9, "test");
|
||||
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
inv2.setItem(j, inv.getContents()[j] != null ? (inv.getContents()[j].getAmount() > 1 ? new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1): null): null);
|
||||
}
|
||||
@ -81,6 +82,7 @@ public class EnhancedCraftingTable extends MultiBlockMachine {
|
||||
|
||||
if (outputInv != null) {
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(adding);
|
||||
|
||||
if (sfItem instanceof SlimefunBackpack) {
|
||||
ItemStack backpack = null;
|
||||
|
||||
|
@ -31,10 +31,11 @@ public class GrindStone extends MultiBlockMachine {
|
||||
new ItemStack(Material.BLAZE_ROD), new ItemStack(Material.BLAZE_POWDER, 4),
|
||||
new ItemStack(Material.BONE), new ItemStack(Material.BONE_MEAL, 4),
|
||||
new ItemStack(Material.GRAVEL), new ItemStack(Material.FLINT),
|
||||
new ItemStack(Material.NETHER_WART), new CustomItem(SlimefunItems.MAGIC_LUMP_1, 2),
|
||||
new ItemStack(Material.ENDER_EYE), new CustomItem(SlimefunItems.ENDER_LUMP_1, 2),
|
||||
new ItemStack(Material.COBBLESTONE), new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.WHEAT), SlimefunItems.WHEAT_FLOUR,
|
||||
new ItemStack(Material.ANDESITE), new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.DIORITE), new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.GRANITE), new ItemStack(Material.GRAVEL),
|
||||
new ItemStack(Material.DIRT), SlimefunItems.STONE_CHUNK,
|
||||
new ItemStack(Material.SANDSTONE), new ItemStack(Material.SAND, 4),
|
||||
new ItemStack(Material.RED_SANDSTONE), new ItemStack(Material.RED_SAND, 4)
|
||||
@ -56,7 +57,7 @@ public class GrindStone extends MultiBlockMachine {
|
||||
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(current, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
ItemStack output = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class Juicer extends MultiBlockMachine {
|
||||
Inventory inv = disp.getInventory();
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(current, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
|
||||
|
@ -58,9 +58,9 @@ public class MagicWorkbench extends MultiBlockMachine {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
boolean craft = true;
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], true)) {
|
||||
if (SlimefunItem.getByItem(inputs.get(i)[j]) instanceof SlimefunBackpack) {
|
||||
if (!SlimefunManager.isItemSimiliar(inv.getContents()[j], inputs.get(i)[j], false)) {
|
||||
if (!SlimefunManager.isItemSimilar(inv.getContents()[j], inputs.get(i)[j], false)) {
|
||||
craft = false;
|
||||
break;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class OreCrusher extends MultiBlockMachine {
|
||||
Inventory inv = disp.getInventory();
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(current, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
if (outputInv != null) {
|
||||
|
@ -50,7 +50,7 @@ public class OreWasher extends MultiBlockMachine {
|
||||
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
if (current != null) {
|
||||
if (SlimefunManager.isItemSimiliar(current, SlimefunItems.SIFTED_ORE, true)) {
|
||||
if (SlimefunManager.isItemSimilar(current, SlimefunItems.SIFTED_ORE, true)) {
|
||||
ItemStack adding = items[new Random().nextInt(items.length)];
|
||||
Inventory outputInv = null;
|
||||
|
||||
@ -77,7 +77,7 @@ public class OreWasher extends MultiBlockMachine {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(current, new ItemStack(Material.SAND, 4), false)) {
|
||||
else if (SlimefunManager.isItemSimilar(current, new ItemStack(Material.SAND, 4), false)) {
|
||||
ItemStack adding = SlimefunItems.SALT;
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
|
||||
@ -93,7 +93,7 @@ public class OreWasher extends MultiBlockMachine {
|
||||
|
||||
return;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(current, SlimefunItems.PULVERIZED_ORE, true)) {
|
||||
else if (SlimefunManager.isItemSimilar(current, SlimefunItems.PULVERIZED_ORE, true)) {
|
||||
ItemStack adding = SlimefunItems.PURE_ORE_CLUSTER;
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class PressureChamber extends MultiBlockMachine {
|
||||
|
||||
for (ItemStack current: inv.getContents()) {
|
||||
for (ItemStack convert: RecipeType.getRecipeInputs(this)) {
|
||||
if (convert != null && SlimefunManager.isItemSimiliar(current, convert, true)) {
|
||||
if (convert != null && SlimefunManager.isItemSimilar(current, convert, true)) {
|
||||
final ItemStack adding = RecipeType.getRecipeOutput(this, convert);
|
||||
Inventory outputInv = findOutputInventory(adding, dispBlock, inv);
|
||||
if (outputInv != null) {
|
||||
|
@ -73,11 +73,11 @@ public class Smeltery extends MultiBlockMachine {
|
||||
for (ItemStack converting: inputs.get(i)) {
|
||||
if (converting != null) {
|
||||
for (int j = 0; j < inv.getContents().length; j++) {
|
||||
if (j == (inv.getContents().length - 1) && !SlimefunManager.isItemSimiliar(converting, inv.getContents()[j], true)) {
|
||||
if (j == (inv.getContents().length - 1) && !SlimefunManager.isItemSimilar(converting, inv.getContents()[j], true)) {
|
||||
craft = false;
|
||||
break;
|
||||
}
|
||||
else if (SlimefunManager.isItemSimiliar(inv.getContents()[j], converting, true)) break;
|
||||
else if (SlimefunManager.isItemSimilar(inv.getContents()[j], converting, true)) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ public class Smeltery extends MultiBlockMachine {
|
||||
if (outputInv != null) {
|
||||
for (ItemStack removing: inputs.get(i)) {
|
||||
if (removing != null) {
|
||||
InvUtils.removeItem(inv, removing.getAmount(), true, stack -> SlimefunManager.isItemSimiliar(stack, removing, true));
|
||||
InvUtils.removeItem(inv, removing.getAmount(), true, stack -> SlimefunManager.isItemSimilar(stack, removing, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user