This commit is contained in:
Jules 2020-04-09 11:05:01 +02:00
commit ed0299b78a
96 changed files with 725 additions and 833 deletions

Binary file not shown.

Binary file not shown.

View File

@ -43,8 +43,6 @@ import net.Indyuce.mmocore.comp.mythicmobs.MythicMobsMMOLoader;
import net.Indyuce.mmocore.comp.placeholder.DefaultParser;
import net.Indyuce.mmocore.comp.placeholder.PlaceholderAPIParser;
import net.Indyuce.mmocore.comp.placeholder.PlaceholderParser;
import net.Indyuce.mmocore.comp.rpg.DefaultRPGUtilHandler;
import net.Indyuce.mmocore.comp.rpg.RPGUtilHandler;
import net.Indyuce.mmocore.comp.vault.VaultEconomy;
import net.Indyuce.mmocore.comp.vault.VaultMMOLoader;
import net.Indyuce.mmocore.comp.worldguard.DefaultRegionHandler;
@ -132,9 +130,7 @@ public class MMOCore extends JavaPlugin {
public final SmithingManager smithingManager = new SmithingManager();
public final MMOLoadManager loadManager = new MMOLoadManager();
public RPGUtilHandler rpgUtilHandler = new DefaultRPGUtilHandler();
private boolean miLoaded, miChecked;
public void onLoad() {
plugin = this;
@ -424,13 +420,4 @@ public class MMOCore extends JavaPlugin {
public boolean hasEconomy() {
return economy != null && economy.isValid();
}
public boolean isMILoaded() {
if (!miChecked) {
miLoaded = Bukkit.getPluginManager().isPluginEnabled("MMOItems");
miChecked = true;
}
return miLoaded;
}
}

View File

@ -0,0 +1,152 @@
package net.Indyuce.mmocore.api.block;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.DropTable;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class BlockInfo {
private final BlockType block;
private final DropTable table;
private final boolean vanillaDrops;
private final List<Trigger> triggers = new ArrayList<>();
private final RegenInfo regen;
/*
* saved separately because MMOCore needs to display the experience gained,
* since it requires a steam call it is better to cache right off the start
*/
private final ExperienceTrigger experience;
public BlockInfo(ConfigurationSection config) {
Validate.notNull(config, "Could not load config");
Validate.isTrue(config.contains("material"), "Could not find block type");
block = MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(config.getString("material")));
table = config.contains("drop-table") ? MMOCore.plugin.dropTableManager.loadDropTable(config.get("drop-table")) : null;
vanillaDrops = config.getBoolean("vanilla-drops", true);
regen = config.contains("regen") ? new RegenInfo(config.getConfigurationSection("regen")) : null;
if (config.contains("triggers")) {
List<String> list = config.getStringList("triggers");
Validate.notNull(list, "Could not load triggers");
for (String key : list)
try {
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
} catch (MMOLoadException exception) {
exception.printConsole("BlockRegen", "trigger");
}
}
Optional<Trigger> opt = triggers.stream().filter(trigger -> (trigger instanceof ExperienceTrigger)).findFirst();
experience = opt.isPresent() ? (ExperienceTrigger) opt.get() : null;
}
public boolean hasVanillaDrops() {
return vanillaDrops;
}
public BlockType getBlock() {
return block;
}
/*
* generates a key used to store the BlockInfo instance in the manager map,
* the key depends on the block type to make sure there is no interference
*/
public String generateKey() {
return block.generateKey();
}
public DropTable getDropTable() {
return table;
}
public List<ItemStack> collectDrops() {
return hasDropTable() ? table.collect() : new ArrayList<>();
}
public boolean hasDropTable() {
return table != null;
}
public boolean hasRegen() {
return regen != null;
}
public boolean regenerates() {
return regen != null;
}
public RegenInfo getRegenerationInfo() {
return regen;
}
public RegeneratingBlock startRegeneration(BlockData data, Location loc) {
return new RegeneratingBlock(data, loc, this);
}
public RegeneratingBlock startRegeneration(Location loc) {
return new RegeneratingBlock(null, loc, this);
}
public boolean hasExperience() {
return experience != null;
}
public ExperienceTrigger getExperience() {
return experience;
}
public boolean hasTriggers() {
return !triggers.isEmpty();
}
public List<Trigger> getTriggers() {
return triggers;
}
public class RegeneratingBlock {
private final BlockData data;
private final Location loc;
private final BlockInfo regenerating;
private final long date = System.currentTimeMillis();
public RegeneratingBlock(BlockData data, Location loc, BlockInfo regenerating) {
this.data = data;
this.loc = loc;
this.regenerating = regenerating;
}
public boolean isTimedOut() {
return date + regenerating.getRegenerationInfo().getTime() * 50 < System.currentTimeMillis();
}
public BlockData getBlockData() {
return data;
}
public Location getLocation() {
return loc;
}
public BlockInfo getRegeneratingBlock() {
return regenerating;
}
}
}

View File

@ -0,0 +1,13 @@
package net.Indyuce.mmocore.api.block;
import org.bukkit.Location;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
public interface BlockType {
public void place(Location loc, RegeneratingBlock regenerating);
// public boolean matches(Block block);
public String generateKey();
}

View File

@ -0,0 +1,31 @@
package net.Indyuce.mmocore.api.block;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.MMOCore;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class RegenInfo {
private final BlockType temporary;
private final int regenTime;
public RegenInfo(ConfigurationSection config) {
Validate.notNull(config, "Could not read regen info config");
temporary = config.contains("temp-block") ? MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(config.getString("temp-block"))) : null;
regenTime = config.getInt("time", 2 * 60 * 20);
}
public int getTime() {
return regenTime;
}
public boolean hasTemporaryBlock() {
return temporary != null;
}
public BlockType getTemporaryBlock() {
return temporary;
}
}

View File

