mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-24 15:01:50 +01:00
Improved default professions
This commit is contained in:
parent
67cd4e44d1
commit
c9fe2c805c
@ -15,7 +15,7 @@ public class RandomAmount {
|
|||||||
public RandomAmount(String value) {
|
public RandomAmount(String value) {
|
||||||
String[] split = value.split("-");
|
String[] split = value.split("-");
|
||||||
min = Double.parseDouble(split[0]);
|
min = Double.parseDouble(split[0]);
|
||||||
max = split.length > 1 ? Double.parseDouble(split[1]) : 0;
|
max = split.length > 1 ? Double.parseDouble(split[1]) : min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMax() {
|
public double getMax() {
|
||||||
@ -27,10 +27,10 @@ public class RandomAmount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double calculate() {
|
public double calculate() {
|
||||||
return max > 0 ? random.nextDouble() * Math.abs((max - min)) + Math.min(max, min) : min;
|
return min + random.nextDouble() * (max - min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calculateInt() {
|
public int calculateInt() {
|
||||||
return (int) (max > 0 ? (random.nextInt((int) (max - min + 1)) + min) : min);
|
return (int) (min + random.nextInt((int) (max - min + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,9 @@ package net.Indyuce.mmocore.experience.source;
|
|||||||
import io.lumine.mythic.lib.MythicLib;
|
import io.lumine.mythic.lib.MythicLib;
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -19,6 +19,10 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When empty, this applies for all enchants
|
||||||
|
*/
|
||||||
private final List<Enchantment> enchants = new ArrayList<>();
|
private final List<Enchantment> enchants = new ArrayList<>();
|
||||||
|
|
||||||
public EnchantItemExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public EnchantItemExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
@ -43,16 +47,17 @@ public class EnchantItemExperienceSource extends ExperienceSource<Void> {
|
|||||||
PlayerData player = PlayerData.get(event.getEnchanter());
|
PlayerData player = PlayerData.get(event.getEnchanter());
|
||||||
for (EnchantItemExperienceSource source : getSources())
|
for (EnchantItemExperienceSource source : getSources())
|
||||||
if (source.matches(player, null)) {
|
if (source.matches(player, null)) {
|
||||||
Map<Enchantment, Integer> ench = new HashMap<>(event.getEnchantsToAdd());
|
Map<Enchantment, Integer> applicableEnchants = new HashMap<>(event.getEnchantsToAdd());
|
||||||
|
|
||||||
|
// Filter out enchants if required
|
||||||
if (!source.enchants.isEmpty())
|
if (!source.enchants.isEmpty())
|
||||||
ench.keySet().removeIf(enchantment -> !source.enchants.contains(enchantment));
|
applicableEnchants.keySet().removeIf(enchantment -> !source.enchants.contains(enchantment));
|
||||||
|
|
||||||
if (ench.isEmpty())
|
if (applicableEnchants.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double exp = 0;
|
double exp = 0;
|
||||||
for (Entry<Enchantment, Integer> entry : ench.entrySet())
|
for (Entry<Enchantment, Integer> entry : applicableEnchants.entrySet())
|
||||||
exp += MMOCore.plugin.enchantManager.getBaseExperience(entry.getKey()) * entry.getValue();
|
exp += MMOCore.plugin.enchantManager.getBaseExperience(entry.getKey()) * entry.getValue();
|
||||||
getDispenser().giveExperience(player, (int) exp, event.getEnchantBlock().getLocation());
|
getDispenser().giveExperience(player, (int) exp, event.getEnchantBlock().getLocation());
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,13 @@ exp-curve: levels
|
|||||||
# Specifying enchants like that lets you create different
|
# Specifying enchants like that lets you create different
|
||||||
# enchanting professions, like DESTRUCTION for offense enchants
|
# enchanting professions, like DESTRUCTION for offense enchants
|
||||||
# (Smite, Bane of Arth., Sharpness, Power, Fire Aspect, Flame)
|
# (Smite, Bane of Arth., Sharpness, Power, Fire Aspect, Flame)
|
||||||
# and ALTERATION for strategic enchants for e.g
|
# and ALTERATION for strategic enchants for example.
|
||||||
|
#
|
||||||
|
# Use enchantitem{} to have it apply for any enchant.
|
||||||
|
#
|
||||||
|
# Use enchantitem{enchant="sharpness,power"} for multiple enchants
|
||||||
exp-sources:
|
exp-sources:
|
||||||
- 'enchantitem{enchant=sharpness}'
|
- 'enchantitem{}'
|
||||||
|
|
||||||
# When enchanting an item, players earn Enchanting experience.
|
# When enchanting an item, players earn Enchanting experience.
|
||||||
# Experience given by an item is the sum of the EXP given by every extra enchantment.
|
# Experience given by an item is the sum of the EXP given by every extra enchantment.
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Display options
|
# Display options
|
||||||
name: Farming
|
name: Farming
|
||||||
|
|
||||||
@ -12,6 +11,21 @@ experience:
|
|||||||
exp-curve: levels
|
exp-curve: levels
|
||||||
|
|
||||||
exp-sources:
|
exp-sources:
|
||||||
- 'mineblock{type=CARROTS;amount=1-3;crop=true;player-placed:true}'
|
- 'mineblock{type=WHEAT;amount=1-3;crop=true;player-placed=true;silk-touch=false}'
|
||||||
- 'mineblock{type=POTATOES;amount=1-3;crop=true;player-placed:true}'
|
- 'mineblock{type=BEETROOTS;amount=1-3;crop=true;player-placed=true;silk-touch=false}'
|
||||||
- 'mineblock{type=WHEAT;amount=1-3;crop=true;player-placed:true}'
|
- 'mineblock{type=CARROTS;amount=1-3;crop=true;player-placed=true;silk-touch=false}'
|
||||||
|
- 'mineblock{type=POTATOES;amount=1-3;crop=true;player-placed=true;silk-touch=false}'
|
||||||
|
- 'mineblock{type=MELON;amount=1-3}'
|
||||||
|
- 'mineblock{type=PUMPKIN;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=BAMBOO;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=COCOA;amount=1-3;crop=true;player-placed=true;silk-touch=false}'
|
||||||
|
- 'mineblock{type=SUGAR_CANE;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=CACTUS;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=RED_MUSHROOM;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=BROWN_MUSHROOM;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=KELP;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=SEA_PICKLE;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=NETHER_WART;amount=1-3;crop=true;silk-touch=false}'
|
||||||
|
- 'mineblock{type=CHORUS_FLOWER;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=CRIMSON_FUNGUS;amount=1-3;silk-touch=false}'
|
||||||
|
- 'mineblock{type=WARPED_FUNGUS;amount=1-3;silk-touch=false}'
|
||||||
|
@ -37,6 +37,64 @@ on-mine:
|
|||||||
triggers:
|
triggers:
|
||||||
- 'exp{profession=mining;amount=20}'
|
- 'exp{profession=mining;amount=20}'
|
||||||
|
|
||||||
|
# Gold ore
|
||||||
|
gold:
|
||||||
|
material: vanilla{type=GOLD_ORE}
|
||||||
|
drop-table:
|
||||||
|
items:
|
||||||
|
- 'vanilla{type=GOLD_ORE}'
|
||||||
|
options:
|
||||||
|
vanilla-drops: false
|
||||||
|
regen:
|
||||||
|
time: 2000
|
||||||
|
temp-block: vanilla{type=STONE}
|
||||||
|
triggers:
|
||||||
|
- 'exp{profession=mining;amount=5}'
|
||||||
|
|
||||||
|
# Iron ore
|
||||||
|
iron:
|
||||||
|
material: vanilla{type=IRON_ORE}
|
||||||
|
drop-table:
|
||||||
|
items:
|
||||||
|
- 'vanilla{type=IRON_ORE}'
|
||||||
|
options:
|
||||||
|
vanilla-drops: false
|
||||||
|
regen:
|
||||||
|
time: 2000
|
||||||
|
temp-block: vanilla{type=STONE}
|
||||||
|
triggers:
|
||||||
|
- 'exp{profession=mining;amount=5}'
|
||||||
|
|
||||||
|
# Lapis ore
|
||||||
|
lapis:
|
||||||
|
material: vanilla{type=LAPIS_ORE}
|
||||||
|
drop-table:
|
||||||
|
items:
|
||||||
|
- 'vanilla{type=LAPIS_LAZULI} 1 4-20'
|
||||||
|
options:
|
||||||
|
vanilla-drops: false
|
||||||
|
regen:
|
||||||
|
time: 2000
|
||||||
|
temp-block: vanilla{type=STONE}
|
||||||
|
triggers:
|
||||||
|
- 'exp{profession=mining;amount=13}'
|
||||||
|
|
||||||
|
# Redstone ore
|
||||||
|
redstone:
|
||||||
|
material: vanilla{type=REDSTONE_ORE}
|
||||||
|
drop-table:
|
||||||
|
items:
|
||||||
|
- 'vanilla{type=REDSTONE} 1 4-20'
|
||||||
|
- 'vanilla{type=REDSTONE_TORCH} .1 1-3'
|
||||||
|
options:
|
||||||
|
vanilla-drops: false
|
||||||
|
regen:
|
||||||
|
time: 2000
|
||||||
|
temp-block: vanilla{type=STONE}
|
||||||
|
triggers:
|
||||||
|
- 'exp{profession=mining;amount=10}'
|
||||||
|
|
||||||
|
# Emerald ore
|
||||||
emerald:
|
emerald:
|
||||||
material: vanilla{type=EMERALD_ORE}
|
material: vanilla{type=EMERALD_ORE}
|
||||||
drop-table:
|
drop-table:
|
||||||
@ -50,6 +108,7 @@ on-mine:
|
|||||||
triggers:
|
triggers:
|
||||||
- 'exp{profession=mining;amount=32}'
|
- 'exp{profession=mining;amount=32}'
|
||||||
|
|
||||||
|
# Diamond ore
|
||||||
diamond:
|
diamond:
|
||||||
# The material you need to mine
|
# The material you need to mine
|
||||||
material: vanilla{type=DIAMOND_ORE}
|
material: vanilla{type=DIAMOND_ORE}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# Display options
|
# Display options
|
||||||
name: Smelting
|
name: Smelting
|
||||||
|
|
||||||
@ -10,3 +9,14 @@ experience:
|
|||||||
|
|
||||||
# Must match an existing exp curve filename from the 'expcurves' folder
|
# Must match an existing exp curve filename from the 'expcurves' folder
|
||||||
exp-curve: levels
|
exp-curve: levels
|
||||||
|
|
||||||
|
exp-sources:
|
||||||
|
- 'craftitem{type=BLAST_FURNACE;amount=1}'
|
||||||
|
- 'craftitem{type=SMOKER;amount=1}'
|
||||||
|
- 'smeltitem{type=COOKED_BEEF;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_CHICKEN;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_COD;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_MUTTON;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_PORKCHOP;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_RABBIT;amount=1-3}'
|
||||||
|
- 'smeltitem{type=COOKED_SALMON;amount=1-3}'
|
||||||
|
Loading…
Reference in New Issue
Block a user