This commit is contained in:
Brianna O'Keefe 2019-02-17 02:47:58 -05:00
parent d5ec64c577
commit dce19a136b
4 changed files with 20 additions and 18 deletions

View File

@ -179,7 +179,7 @@ public class SkyBlock extends JavaPlugin {
SkyBlockAPI.setImplementation(instance);
this.loadFromFile();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::loadFromFile, 5L);
}
@Override

View File

@ -84,19 +84,25 @@ public class Block implements Listener {
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 (materials != null) {
if (level.hasMaterial(materials.name())) {
materialAmount = level.getMaterialAmount(materials.name());
IslandLevel level = island.getLevel();
if (level.hasMaterial(materials.name())) {
int materialAmount = level.getMaterialAmount(materials.name());
if (materialAmount - 1 <= 0) {
level.removeMaterial(materials.name());
} else {
level.setMaterialAmount(materials.name(), materialAmount - 1);
}
}
}
level.setMaterialAmount(materials.name(), materialAmount + 1);
}
event.setCancelled(true);

View File

@ -29,7 +29,6 @@ import java.util.UUID;
public class Stackable {
private UUID uuid;
private Island island;
private Location location;
private Material material;
@ -37,7 +36,6 @@ public class Stackable {
public Stackable(Location location, Material material) {
this.island = SkyBlock.getInstance().getIslandManager().getIslandAtLocation(location);
this.uuid = UUID.randomUUID();
this.location = location;
this.material = material;
@ -47,23 +45,17 @@ public class Stackable {
}
public Stackable(UUID uuid, Location location, Material material, int size) {
this.island = SkyBlock.getInstance().getIslandManager().getIslandAtLocation(location);
this.uuid = uuid;
this.location = location;
this.material = material;
this.size = size;
updateDisplay();
save();
}
public UUID getUuid() {
return uuid;
}
public Island getIsland() {
return island;
}
public Location getLocation() {
return location.clone();
}
@ -88,6 +80,7 @@ public class Stackable {
public void setSize(Integer size) {
this.size = size;
updateDisplay();
save();
}
public void addOne() {
@ -131,7 +124,8 @@ public class Stackable {
private void save() {
File configFile = new File(SkyBlock.getInstance().getDataFolder().toString() + "/island-data");
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(configFile, island.getOwnerUUID() + ".yml"));
FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(configFile,
SkyBlock.getInstance().getIslandManager().getIslandAtLocation(location).getOwnerUUID() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
ConfigurationSection section = configLoad.createSection("Stackables." + getUuid().toString());

View File

@ -6,6 +6,7 @@ import me.goodandevil.skyblock.listeners.Entity;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Item;
@ -69,6 +70,7 @@ public class StackableManager {
}
public void removeStack(Stackable stackable) {
stackable.setSize(0);
stackable.removeDisplay();
stacks.remove(stackable.getLocation());
}