@ -0,0 +1,44 @@
package net.Indyuce.mmocore.api.block;
import org.bukkit.Location;
import org.bukkit.block.Block;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.version.VersionMaterial;
public class SkullBlockType implements BlockType {
private final String value;
public SkullBlockType(MMOLineConfig config) {
config.validate("value");
value = config.getString("value");
}
public SkullBlockType(Block block) {
value = MMOLib.plugin.getNMS().getSkullValue(block);
}
public String getValue() {
return value;
}
@Override
public void place(Location loc, RegeneratingBlock block) {
loc.getBlock().setType(VersionMaterial.PLAYER_HEAD.toMaterial());
// save skull orientation if replaced block is a player head
if (MMOCoreUtils.isPlayerHead(block.getBlockData().getMaterial()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
loc.getBlock().setBlockData(block.getBlockData());
MMOLib.plugin.getNMS().setSkullValue(loc.getBlock(), value);
}
@Override
public String generateKey() {
return "vanilla-skull-" + value;
}
}

View File

@ -0,0 +1,36 @@
package net.Indyuce.mmocore.api.block;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class VanillaBlockType implements BlockType {
private final Material type;
public VanillaBlockType(MMOLineConfig config) {
config.validate("type");
type = Material.valueOf(config.getString("type").toUpperCase().replace("-", "_").replace(" ", "_"));
}
public VanillaBlockType(Block block) {
type = block.getType();
}
public Material getType() {
return type;
}
@Override
public void place(Location loc, RegeneratingBlock block) {
loc.getBlock().setType(type);
}
@Override
public String generateKey() {
return "vanilla-block-" + type.name();
}
}

View File

@ -11,8 +11,8 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class DropTable {
private final String id;

View File

@ -1,11 +1,12 @@
package net.Indyuce.mmocore.api.droptable.condition;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import org.bukkit.block.Biome;
import java.util.Arrays;
import java.util.List;
import org.bukkit.block.Biome;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class BiomeCondition extends Condition {
private final List<String> names;

View File

@ -1,6 +1,6 @@
package net.Indyuce.mmocore.api.droptable.condition;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class Condition {
private final String id;

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmocore.api.droptable.condition;
import java.util.Arrays;
import java.util.List;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class WorldCondition extends Condition {
private final List<String> names;

View File

@ -5,8 +5,8 @@ import java.util.Random;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class DropItem {
protected static final Random random = new Random();

View File

@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.DropTable;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class DropTableDropItem extends DropItem {
private DropTable dropTable;

View File

@ -4,8 +4,8 @@ import java.util.List;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class GoldDropItem extends DropItem {
public GoldDropItem(MMOLineConfig config) {

View File

@ -14,7 +14,7 @@ import io.lumine.xikage.mythicmobs.drops.DropTable;
import io.lumine.xikage.mythicmobs.drops.IItemDrop;
import io.lumine.xikage.mythicmobs.drops.LootBag;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MMDropTableDropItem extends DropItem {
private DropTable dropTable;

View File

@ -4,8 +4,8 @@ import java.util.List;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class NoteDropItem extends DropItem {
private int min, max;

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class VanillaDropItem extends DropItem {
private final Material material;

View File

@ -7,8 +7,8 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class FishingDropItem {
private final RandomAmount experience, tugs;

View File

@ -18,7 +18,7 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.Indyuce.mmocore.api.util.item.SmartGive;
import net.mmogroup.mmolib.api.util.SmartGive;
public class Withdraw implements Listener {
private static final Set<UUID> withdrawing = new HashSet<>();

View File

@ -7,9 +7,9 @@ import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.block.BlockInfo;
import net.Indyuce.mmocore.api.experience.ExperienceInfo;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.CustomBlockManager.BlockInfo;
public class CustomBlockMineEvent extends PlayerDataEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();

View File

@ -9,10 +9,10 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.potion.PotionType;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class Profession {
private final String id, name, expCurve;

View File

@ -19,9 +19,9 @@ import org.bukkit.potion.PotionType;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class BrewPotionExperienceSource extends ExperienceSource<PotionMeta> {
private final List<PotionType> types = new ArrayList<>();

View File

@ -8,9 +8,9 @@ import org.bukkit.event.inventory.CraftItemEvent;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class CraftItemExperienceSource extends SpecificExperienceSource<Material> {
public final Material material;

View File

@ -15,9 +15,9 @@ import org.bukkit.event.enchantment.EnchantItemEvent;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.MMOLib;
public class EnchantItemExperienceSource extends ExperienceSource<Void> {

View File

@ -10,9 +10,9 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class FishItemExperienceSource extends SpecificExperienceSource<ItemStack> {
private final Material material;

View File

@ -10,9 +10,9 @@ import org.bukkit.event.EventPriority;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.api.event.EntityKillEntityEvent;
public class KillMobExperienceSource extends SpecificExperienceSource<Entity> {

View File

@ -10,9 +10,9 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.MMOLib;
public class MineBlockExperienceSource extends SpecificExperienceSource<Material> {

View File

@ -8,9 +8,9 @@ import org.bukkit.event.block.BlockPlaceEvent;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class PlaceBlockExperienceSource extends SpecificExperienceSource<Material> {
public final Material material;

View File

@ -13,9 +13,9 @@ import org.bukkit.inventory.meta.Damageable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class RepairItemExperienceSource extends ExperienceSource<ItemStack> {
private final Material material;

View File

@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class SmeltItemExperienceSource extends SpecificExperienceSource<ItemStack> {
private final Material material;

View File

@ -3,9 +3,9 @@ package net.Indyuce.mmocore.api.experience.source.type;
import org.bukkit.Location;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class SpecificExperienceSource<T> extends ExperienceSource<T> {
private final RandomAmount amount;

View File

@ -1,8 +1,11 @@
package net.Indyuce.mmocore.api.load;
import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.block.SkullBlockType;
import net.Indyuce.mmocore.api.block.VanillaBlockType;
import net.Indyuce.mmocore.api.droptable.condition.BiomeCondition;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.WorldCondition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
@ -35,8 +38,9 @@ import net.Indyuce.mmocore.api.quest.trigger.MessageTrigger;
import net.Indyuce.mmocore.api.quest.trigger.SoundTrigger;
import net.Indyuce.mmocore.api.quest.trigger.StelliumTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class DefaultMMOLoader implements MMOLoader {
public class DefaultMMOLoader extends MMOLoader {
@Override
public Trigger loadTrigger(MMOLineConfig config) {
@ -143,4 +147,16 @@ public class DefaultMMOLoader implements MMOLoader {
return null;
}
@Override
public BlockType loadBlockType(MMOLineConfig config) {
if (config.getKey().equalsIgnoreCase("vanilla"))
return new VanillaBlockType(config);
if (config.getKey().equalsIgnoreCase("skull") || config.getKey().equals("head") || config.getKey().equals("playerhead"))
return new SkullBlockType(config);
return null;
}
}

View File

@ -1,100 +0,0 @@
package net.Indyuce.mmocore.api.load;
import org.apache.commons.lang.Validate;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
public class MMOLineConfig {
private final String key, value;
private final String[] args;
private JsonObject json;
public MMOLineConfig(String value) {
this.value = value;
/*
* if there is no config, no need to parse the json object. split,
* define key and find arg
*/
if (!value.contains("{") || !value.contains("}")) {
String[] split = value.split("\\ ");
key = split[0];
args = split.length > 1 ? value.replace(key + " ", "").split("\\ ") : new String[0];
return;
}
/*
* load json and extra args
*/
int begin = value.indexOf("{"), end = value.lastIndexOf("}") + 1;
key = value.substring(0, begin);
try {
json = new JsonParser().parse(value.substring(begin, end)).getAsJsonObject();
} catch (JsonParseException exception) {
throw new IllegalArgumentException("Could not load config");
}
String format = value.substring(Math.min(value.length(), end + 1));
args = format.isEmpty() ? new String[0] : format.split("\\ ");
}
/*
* extra arguments outside the config brackets
*/
public String[] args() {
return args;
}
public String getKey() {
return key;
}
public String getString(String path) {
return json.get(path).getAsString();
}
public double getDouble(String path) {
return json.get(path).getAsDouble();
}
public int getInt(String path) {
return json.get(path).getAsInt();
}
public int getInt(String path, int def) {
return json.has(path) ? getInt(path) : def;
}
public long getLong(String path) {
return json.get(path).getAsLong();
}
public boolean getBoolean(String path) {
return json.get(path).getAsBoolean();
}
public boolean getBoolean(String path, boolean def) {
return json.has(path) ? getBoolean(path) : def;
}
public boolean contains(String path) {
return json.has(path);
}
public void validate(String... paths) {
for (String path : paths)
Validate.isTrue(contains(path), "Config is missing parameter '" + path + "'");
}
public void validateArgs(int count) {
Validate.isTrue(args.length >= count, "Config must have at least " + count + " parameters");
}
@Override
public String toString() {
return value;
}
}

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.api.load;
import java.util.logging.Level;
import net.Indyuce.mmocore.MMOCore;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MMOLoadException extends IllegalArgumentException {
private static final long serialVersionUID = -8839506644440697800L;

View File

@ -2,21 +2,42 @@ package net.Indyuce.mmocore.api.load;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public interface MMOLoader {
public Condition loadCondition(MMOLineConfig config);
public class MMOLoader {
public Trigger loadTrigger(MMOLineConfig config);
/*
* MMOLoader was initially an interface but it is now a class so devs do not
* have to add a new method everytime the class is updated.
*/
public Condition loadCondition(MMOLineConfig config) {
return null;
}
public DropItem loadDropItem(MMOLineConfig config);
public Trigger loadTrigger(MMOLineConfig config) {
return null;
}
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section);
public DropItem loadDropItem(MMOLineConfig config) {
return null;
}
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession);
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
return null;
}
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
return null;
}
public BlockType loadBlockType(MMOLineConfig config) {
return null;
}
}

View File

@ -54,8 +54,9 @@ import net.mmogroup.mmolib.version.VersionSound;
public class PlayerData extends OfflinePlayerData {
/*
* is updated everytime the player joins the server. it is kept when the player
* is offline so the plugin can use #isOnline to check if the player is online
* is updated everytime the player joins the server. it is kept when the
* player is offline so the plugin can use #isOnline to check if the player
* is online
*/
private Player player;
@ -108,8 +109,7 @@ public class PlayerData extends OfflinePlayerData {
try {
profess = profess == null ? null : MMOCore.plugin.classManager.get(profess.getId());
} catch (NullPointerException exception) {
MMOCore.log(Level.SEVERE,
"[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
MMOCore.log(Level.SEVERE, "[Userdata] Could not find class " + getProfess().getId() + " while refreshing player data.");
}
int j = 0;
@ -119,8 +119,7 @@ public class PlayerData extends OfflinePlayerData {
j++;
} catch (NullPointerException notFound) {
boundSkills.remove(j);
MMOCore.log(Level.SEVERE, "[Userdata] Could not find skill " + boundSkills.get(j).getSkill().getId()
+ " in class " + getProfess().getId() + " while refreshing player data.");
MMOCore.log(Level.SEVERE, "[Userdata] Could not find skill " + boundSkills.get(j).getSkill().getId() + " in class " + getProfess().getId() + " while refreshing player data.");
}
}
@ -301,8 +300,7 @@ public class PlayerData extends OfflinePlayerData {
}
public void heal(double heal) {
double newest = Math.max(0,
Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
double newest = Math.max(0, Math.min(player.getHealth() + heal, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
if (player.getHealth() == newest)
return;
@ -348,9 +346,7 @@ public class PlayerData extends OfflinePlayerData {
setLastFriendRequest(System.currentTimeMillis());
FriendRequest request = new FriendRequest(this, target);
new ConfigMessage("friend-request")
.addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString())
.sendAsJSon(target.getPlayer());
new ConfigMessage("friend-request").addPlaceholders("player", getPlayer().getName(), "uuid", request.getUniqueId().toString()).sendAsJSon(target.getPlayer());
MMOCore.plugin.requestManager.registerRequest(request);
}
@ -359,12 +355,10 @@ public class PlayerData extends OfflinePlayerData {
giveStellium(-waypoint.getStelliumCost());
new BukkitRunnable() {
int x = player.getLocation().getBlockX(), y = player.getLocation().getBlockY(),
z = player.getLocation().getBlockZ(), t;
int x = player.getLocation().getBlockX(), y = player.getLocation().getBlockY(), z = player.getLocation().getBlockZ(), t;
public void run() {
if (player.getLocation().getBlockX() != x || player.getLocation().getBlockY() != y
|| player.getLocation().getBlockZ() != z) {
if (player.getLocation().getBlockX() != x || player.getLocation().getBlockY() != y || player.getLocation().getBlockZ() != z) {
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, .5f);
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(player);
giveStellium(waypoint.getStelliumCost());
@ -372,8 +366,7 @@ public class PlayerData extends OfflinePlayerData {
return;
}
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((120 - t) / 20))
.send(player);
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((120 - t) / 20)).send(player);
if (t++ >= 100) {
player.teleport(waypoint.getLocation());
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
@ -382,13 +375,10 @@ public class PlayerData extends OfflinePlayerData {
return;
}
player.playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1,
(float) (t / Math.PI * .015 + .5));
player.playSound(player.getLocation(), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound(), 1, (float) (t / Math.PI * .015 + .5));
double r = Math.sin((double) t / 100 * Math.PI);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, player.getLocation()
.add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r),
1.25f, Color.PURPLE);
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.REDSTONE, player.getLocation().add(Math.cos((double) t / 20 + j) * r, (double) t / 50, Math.sin((double) t / 20 + j) * r), 1.25f, Color.PURPLE);
}
}.runTaskTimer(MMOCore.plugin, 0, 1);
}
@ -410,9 +400,7 @@ public class PlayerData extends OfflinePlayerData {
// display hologram
if (MMOCore.plugin.getConfig().getBoolean("display-exp-holograms"))
if (loc != null && MMOCore.plugin.hologramSupport != null)
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5),
MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(),
getPlayer());
MMOCore.plugin.hologramSupport.displayIndicator(loc.add(.5, 1.5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + value).message(), getPlayer());
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
@ -534,8 +522,8 @@ public class PlayerData extends OfflinePlayerData {
}
/*
* returns if the action bar is not being used to display anything else and if
* the general info action bar can be displayed
* returns if the action bar is not being used to display anything else and
* if the general info action bar can be displayed
*/
public boolean canSeeActionBar() {
return actionBarTimeOut < System.currentTimeMillis();
@ -678,9 +666,6 @@ public class PlayerData extends OfflinePlayerData {
public SkillResult cast(SkillInfo skill) {
if (skill.getSkill().isPassive())
return new SkillResult(this, skill, CancelReason.OTHER);
PlayerCastSkillEvent event = new PlayerCastSkillEvent(this, skill);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
@ -688,24 +673,22 @@ public class PlayerData extends OfflinePlayerData {
SkillResult cast = skill.getSkill().whenCast(this, skill);
if (!cast.isSuccessful()) {
if (!skill.getSkill().isPassive()) {
if (cast.getCancelReason() == CancelReason.MANA)
MMOCore.plugin.configManager.getSimpleMessage("casting.no-mana").send(player);
if (cast.getCancelReason() == CancelReason.COOLDOWN)
MMOCore.plugin.configManager.getSimpleMessage("casting.on-cooldown").send(player);
}
return cast;
}
if (!nocd) {
double flatCooldownReduction = Math.max(0, Math.min(1, getStats().getStat(StatType.COOLDOWN_REDUCTION) / 100));
flatCooldownReduction *= flatCooldownReduction > 0 ? skill.getModifier("cooldown", getSkillLevel(skill.getSkill())) * 1000 : 0;
// calculate skill cooldown reduction only if stat is higher than 0
// to save performance
double red = getStats().getStat(StatType.COOLDOWN_REDUCTION) * 10;
red *= red > 0 ? skill.getModifier("cooldown", getSkillLevel(skill.getSkill())) : 0;
skillData.setLastCast(cast.getSkill(), System.currentTimeMillis() - (long) red);
skillData.setLastCast(cast.getSkill(), System.currentTimeMillis() - (long) flatCooldownReduction);
giveMana(-cast.getManaCost());
}

View File

@ -34,7 +34,7 @@ public class PlayerSkillData {
* up to 3 digits)
*/
public long getCooldown(SkillInfo skill) {
return Math.max(0, lastCast(skill.getSkill()) + 1000 * (long) skill.getModifier("cooldown", data.getSkillLevel(skill.getSkill())) - System.currentTimeMillis());
return Math.max(0, lastCast(skill.getSkill()) - System.currentTimeMillis() + (long) (1000. * skill.getModifier("cooldown", data.getSkillLevel(skill.getSkill()))));
}
public long lastCast(Skill skill) {
@ -57,7 +57,7 @@ public class PlayerSkillData {
// ambers = 0;
// }
public int getCachedModifier(String name) {
public double getCachedModifier(String name) {
return cache.containsKey(name) ? cache.get(name).getValue() : 0;
}
@ -68,7 +68,7 @@ public class PlayerSkillData {
cacheModifier(mmSkill, "level", cast.getLevel());
}
public void cacheModifier(MythicMobSkill skill, String name, int value) {
public void cacheModifier(MythicMobSkill skill, String name, double value) {
cache.put(skill.getInternalName() + "." + name, new CachedModifier(value));
}
@ -80,9 +80,9 @@ public class PlayerSkillData {
public class CachedModifier {
private final long date = System.currentTimeMillis();
private final int value;
private final double value;
public CachedModifier(int value) {
public CachedModifier(double value) {
this.value = value;
}
@ -90,7 +90,7 @@ public class PlayerSkillData {
return date + 1000 * 60 < System.currentTimeMillis();
}
public int getValue() {
public double getValue() {
return value;
}
}

View File

@ -25,7 +25,6 @@ import com.mojang.authlib.properties.Property;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.AltChar;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.player.profess.event.EventTrigger;
import net.Indyuce.mmocore.api.player.profess.resource.ManaDisplayOptions;
@ -38,6 +37,7 @@ import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.Indyuce.mmocore.api.util.math.particle.CastingParticle;
import net.Indyuce.mmocore.manager.ClassManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.version.VersionMaterial;
public class PlayerClass {

View File

@ -7,9 +7,9 @@ import java.util.Set;
import org.apache.commons.lang.Validate;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class EventTrigger {
private final String event;

View File

@ -1,15 +1,6 @@
package net.Indyuce.mmocore.api.player.stats;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.api.player.MMOData;
import net.mmogroup.mmolib.api.stat.StatInstance;
import net.mmogroup.mmolib.api.stat.StatMap;
@ -60,36 +51,4 @@ public class PlayerStats {
public double getExtraStat(StatType stat) {
return getInstance(stat).getTotal(0);
}
public CachedStats cache() {
return new CachedStats();
}
public class CachedStats {
private final Player player;
private final Map<String, Double> stats = new HashMap<>();
public CachedStats() {
this.player = data.getPlayer();
for (StatType stat : StatType.values())
this.stats.put(stat.name(), getStat(stat));
}
public Player getPlayer() {
return player;
}
public PlayerData getData() {
return data;
}
public double getStat(StatType stat) {
return stats.get(stat.name());
}
public void damage(LivingEntity target, double value, DamageType... types) {
MMOLib.plugin.getDamage().damage(data.getPlayer(), target, new AttackResult(true, value, types));
}
}
}

View File

@ -13,11 +13,11 @@ import org.bukkit.configuration.file.FileConfiguration;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.manager.QuestManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class Quest {
private final String id;

View File

@ -11,9 +11,9 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class ClickonObjective extends Objective {
private final Location loc;

View File

@ -10,9 +10,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class GoToObjective extends Objective {
private final Location loc;

View File

@ -5,9 +5,9 @@ import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.api.event.EntityKillEntityEvent;
public class KillMobObjective extends Objective {

View File

@ -7,9 +7,9 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MineBlockObjective extends Objective {
private final Material block;

View File

@ -8,11 +8,11 @@ import org.bukkit.boss.BarColor;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class Objective {
private final String id, lore;

View File

@ -4,8 +4,8 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class CommandTrigger extends Trigger {
private final String command;

View File

@ -5,9 +5,9 @@ import org.apache.commons.lang.Validate;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.ExperienceInfo;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class ExperienceTrigger extends Trigger {
private final RandomAmount amount;

View File

@ -3,9 +3,9 @@ package net.Indyuce.mmocore.api.quest.trigger;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.item.SmartGive;
import net.mmogroup.mmolib.api.MMOLineConfig;
import net.mmogroup.mmolib.api.util.SmartGive;
public class ItemTrigger extends Trigger {
private final Material material;

View File

@ -1,8 +1,8 @@
package net.Indyuce.mmocore.api.quest.trigger;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class ManaTrigger extends Trigger {
private final RandomAmount amount;

View File

@ -3,8 +3,8 @@ package net.Indyuce.mmocore.api.quest.trigger;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MessageTrigger extends Trigger {
private final String message;

View File

@ -2,8 +2,8 @@ package net.Indyuce.mmocore.api.quest.trigger;
import org.bukkit.Sound;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class SoundTrigger extends Trigger {
private final Sound sound;

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmocore.api.quest.trigger;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.ManaTrigger.Operation;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class StelliumTrigger extends Trigger {
private final RandomAmount amount;

View File

@ -3,8 +3,8 @@ package net.Indyuce.mmocore.api.quest.trigger;
import org.bukkit.Bukkit;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.mmogroup.mmolib.api.MMOLineConfig;
public abstract class Trigger {
private final long delay;

View File

@ -15,7 +15,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.skill.SkillResult.CancelReason;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
@ -131,9 +130,7 @@ public abstract class Skill {
* not overriden for passive skills therefore not abstract.
*/
public SkillResult whenCast(PlayerData data, SkillInfo skill) {
SkillResult cast = new SkillResult(data, skill);
cast.abort(CancelReason.OTHER);
return cast;
return new SkillResult(data, skill);
}
public SkillInfo newSkillInfo(ConfigurationSection config) {
@ -190,8 +187,8 @@ public abstract class Skill {
modifiers.put(modifier, linear);
}
public int getModifier(String modifier, int level) {
return (int) modifiers.get(modifier).calculate(level);
public double getModifier(String modifier, int level) {
return modifiers.get(modifier).calculate(level);
}
public boolean isUnlocked(PlayerData profess) {

View File

@ -64,7 +64,7 @@ public class SkillResult {
cancelReason = reason;
}
public int getModifier(String modifier) {
public double getModifier(String modifier) {
return skill.getModifier(modifier, level);
}

View File

@ -22,6 +22,7 @@ import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import net.Indyuce.mmocore.MMOCore;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.version.VersionMaterial;
public class MMOCoreUtils {
public static boolean pluginItem(ItemStack item) {
@ -48,6 +49,10 @@ public class MMOCoreUtils {
return builder.toString();
}
public static boolean isPlayerHead(Material material) {
return material == VersionMaterial.PLAYER_HEAD.toMaterial() || material == VersionMaterial.PLAYER_WALL_HEAD.toMaterial();
}
public static ItemStack readIcon(String string) {
try {
Validate.notNull(string, "String cannot be null");

View File

@ -14,7 +14,6 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import com.mojang.authlib.GameProfile;
@ -33,7 +32,7 @@ public class ConfigItem {
private final int damage, modeldata;
private boolean unbreakable;
private Map<String, String> placeholders = new HashMap<>();
private final Map<String, String> placeholders = new HashMap<>();
public ConfigItem(ConfigurationSection config) {
id = config.getName();
@ -107,13 +106,13 @@ public class ConfigItem {
ItemStack item = getItem(amount);
ItemMeta meta = item.getItemMeta();
if (meta instanceof Damageable)
((Damageable) meta).setDamage(damage);
if (MMOLib.plugin.getVersion().getWrapper().isDamageable(item))
MMOLib.plugin.getVersion().getWrapper().applyDurability(item, meta, damage);
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 13))
if (MMOLib.plugin.getVersion().isStrictlyHigher(1, 13))
meta.setCustomModelData(modeldata);
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && texture != null) {
if (item.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() && texture != null)
try {
Field profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
@ -123,7 +122,6 @@ public class ConfigItem {
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exception) {
MMOCore.log(Level.WARNING, "Could not load config item texture of " + id);
}
}
meta.addItemFlags(ItemFlag.values());
meta.setDisplayName(format(name));

View File

@ -1,32 +0,0 @@
package net.Indyuce.mmocore.api.util.item;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class SmartGive {
private final Inventory inv;
private final Location loc;
public SmartGive(Player player) {
inv = player.getInventory();
loc = player.getLocation();
}
/*
* either give directly the item to the player or drops it on the ground if
* there is not enough space in the player inventory.
*/
public void give(ItemStack... item) {
for (ItemStack drop : inv.addItem(item).values())
loc.getWorld().dropItem(loc, drop);
}
public void give(List<ItemStack> item) {
for (ItemStack drop : inv.addItem(item.toArray(new ItemStack[item.size()])).values())
loc.getWorld().dropItem(loc, drop);
}
}

View File

@ -6,10 +6,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.Indyuce.mmocore.api.util.item.SmartGive;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.api.util.SmartGive;
public class CoinsCommandMap extends CommandEnd {
public CoinsCommandMap(CommandMap parent) {

View File

@ -8,10 +8,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.util.item.CurrencyItem;
import net.Indyuce.mmocore.api.util.item.SmartGive;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
import net.mmogroup.mmolib.api.util.SmartGive;
public class NoteCommandMap extends CommandEnd {
public NoteCommandMap(CommandMap parent) {

View File

@ -2,34 +2,11 @@ package net.Indyuce.mmocore.comp.citizens;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class CitizensMMOLoader implements MMOLoader {
@Override
public Condition loadCondition(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public Trigger loadTrigger(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public DropItem loadDropItem(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
public class CitizensMMOLoader extends MMOLoader {
@Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
@ -42,10 +19,4 @@ public class CitizensMMOLoader implements MMOLoader {
return null;
}
@Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -7,10 +7,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class GetItemObjective extends Objective {
private Material material;

View File

@ -4,10 +4,10 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class TalktoCitizenObjective extends Objective {
private int id;

View File

@ -2,25 +2,17 @@ package net.Indyuce.mmocore.comp.mythicmobs;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource;
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective;
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicMobSkillTrigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MythicMobsMMOLoader implements MMOLoader {
@Override
public Condition loadCondition(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
public class MythicMobsMMOLoader extends MMOLoader {
@Override
public Trigger loadTrigger(MMOLineConfig config) {
@ -31,12 +23,6 @@ public class MythicMobsMMOLoader implements MMOLoader {
return null;
}
@Override
public DropItem loadDropItem(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {

View File

@ -8,9 +8,9 @@ import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.SpecificExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.profession.ExperienceManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class KillMythicMobExperienceSource extends SpecificExperienceSource<String> {
private final String internalName;

View File

@ -6,10 +6,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
import net.Indyuce.mmocore.api.quest.QuestProgress;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class KillMythicMobObjective extends Objective {
private final String internalName;

View File

@ -9,9 +9,9 @@ import org.bukkit.entity.Entity;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.skills.Skill;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MythicMobSkillTrigger extends Trigger {
private final Skill skill;

View File

@ -1,12 +0,0 @@
package net.Indyuce.mmocore.comp.rpg;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.PlayerStats.CachedStats;
public class DefaultRPGUtilHandler implements RPGUtilHandler {
@Override
public CachedStats cachePlayerStats(PlayerData playerData) {
return playerData.getStats().cache();
}
}

View File

@ -1,8 +0,0 @@
package net.Indyuce.mmocore.comp.rpg;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.PlayerStats.CachedStats;
public interface RPGUtilHandler {
public CachedStats cachePlayerStats(PlayerData playerData);
}

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmocore.comp.vault;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MoneyTrigger extends Trigger {
private final RandomAmount amount;

View File

@ -1,23 +1,10 @@
package net.Indyuce.mmocore.comp.vault;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class VaultMMOLoader implements MMOLoader {
@Override
public Condition loadCondition(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
public class VaultMMOLoader extends MMOLoader {
@Override
public Trigger loadTrigger(MMOLineConfig config) {
@ -27,22 +14,4 @@ public class VaultMMOLoader implements MMOLoader {
return null;
}
@Override
public DropItem loadDropItem(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
// TODO Auto-generated method stub
return null;
}
@Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class RegionCondition extends Condition {
private final List<String> names;

View File

@ -1,17 +1,10 @@
package net.Indyuce.mmocore.comp.worldguard;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class WorldGuardMMOLoader implements MMOLoader {
public class WorldGuardMMOLoader extends MMOLoader {
@Override
public Condition loadCondition(MMOLineConfig config) {
@ -21,28 +14,4 @@ public class WorldGuardMMOLoader implements MMOLoader {
return null;
}
@Override
public Trigger loadTrigger(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public DropItem loadDropItem(MMOLineConfig config) {
// TODO Auto-generated method stub
return null;
}
@Override
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
// TODO Auto-generated method stub
return null;
}
@Override
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -32,6 +32,7 @@ public class AttributeView extends EditableInventory {
@Override
public Placeholders getPlaceholders(PluginInventory inv, int n) {
Placeholders holders = new Placeholders();
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
holders.register("points", inv.getPlayerData().getAttributeReallocationPoints());
holders.register("total", inv.getPlayerData().getAttributes().countSkillPoints());
return holders;

View File

@ -3,9 +3,9 @@ package net.Indyuce.mmocore.gui.api.item;
import org.bukkit.configuration.ConfigurationSection;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmocore.gui.api.PluginInventory;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class TriggerItem extends InventoryPlaceholderItem {
private final Trigger trigger;

View File

@ -13,9 +13,9 @@ import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.item.ConfigItem;
import net.Indyuce.mmocore.api.util.item.SmartGive;
import net.Indyuce.mmocore.gui.api.PluginInventory;
import net.mmogroup.mmolib.api.item.NBTItem;
import net.mmogroup.mmolib.api.util.SmartGive;
public class DepositMenu extends PluginInventory {
private ItemStack depositItem;

View File

@ -18,12 +18,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.block.BlockInfo;
import net.Indyuce.mmocore.api.event.CustomBlockMineEvent;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.manager.CustomBlockManager.BlockInfo;
import net.Indyuce.mmocore.manager.RestrictionManager.BlockPermissions;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.CustomBlock;
import net.mmogroup.mmolib.MMOLib;
public class BlockListener implements Listener {
@ -37,19 +35,20 @@ public class BlockListener implements Listener {
String savedData = MMOLib.plugin.getVersion().isStrictlyHigher(1, 12) ? event.getBlock().getBlockData().getAsString() : "";
Block block = event.getBlock();
/*
* if custom mining enabled, check for item breaking restrictions
*/
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player, block.getLocation());
ItemStack item = player.getInventory().getItemInMainHand();
if (customMine) {
if (!customMine)
return;
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
if (info == null) {
event.setCancelled(true);
return;
}
/*
* calls the event and listen for cancel & for drops changes... also
* allows to apply tool durability & enchants to drops, etc.
@ -61,13 +60,14 @@ public class BlockListener implements Listener {
return;
}
ItemStack item = player.getInventory().getItemInMainHand();
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType());
if (perms == null) {
event.setCancelled(true);
return;
}
if (!perms.canMine(getBlockName(block))) {
if (!perms.canMine(info.getBlock())) {
MMOCore.plugin.configManager.getSimpleMessage("cannot-break").send(player);
event.setCancelled(true);
return;
@ -77,26 +77,26 @@ public class BlockListener implements Listener {
* remove vanilla drops if needed
*/
if (!info.hasVanillaDrops()) {
event.setDropItems(false); // May not work
// event.setCancelled(true);
// event.setDropItems(false); // May not work
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
}
/*
* apply triggers, add experience info to the event so the other
* events can give exp to other TOOLS and display HOLOGRAMS
* apply triggers, add experience info to the event so the other events
* can give exp to other TOOLS and display HOLOGRAMS
*/
if (info.hasTriggers() && !block.hasMetadata("player_placed")) {
PlayerData playerData = PlayerData.get(player);
info.getTriggers().forEach(trigger -> trigger.apply(playerData));
/**
* if (!block.hasMetadata("player_placed") &&
* info.hasExperience() && MMOCore.plugin.hasHolograms())
* if (!block.hasMetadata("player_placed") && info.hasExperience()
* && MMOCore.plugin.hasHolograms())
* MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5,
* 1.5, .5),
* MMOCore.plugin.configManager.getSimpleMessage("exp-hologram",
* "exp", "" +
* called.getGainedExperience().getValue()).message(), player);
* "exp", "" + called.getGainedExperience().getValue()).message(),
* player);
*/
}
@ -104,7 +104,7 @@ public class BlockListener implements Listener {
* apply drop tables
*/
if (info.hasDropTable()) {
Location dropLocation = getSafeDropLocation(block, true);
Location dropLocation = getSafeDropLocation(block, !block.getType().isSolid() || !(info.regenerates() && info.getRegenerationInfo().hasTemporaryBlock()));
for (ItemStack drop : called.getDrops())
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
block.getWorld().dropItemNaturally(dropLocation, drop);
@ -115,23 +115,11 @@ public class BlockListener implements Listener {
*/
if (info.hasRegen()) {
if (MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(Bukkit.createBlockData(savedData), block.getLocation()));
MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()));
else
MMOCore.plugin.mineManager.initialize(info.generateRegenInfo(block.getLocation()));
MMOCore.plugin.mineManager.initialize(info.startRegeneration(block.getLocation()));
}
}
}
private String getBlockName(Block block) {
if (MMOCore.plugin.isMILoaded())
if (MMOItems.plugin.getCustomBlocks().isMushroomBlock(block.getType())) {
CustomBlock cblock = CustomBlock.getFromData(block.getBlockData());
if (cblock != null)
return "MICUSTOM_" + cblock.getId();
}
return block.getType().toString();
}
@EventHandler(priority = EventPriority.HIGH)
public void b(BlockPlaceEvent event) {
@ -146,13 +134,12 @@ public class BlockListener implements Listener {
BlockFace direction = event.getDirection();
movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) {
for (Block b : event.getBlocks())
if (b.hasMetadata("player_placed")) {
movedBlock = b.getRelative(direction);
movedBlock.setMetadata("player_placed", new FixedMetadataValue(MMOCore.plugin, true));
}
}
}
@EventHandler
public void c2(BlockPistonRetractEvent event) {
@ -170,10 +157,12 @@ public class BlockListener implements Listener {
if (block.getType() == Material.AIR && self)
return block.getLocation();
Block relative;
for (BlockFace face : order)
if (!(relative = block.getRelative(face)).getType().isSolid())
return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.3));
for (BlockFace face : order) {
Block relative = block.getRelative(face);
if (!relative.getType().isSolid())
return relative.getLocation().add(block.getLocation().subtract(relative.getLocation()).multiply(.6));
}
return block.getLocation();
}
}

View File

@ -5,67 +5,86 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.logging.Level;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.DropTable;
import net.Indyuce.mmocore.api.block.BlockInfo;
import net.Indyuce.mmocore.api.block.BlockInfo.RegeneratingBlock;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.block.SkullBlockType;
import net.Indyuce.mmocore.api.block.VanillaBlockType;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.quest.trigger.ExperienceTrigger;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.CustomBlock;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.version.VersionMaterial;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class CustomBlockManager extends MMOManager {
/*
* registered block infos
*/
private final Map<String, BlockInfo> map = new HashMap<>();
private final Set<RegenInfo> active = new HashSet<>();
/*
* blocks that are regenerating and that must be refreshed whenever the
* server reloads or shuts down not to hurt the world map
*/
private final Set<RegeneratingBlock> active = new HashSet<>();
/* list in which both block regen and block permissions are enabled. */
private final List<Condition> customMineConditions = new ArrayList<>();
public void loadDropTables(ConfigurationSection config) {
for (String key : config.getKeys(false))
try {
BlockInfo info = new BlockInfo(config.getConfigurationSection(key));
register(info.getHeadValue().isEmpty() ? info.getCustomBlockID() > 0 ? "mi-custom-" + info.getCustomBlockID() : info.getBlock().name() : info.getHeadValue(), info);
} catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "Could not load custom block '" + key + "': " + exception.getMessage());
}
/*
* list of functions which let
*/
private final List<Function<Block, BlockType>> blockTypes = new ArrayList<>();
public CustomBlockManager() {
registerBlockType(block -> MMOCoreUtils.isPlayerHead(block.getType()) ? new SkullBlockType(block) : null);
}
public void register(String key, BlockInfo regen) {
map.put(key, regen);
public void registerBlockType(Function<Block, BlockType> function) {
blockTypes.add(function);
}
public void register(BlockInfo regen) {
map.put(regen.generateKey(), regen);
}
public BlockInfo getInfo(Block block) {
if(isPlayerSkull(block.getType())) {
String skullValue = MMOLib.plugin.getNMS().getSkullValue(block);
return map.getOrDefault(skullValue, map.getOrDefault(block.getType().name(), null));
}
if(MMOCore.plugin.isMILoaded())
if(MMOItems.plugin.getCustomBlocks().isMushroomBlock(block.getType())) {
CustomBlock cblock = CustomBlock.getFromData(block.getBlockData());
if(cblock != null)
return map.getOrDefault("mi-custom-" + cblock.getId(), map.getOrDefault(block.getType().name(), null));
return map.getOrDefault(findBlockType(block).generateKey(), null);
}
return map.getOrDefault(block.getType().name(), null);
public BlockType findBlockType(Block block) {
for (Function<Block, BlockType> blockType : blockTypes) {
BlockType type = blockType.apply(block);
if (type != null)
return type;
}
return new VanillaBlockType(block);
}
public void initialize(RegeneratingBlock info) {
active.add(info);
if (info.getRegeneratingBlock().getRegenerationInfo().hasTemporaryBlock())
info.getRegeneratingBlock().getRegenerationInfo().getTemporaryBlock().place(info.getLocation(), info);
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> regen(info), info.getRegeneratingBlock().getRegenerationInfo().getTime());
}
private void regen(RegeneratingBlock info) {
info.getRegeneratingBlock().getBlock().place(info.getLocation(), info);
active.remove(info);
info.getLocation().getBlock().getState().update();
}
/*
@ -73,36 +92,7 @@ public class CustomBlockManager extends MMOManager {
* are reset and put back in place.
*/
public void resetRemainingBlocks() {
active.forEach(info -> { regen(info); });
}
public void initialize(RegenInfo info) {
active.add(info);
if(MMOCore.plugin.isMILoaded() && info.getRegen().getCustomRegenBlockID() != 0) {
CustomBlock block = MMOItems.plugin.getCustomBlocks().getBlock(info.getRegen().getCustomRegenBlockID());
info.getLocation().getBlock().setType(block.getType());
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 12)) info.getLocation().getBlock().setBlockData(block.getBlockData());
}
else info.getLocation().getBlock().setType(info.getRegen().getTemporaryBlock());
if(isPlayerSkull(info.getLocation().getBlock().getType())) {
if(isPlayerSkull(info.getRegen().getBlock()) && MMOLib.plugin.getVersion().isStrictlyHigher(1, 12)) info.getLocation().getBlock().setBlockData(info.getBlockData());
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getRegenHeadValue());
}
new BukkitRunnable() {
public void run() { regen(info); }
}.runTaskLater(MMOCore.plugin, info.getRegen().getRegenTime());
}
private void regen(RegenInfo info) {
if(MMOLib.plugin.getVersion().isStrictlyHigher(1, 12))
info.getLocation().getBlock().setBlockData(info.getBlockData());
if(isPlayerSkull(info.getLocation().getBlock().getType()))
MMOLib.plugin.getNMS().setSkullValue(info.getLocation().getBlock(), info.getRegen().getHeadValue());
active.remove(info);
info.getLocation().getBlock().getState().update();
active.forEach(info -> regen(info));
}
public boolean isEnabled(Entity entity) {
@ -118,161 +108,12 @@ public class CustomBlockManager extends MMOManager {
return true;
}
private boolean isPlayerSkull(Material block) {
return block == VersionMaterial.PLAYER_HEAD.toMaterial() ||
block == VersionMaterial.PLAYER_WALL_HEAD.toMaterial();
}
public class BlockInfo {
private final Material block;
private final DropTable table;
private final boolean vanillaDrops;
private final String headValue;
private final List<Trigger> triggers = new ArrayList<>();
private final ExperienceTrigger experience;
private final int customBlockId;
/*
* options for block regen.
*/
private Material temporary;
private int regenTime = -1;
private int regenCustomBlockId;
private String regenHeadValue;
public BlockInfo(ConfigurationSection config) {
Validate.notNull(config, "Could not load config");
block = Material.valueOf(config.getString("material", "BOOKSHELF").toUpperCase().replace("-", "_").replace(" ", "_"));
customBlockId = config.getInt("mi-custom-block", 0);
headValue = config.getString("head-value", "");
table = config.contains("drop-table") ? MMOCore.plugin.dropTableManager.loadDropTable(config.get("drop-table")) : null;
vanillaDrops = config.getBoolean("vanilla-drops", true);
if (config.contains("regen")) {
temporary = Material.valueOf(config.getString("regen.temp-block", "BOOKSHELF").toUpperCase().replace("-", "_").replace(" ", "_"));
regenCustomBlockId = config.getInt("regen.mi-custom-block", 0);
regenHeadValue = config.getString("regen.head-value", "");
regenTime = config.getInt("regen.time");
}
if (config.contains("triggers")) {
List<String> list = config.getStringList("triggers");
Validate.notNull(list, "Could not load triggers");
for (String key : list)
public void loadDropTables(ConfigurationSection config) {
for (String key : config.getKeys(false))
try {
triggers.add(MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(key)));
} catch (MMOLoadException exception) {
exception.printConsole("BlockRegen", "trigger");
}
}
Optional<Trigger> opt = triggers.stream().filter(trigger -> (trigger instanceof ExperienceTrigger)).findFirst();
experience = opt.isPresent() ? (ExperienceTrigger) opt.get() : null;
}
public String getHeadValue() {
return headValue;
}
public boolean hasVanillaDrops() {
return vanillaDrops;
}
public Material getBlock() {
return block;
}
public DropTable getDropTable() {
return table;
}
public List<ItemStack> collectDrops() {
return hasDropTable() ? table.collect() : new ArrayList<>();
}
public boolean hasDropTable() {
return table != null;
}
public boolean hasRegen() {
return regenTime > 0;
}
public int getRegenTime() {
return regenTime;
}
public Material getTemporaryBlock() {
return temporary;
}
public String getRegenHeadValue() {
return regenHeadValue;
}
public RegenInfo generateRegenInfo(BlockData data, Location loc) {
return new RegenInfo(data, loc, this);
}
public RegenInfo generateRegenInfo(Location loc) {
return new RegenInfo(null, loc, this);
}
public int getCustomBlockID() {
return customBlockId;
}
public int getCustomRegenBlockID() {
return regenCustomBlockId;
}
public boolean hasExperience() {
return experience != null;
}
public ExperienceTrigger getExperience() {
return experience;
}
public boolean hasTriggers() {
return !triggers.isEmpty();
}
public List<Trigger> getTriggers() {
return triggers;
}
}
public class RegenInfo {
private final BlockData data;
private final Location loc;
private final BlockInfo regen;
private final long date = System.currentTimeMillis();
public RegenInfo(BlockData data, Location loc, BlockInfo regen) {
this.data = data;
this.loc = loc;
this.regen = regen;
}
public boolean isTimedOut() {
return date + regen.getRegenTime() * 50 < System.currentTimeMillis();
}
public BlockData getBlockData() {
return data;
}
public Location getLocation() {
return loc;
}
public BlockInfo getRegen() {
return regen;
register(new BlockInfo(config.getConfigurationSection(key)));
} catch (IllegalArgumentException exception) {
MMOCore.log(Level.WARNING, "Could not load custom block '" + key + "': " + exception.getMessage());
}
}

View File

@ -4,20 +4,22 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
import com.google.gson.JsonParseException;
import net.Indyuce.mmocore.api.block.BlockType;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.dropitem.DropItem;
import net.Indyuce.mmocore.api.experience.Profession;
import net.Indyuce.mmocore.api.experience.source.type.ExperienceSource;
import net.Indyuce.mmocore.api.load.DefaultMMOLoader;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.api.load.MMOLoader;
import net.Indyuce.mmocore.api.quest.objective.Objective;
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class MMOLoadManager {
private final List<MMOLoader> loaders = new ArrayList<>();
@ -27,27 +29,33 @@ public class MMOLoadManager {
}
public void registerLoader(MMOLoader loader) {
Validate.notNull(loader, "Loader must not be null");
loaders.add(loader);
}
public Condition loadCondition(MMOLineConfig config) {
return load(Condition.class, config, (loader) -> loader.loadCondition(config));
return load(Condition.class, config, loader -> loader.loadCondition(config));
}
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
return load(Objective.class, config, (loader) -> loader.loadObjective(config, section));
return load(Objective.class, config, loader -> loader.loadObjective(config, section));
}
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, Profession profession) {
return load(ExperienceSource.class, config, (loader) -> loader.loadExperienceSource(config, profession));
return load(ExperienceSource.class, config, loader -> loader.loadExperienceSource(config, profession));
}
public Trigger loadTrigger(MMOLineConfig config) {
return load(Trigger.class, config, (loader) -> loader.loadTrigger(config));
return load(Trigger.class, config, loader -> loader.loadTrigger(config));
}
public DropItem loadDropItem(MMOLineConfig config) {
return load(DropItem.class, config, (loader) -> loader.loadDropItem(config));
return load(DropItem.class, config, loader -> loader.loadDropItem(config));
}
public BlockType loadBlockType(MMOLineConfig config) {
return load(BlockType.class, config, loader -> loader.loadBlockType(config));
}
private <T> T load(Class<T> c, MMOLineConfig config, Function<MMOLoader, T> func) {

View File

@ -12,9 +12,11 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.block.BlockType;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class RestrictionManager {
private Set<String> breakBlackList = new HashSet<>();
// private Set<String> breakBlackList = new HashSet<>();
private Map<Material, BlockPermissions> map = new HashMap<>();
public RestrictionManager(FileConfiguration config) {
@ -37,20 +39,21 @@ public class RestrictionManager {
public void register(BlockPermissions perms) {
if (perms.isValid()) {
map.put(perms.getTool(), perms);
perms.getMinable().forEach(material -> breakBlackList.add(material));
// perms.getMinable().forEach(material ->
// breakBlackList.add(material));
}
}
public boolean isBlackListed(String s) {
return breakBlackList.contains(s);
}
// public boolean isBlackListed(String s) {
// return breakBlackList.contains(s);
// }
public BlockPermissions getPermissions(Material tool) {
return map.containsKey(tool) ? map.get(tool) : null;
}
public class BlockPermissions {
private final Set<String> canMine = new HashSet<>();
private final Set<BlockType> mineable = new HashSet<>();
private final Material tool;
private BlockPermissions parent;
@ -73,36 +76,26 @@ public class RestrictionManager {
}
public void load() {
if (loaded.contains("parent")) {
String str = loaded.getString("parent").toUpperCase().replace("-", "_").replace(" ", "_");
Validate.notNull(str, "Could not load parent");
parent = map.get(Material.valueOf(str));
}
if (loaded.contains("parent"))
parent = map.get(Material.valueOf(loaded.getString("parent", "???").toUpperCase().replace("-", "_").replace(" ", "_")));
for (String key : loaded.getStringList("can-mine"))
canMine.add(key.toUpperCase().replace("-", "_"));
mineable.add(MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(key)));
loaded = null;
}
public void setParent(BlockPermissions parent) {
this.parent = parent;
}
public void addPermission(String s) {
canMine.add(s);
public void addPermission(BlockType block) {
mineable.add(block);
}
// recursive function to check for parent permissions
public boolean canMine(String material) {
return canMine.contains(material) || (parent != null && parent.canMine(material));
}
public boolean canMine(BlockType type) {
String key = type.generateKey();
for (BlockType mineable : this.mineable)
if (mineable.generateKey().equals(key))
return true;
public Set<String> getMinable() {
Set<String> total = new HashSet<>(canMine);
if (parent != null)
total.addAll(parent.getMinable());
return total;
return parent != null && parent.canMine(type);
}
public Material getTool() {

View File

@ -16,9 +16,9 @@ import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.droptable.condition.Condition;
import net.Indyuce.mmocore.api.droptable.condition.ConditionInstance;
import net.Indyuce.mmocore.api.droptable.dropitem.fishing.FishingDropItem;
import net.Indyuce.mmocore.api.load.MMOLineConfig;
import net.Indyuce.mmocore.api.load.MMOLoadException;
import net.Indyuce.mmocore.manager.MMOManager;
import net.mmogroup.mmolib.api.MMOLineConfig;
public class FishingManager extends MMOManager {
private final Set<FishingDropTable> tables = new LinkedHashSet<>();

View File

@ -36,7 +36,7 @@ public class Deep_Wound extends Skill {
LivingEntity target = cast.getTarget();
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 2, 2);
target.getWorld().spawnParticle(Particle.CRIT, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, .7);
target.getWorld().spawnParticle(Particle.BLOCK_CRACK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, 2, Material.REDSTONE_BLOCK.createBlockData());
MMOLib.plugin.getVersion().getWrapper().spawnParticle(Particle.BLOCK_CRACK, target.getLocation().add(0, target.getHeight() / 2, 0), 32, 0, 0, 0, 2, Material.REDSTONE_BLOCK);
double max = target.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
double ratio = (max - target.getHealth()) / max;

View File

@ -17,6 +17,7 @@ import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.api.MMORayTraceResult;
import net.mmogroup.mmolib.version.VersionMaterial;
import net.mmogroup.mmolib.version.VersionSound;
@ -24,11 +25,12 @@ public class Fireball extends Skill {
public Fireball() {
super();
setMaterial(VersionMaterial.FIRE_CHARGE.toMaterial());
setLore("Casts a deadly fireball onto your", "target, dealing &c{damage} &7damage upon contact", "and igniting it for &c{ignite} &7seconds.", "", "Shatters into 3 blazing hot shards which stick", "to walls and explode 3 seconds later, dealing", "33% of the initial spell damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
setLore("Casts a deadly fireball onto your", "target, dealing &c{damage} &7damage upon contact", "and igniting it for &c{ignite} &7seconds.", "", "Shatters into 3 blazing hot shards which stick", "to walls and explode 3 seconds later, dealing", "&c{ratio}% &7of the initial spell damage.", "", "&e{cooldown}s Cooldown", "&9Costs {mana} {mana_name}");
addModifier("mana", new LinearValue(15, 1));
addModifier("damage", new LinearValue(5, 3));
addModifier("ignite", new LinearValue(2, .1));
addModifier("ratio", new LinearValue(50, 3));
addModifier("cooldown", new LinearValue(9, -.1, 1, 5));
}
@ -41,8 +43,8 @@ public class Fireball extends Skill {
data.getPlayer().getWorld().playSound(data.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 1);
new BukkitRunnable() {
int j = 0;
Vector vec = data.getPlayer().getEyeLocation().getDirection();
Location loc = data.getPlayer().getLocation().add(0, 1.3, 0);
final Vector vec = data.getPlayer().getEyeLocation().getDirection();
final Location loc = data.getPlayer().getLocation().add(0, 1.3, 0);
public void run() {
if (j++ > 40) {
@ -52,13 +54,10 @@ public class Fireball extends Skill {
loc.add(vec);
if (j % 3 == 0)
loc.getWorld().playSound(loc, Sound.BLOCK_FIRE_AMBIENT, 2, 1);
// loc.getWorld().spawnParticle(Particle.FLAME, loc, 5, .12,
// .12, .12, 0);
loc.getWorld().spawnParticle(Particle.FLAME, loc, 4, .02, .02, .02, 0);
loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
// if (random.nextDouble() < .3)
// loc.getWorld().spawnParticle(Particle.LAVA, loc, 0);
for (Entity target : MMOCoreUtils.getNearbyChunkEntities(loc))
if (MMOLib.plugin.getNMS().isInBoundingBox(target, loc) && MMOCoreUtils.canTarget(data.getPlayer(), target)) {
@ -66,11 +65,42 @@ public class Fireball extends Skill {
loc.getWorld().spawnParticle(Particle.FLAME, loc, 32, 0, 0, 0, .1);
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1);
target.setFireTicks((int) (target.getFireTicks() + cast.getModifier("ignite") * 20));
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) target, new AttackResult(cast.getModifier("damage"), DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGIC));
double damage = cast.getModifier("damage");
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) target, new AttackResult(damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGIC));
new BukkitRunnable() {
int i = 0;
@Override
public void run() {
if (i++ > 2) {
cancel();
return;
}
double range = 2.5 * (1 + random.nextDouble());
Vector dir = randomDirection();
loc.getWorld().playSound(loc, Sound.ENTITY_BLAZE_HURT, 2, 1.5f);
MMORayTraceResult result = MMOLib.plugin.getVersion().getWrapper().rayTrace(loc, dir, range, entity -> MMOCoreUtils.canTarget(data.getPlayer(), entity));
if (result.hasHit())
MMOLib.plugin.getDamage().damage(data.getPlayer(), result.getHit(), new AttackResult(damage, DamageType.SKILL, DamageType.PROJECTILE, DamageType.MAGIC));
result.draw(loc.clone(), dir, 8, tick -> tick.getWorld().spawnParticle(Particle.FLAME, tick, 0));
}
}.runTaskTimer(MMOCore.plugin, 3, 3);
cancel();
return;
}
}
}.runTaskTimer(MMOCore.plugin, 0, 1);
return cast;
}
private Vector randomDirection() {
double x = random.nextDouble() - .5, y = (random.nextDouble() - .2) / 2, z = random.nextDouble() - .5;
Vector dir = new Vector(x, y, z);
return dir.lengthSquared() == 0 ? new Vector(1, 0, 0) : dir.normalize();
}
}

View File

@ -17,12 +17,13 @@ import org.bukkit.util.Vector;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.PlayerStats.CachedStats;
import net.Indyuce.mmocore.api.skill.Skill;
import net.Indyuce.mmocore.api.skill.SkillResult;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
import net.Indyuce.mmocore.api.util.math.particle.ParabolicProjectile;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.AttackResult;
import net.mmogroup.mmolib.api.DamageType;
import net.mmogroup.mmolib.api.event.PlayerAttackEvent;
import net.mmogroup.mmolib.version.VersionMaterial;
@ -59,7 +60,6 @@ public class Power_Mark extends Skill implements Listener {
public class PowerMark extends BukkitRunnable implements Listener {
private final PlayerData data;
private final Location loc;
private final CachedStats stats;
private double duration, ratio, stun;
@ -69,7 +69,6 @@ public class Power_Mark extends Skill implements Listener {
public PowerMark(PlayerData data, SkillResult cast, Location loc) {
this.data = data;
this.loc = loc;
this.stats = MMOCore.plugin.rpgUtilHandler.cachePlayerStats(data);
loc.getWorld().playSound(loc, Sound.BLOCK_END_PORTAL_FRAME_FILL, 2, 1);
@ -81,7 +80,7 @@ public class Power_Mark extends Skill implements Listener {
Bukkit.getPluginManager().registerEvents(this, MMOCore.plugin);
}
public void unregister() {
private void unregister() {
PlayerAttackEvent.getHandlerList().unregister(this);
cancel();
}
@ -115,9 +114,9 @@ public class Power_Mark extends Skill implements Listener {
for (Entity entity : MMOCoreUtils.getNearbyChunkEntities(loc))
if (entity.getLocation().distanceSquared(loc) < 25 && MMOCoreUtils.canTarget(data.getPlayer(), entity)) {
entity.setVelocity(format(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.3));
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, (int) (stun * 20), 10, false, false));
stats.damage((LivingEntity) entity, accumulate, DamageType.SKILL, DamageType.MAGIC);
MMOLib.plugin.getDamage().damage(data.getPlayer(), (LivingEntity) entity, new AttackResult(accumulate, DamageType.SKILL, DamageType.MAGIC));
entity.setVelocity(format(entity.getLocation().subtract(loc).toVector().setY(0)).setY(.3));
}
return;
}

View File

@ -80,7 +80,7 @@ health-scale:
enabled: true
scale: 20
# Allows to toggle exp hologram from gaining experiences
# Allows to toggle exp hologram from gaining experience
display-exp-holograms: true
# Players can swap their hotbar with the 9 inventory slots

View File

@ -8,6 +8,9 @@ experience:
base: 20
per-level: 3
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
exp-sources:
- 'brewpotion{effect=SPEED}'

View File

@ -8,6 +8,9 @@ experience:
base: 10
per-level: 2
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
# Remove the 'enchant' parameter from the line config
# to make the profession get EXP with ANY enchant.

View File

@ -8,6 +8,9 @@ experience:
base: 10
per-level: 2
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
exp-sources:
- 'mineblock{type=CARROTS;amount=1-3;crop=true;player-placed:true}'
- 'mineblock{type=POTATOES;amount=1-3;crop=true;player-placed:true}'

View File

@ -8,6 +8,9 @@ experience:
base: 20
per-level: 3
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
exp-sources: {}
# Fishing drop tables which override MC default.

View File

@ -19,21 +19,40 @@ exp-curve: mining
# configure drop tables with MMOItems.
# Block Regen is currently only possible using custom mining.
on-mine:
# Config example showing how you can bind drops and experience
# to custom player heads based on the skull texture.
diamond-skull:
# Diamond ore skull texture
material: 'skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2EzYmI4NWRlYzEzMjlmZTgyOWNjNmNkY2QzNGUxYmQ2MGVlODMyZjU3MjYyOTY1MWYxNGI1ZTE0NTU1ZGJiMSJ9fX0="}'
drop-table:
items:
- 'vanilla{type=DIAMOND} 1 1-4'
vanilla-drops: false
regen:
time: 20
# Stone block skull texture
temp-block: 'skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTU0ODE4MjMzYzgxMTg3M2U4NWY1YTRlYTQ0MjliNzVmMjNiNmFlMGVhNmY1ZmMwZjdiYjQyMGQ3YzQ3MSJ9fX0="}'
triggers:
- 'exp{profession=mining;amount=20}'
emerald:
material: EMERALD_ORE
material: vanilla{type=EMERALD_ORE}
drop-table:
items:
- 'vanilla{type=EMERALD} 1 1-9'
vanilla-drops: false
regen:
time: 2000
temp-block: STONE
temp-block: vanilla{type=STONE}
triggers:
- 'exp{profession=mining;amount=32}'
diamond:
# The material you need to mine
material: DIAMOND_ORE
material: vanilla{type=DIAMOND_ORE}
# Refer to drop-tables.yml
# The drop table used by the block.
@ -63,4 +82,4 @@ on-mine:
# When using the temp-block option, make sure you choose
# one temp block and don't use it anywhere else in the
# configuration so that block regens do not affect each other
temp-block: STONE
temp-block: vanilla{type=STONE}

View File

@ -7,3 +7,6 @@ name: Smelting
experience:
base: 20
per-level: 3
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels

View File

@ -8,6 +8,9 @@ experience:
base: 20
per-level: 3
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
exp-sources:
- 'repairitem{}'

View File

@ -8,6 +8,9 @@ experience:
base: 13
per-level: 2.5
# Must match an existing exp curve filename from the 'expcurves' folder
exp-curve: levels
exp-sources:
- 'mineblock{type=OAK_LOG;amount=1-3}'
- 'mineblock{type=SPRUCE_LOG;amount=1-3}'

View File

@ -10,11 +10,13 @@ WOODEN_PICKAXE:
# What the tool can mine.
can-mine:
- COAL_ORE
- vanilla{type=COAL_ORE}
STONE_PICKAXE:
can-mine:
- IRON_ORE
- vanilla{type=IRON_ORE}
# MMOItems custom blocks with ID 1
- mmoitems{id=1}
# The block break permissions the tool inherits.
# e.g a stone pickaxe can mine iron ores PLUS
@ -25,16 +27,18 @@ STONE_PICKAXE:
IRON_PICKAXE:
parent: STONE_PICKAXE
can-mine:
- GOLD_ORE
- vanilla{type=GOLD_ORE}
# Custom skull with diamond ore texture
- skull{value="eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2EzYmI4NWRlYzEzMjlmZTgyOWNjNmNkY2QzNGUxYmQ2MGVlODMyZjU3MjYyOTY1MWYxNGI1ZTE0NTU1ZGJiMSJ9fX0="}
GOLDEN_PICKAXE:
parent: IRON_PICKAXE
can-mine:
- LAPIS_ORE
- vanilla{type=LAPIS_ORE}
DIAMOND_PICKAXE:
parent: GOLDEN_PICKAXE
can-mine:
- DIAMOND_ORE
- EMERALD_ORE
- REDSTONE_ORE
- vanilla{type=DIAMOND_ORE}
- vanilla{type=EMERALD_ORE}
- vanilla{type=REDSTONE_ORE}