mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-11 02:07:42 +01:00
fixed stackable leveling.
This commit is contained in:
parent
c91372ff40
commit
d5ec64c577
@ -81,6 +81,24 @@ public class Block implements Listener {
|
|||||||
if (stackable.getSize() <= 1) {
|
if (stackable.getSize() <= 1) {
|
||||||
stackableManager.removeStack(stackable);
|
stackableManager.removeStack(stackable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
|
||||||
|
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
|
||||||
|
Materials materials = Materials.getMaterials(block.getType(), block.getData());
|
||||||
|
|
||||||
|
if (materials == null) return;
|
||||||
|
int materialAmount = 0;
|
||||||
|
IslandLevel level = island.getLevel();
|
||||||
|
|
||||||
|
if (level.hasMaterial(materials.name())) {
|
||||||
|
materialAmount = level.getMaterialAmount(materials.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
level.setMaterialAmount(materials.name(), materialAmount + 1);
|
||||||
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
block.getWorld().dropItemNaturally(block.getLocation().clone().add(.5, 1, .5), new ItemStack(block.getType()));
|
block.getWorld().dropItemNaturally(block.getLocation().clone().add(.5, 1, .5), new ItemStack(block.getType()));
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package me.goodandevil.skyblock.listeners;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import me.goodandevil.skyblock.config.FileManager;
|
||||||
|
import me.goodandevil.skyblock.island.Island;
|
||||||
|
import me.goodandevil.skyblock.island.IslandLevel;
|
||||||
import me.goodandevil.skyblock.stackable.Stackable;
|
import me.goodandevil.skyblock.stackable.Stackable;
|
||||||
import me.goodandevil.skyblock.stackable.StackableManager;
|
import me.goodandevil.skyblock.stackable.StackableManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -10,6 +13,7 @@ import org.bukkit.GameMode;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.minecart.StorageMinecart;
|
import org.bukkit.entity.minecart.StorageMinecart;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -69,6 +73,25 @@ public class Interact implements Listener {
|
|||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
InventoryUtil.takeItem(player, 1);
|
InventoryUtil.takeItem(player, 1);
|
||||||
|
|
||||||
|
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
|
||||||
|
FileConfiguration configLoad = config.getFileConfiguration();
|
||||||
|
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
|
||||||
|
|
||||||
|
Island island = islandManager.getIslandAtLocation(block.getLocation());
|
||||||
|
|
||||||
|
Materials materials = Materials.getMaterials(block.getType(), block.getData());
|
||||||
|
|
||||||
|
if (materials == null) return;
|
||||||
|
int materialAmount = 0;
|
||||||
|
IslandLevel level = island.getLevel();
|
||||||
|
|
||||||
|
if (level.hasMaterial(materials.name())) {
|
||||||
|
materialAmount = level.getMaterialAmount(materials.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
level.setMaterialAmount(materials.name(), materialAmount + 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (block.getType() == Material.ANVIL) {
|
if (block.getType() == Material.ANVIL) {
|
||||||
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
|
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user