mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Added ability to config Hylian Luck drops through treasures.yml
This commit is contained in:
parent
1e7b54ef0d
commit
60041a1253
@ -18,6 +18,7 @@ Version 1.4.00-dev
|
||||
+ Added '/ptp accept' and '/ptp acceptall' commands
|
||||
+ Added timeout on party teleport requests
|
||||
+ Added XP bonus for Archery based on distance from shooter to target
|
||||
+ Added ability to config Hylian Luck drops through treasures.yml
|
||||
= Fixed Spout config files loading / generating when they shouldn't have
|
||||
= Fixed mod config files loading / generating when they shouldn't have
|
||||
= Fixed bug where Green Terra could activate on crops that weren't fully grown.
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class TreasuresConfig extends ConfigLoader {
|
||||
@ -25,6 +26,11 @@ public class TreasuresConfig extends ConfigLoader {
|
||||
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
||||
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
||||
|
||||
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasuresConfig() {
|
||||
@ -131,8 +137,6 @@ public class TreasuresConfig extends ConfigLoader {
|
||||
}
|
||||
|
||||
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
|
||||
|
||||
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
|
||||
@ -141,6 +145,7 @@ public class TreasuresConfig extends ConfigLoader {
|
||||
}
|
||||
else {
|
||||
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
|
||||
eTreasure.setDropsFromDirt();
|
||||
@ -170,18 +175,34 @@ public class TreasuresConfig extends ConfigLoader {
|
||||
eTreasure.setDropsFromSoulSand();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
|
||||
hTreasure.setDropsFromBushes();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
|
||||
hTreasure.setDropsFromFlowers();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
|
||||
hTreasure.setDropsFromPots();
|
||||
}
|
||||
|
||||
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
||||
reason.add("Excavation drops cannot also be fishing drops");
|
||||
}
|
||||
|
||||
if (noErrorsInTreasure(reason)) {
|
||||
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
||||
treasures.put(treasureName, eTreasure);
|
||||
}
|
||||
else if (noErrorsInTreasure(reason) && eTreasure.getDropsFrom() == (byte) 0x0){
|
||||
treasures.put(treasureName, hTreasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
||||
|
||||
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
||||
String treasureKey = nextEntry.getKey();
|
||||
@ -194,6 +215,25 @@ public class TreasuresConfig extends ConfigLoader {
|
||||
|
||||
fishingRewards.add((FishingTreasure) treasure);
|
||||
}
|
||||
else if (treasure instanceof HylianTreasure) {
|
||||
if (!hylianTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
HylianTreasure hTreasure = (HylianTreasure) treasure;
|
||||
|
||||
if (hTreasure.getDropsFromBushes()) {
|
||||
hylianFromBushes.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromFlowers()) {
|
||||
hylianFromFlowers.add(hTreasure);
|
||||
}
|
||||
|
||||
if (hTreasure.getDropsFromPots()) {
|
||||
hylianFromPots.add(hTreasure);
|
||||
}
|
||||
}
|
||||
else if (treasure instanceof ExcavationTreasure) {
|
||||
if (!excavationTreasures.contains(treasureKey)) {
|
||||
continue;
|
||||
|
@ -0,0 +1,76 @@
|
||||
package com.gmail.nossr50.datatypes.treasure;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class HylianTreasure extends Treasure {
|
||||
// bushes | flowers | pots
|
||||
// 00000001 - bushes 1
|
||||
// 00000010 - flowers 2
|
||||
// 00000100 - pots 4
|
||||
private byte dropsFrom = 0x0;
|
||||
|
||||
public HylianTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel) {
|
||||
super(drop, xp, dropChance, dropLevel);
|
||||
}
|
||||
|
||||
// Raw getters and setters
|
||||
public byte getDropsFrom() {
|
||||
return dropsFrom;
|
||||
}
|
||||
|
||||
public void setDropsFrom(byte dropsFrom) {
|
||||
this.dropsFrom = dropsFrom;
|
||||
}
|
||||
|
||||
// Getters
|
||||
public boolean getDropsFromBushes() {
|
||||
return getDropFromMask(1);
|
||||
}
|
||||
|
||||
public boolean getDropsFromFlowers() {
|
||||
return getDropFromMask(2);
|
||||
}
|
||||
|
||||
public boolean getDropsFromPots() {
|
||||
return getDropFromMask(4);
|
||||
}
|
||||
|
||||
private boolean getDropFromMask(int mask) {
|
||||
return ((dropsFrom & mask) > 0) ? true : false;
|
||||
}
|
||||
|
||||
// Setters
|
||||
public void setDropsFromBushes() {
|
||||
setDropFromMask(1);
|
||||
}
|
||||
|
||||
public void setDropsFromFlowers() {
|
||||
setDropFromMask(2);
|
||||
}
|
||||
|
||||
public void setDropsFromPots() {
|
||||
setDropFromMask(4);
|
||||
}
|
||||
|
||||
private void setDropFromMask(int mask) {
|
||||
dropsFrom |= mask;
|
||||
}
|
||||
|
||||
// Un-setters
|
||||
public void unsetDropsFromBushes() {
|
||||
unsetDropFromMask(1);
|
||||
}
|
||||
|
||||
public void unsetDropsFromFlowers() {
|
||||
unsetDropFromMask(2);
|
||||
}
|
||||
|
||||
public void unsetDropsFromPots() {
|
||||
unsetDropFromMask(4);
|
||||
}
|
||||
|
||||
private void unsetDropFromMask(int mask) {
|
||||
dropsFrom &= ~mask;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package com.gmail.nossr50.skills.herbalism;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -10,13 +13,14 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.skills.AbilityType;
|
||||
@ -340,31 +344,13 @@ public class Herbalism {
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyHerbalism(player));
|
||||
|
||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||
Location location = block.getLocation();
|
||||
int dropNumber = Misc.getRandom().nextInt(3);
|
||||
ItemStack item;
|
||||
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
|
||||
|
||||
switch (block.getType()) {
|
||||
case DEAD_BUSH:
|
||||
case LONG_GRASS:
|
||||
case SAPLING:
|
||||
if (dropNumber == 0) {
|
||||
item = new ItemStack(Material.MELON_SEEDS);
|
||||
}
|
||||
else if (dropNumber == 1) {
|
||||
item = new ItemStack(Material.PUMPKIN_SEEDS);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
item = (new MaterialData(Material.INK_SACK, DyeColor.BROWN.getDyeData())).toItemStack(1);
|
||||
}
|
||||
catch (Exception e) {
|
||||
item = (new MaterialData(Material.INK_SACK, (byte) 0x3)).toItemStack(1);
|
||||
}
|
||||
catch (NoSuchMethodError e) {
|
||||
item = (new MaterialData(Material.INK_SACK, (byte) 0x3)).toItemStack(1);
|
||||
}
|
||||
}
|
||||
treasures = TreasuresConfig.getInstance().hylianFromBushes;
|
||||
break;
|
||||
|
||||
case RED_ROSE:
|
||||
@ -374,34 +360,21 @@ public class Herbalism {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dropNumber == 0) {
|
||||
item = new ItemStack(Material.POTATO);
|
||||
}
|
||||
else if (dropNumber == 1) {
|
||||
item = new ItemStack(Material.CARROT);
|
||||
}
|
||||
else {
|
||||
item = new ItemStack(Material.APPLE);
|
||||
}
|
||||
|
||||
treasures = TreasuresConfig.getInstance().hylianFromFlowers;
|
||||
break;
|
||||
|
||||
case FLOWER_POT:
|
||||
if (dropNumber == 0) {
|
||||
item = new ItemStack(Material.EMERALD);
|
||||
}
|
||||
else if (dropNumber == 1) {
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
}
|
||||
else {
|
||||
item = new ItemStack(Material.GOLD_NUGGET);
|
||||
}
|
||||
treasures = TreasuresConfig.getInstance().hylianFromPots;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
int dropNumber = Misc.getRandom().nextInt(treasures.size());
|
||||
ItemStack item = treasures.get(dropNumber + 1).getDrop();
|
||||
Location location = block.getLocation();
|
||||
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
Misc.dropItem(location, item);
|
||||
|
@ -84,7 +84,20 @@ Excavation:
|
||||
- Green_Music
|
||||
- Diamond
|
||||
- Cocoa_Beans
|
||||
|
||||
#
|
||||
# Settings for Hylian Luck
|
||||
###
|
||||
Hylian_Luck:
|
||||
Treasure:
|
||||
- Melon_Seeds
|
||||
- Pumpkin_Seeds
|
||||
- Cocoa
|
||||
- Carrot
|
||||
- Potato
|
||||
- Apples
|
||||
- Emeralds
|
||||
- Diamond_Gem
|
||||
- Gold_Nuggets
|
||||
#
|
||||
# Configuration to define Treasures
|
||||
###
|
||||
@ -863,4 +876,85 @@ Treasures:
|
||||
Drop_Level: 800
|
||||
Max_Level: -1
|
||||
Drops_From:
|
||||
Fishing: true
|
||||
Fishing: true
|
||||
Melon_Seeds:
|
||||
ID: 362
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Bushes: true
|
||||
Pumpkin_Seeds:
|
||||
ID: 361
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Bushes: true
|
||||
Cocoa:
|
||||
ID: 351
|
||||
Data: 3
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Bushes: true
|
||||
Carrot:
|
||||
ID: 391
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Flowers: true
|
||||
Potato:
|
||||
ID: 392
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Flowers: true
|
||||
Apples:
|
||||
ID: 260
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Flowers: true
|
||||
Emeralds:
|
||||
ID: 388
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Pots: true
|
||||
Diamond_Gem:
|
||||
ID: 264
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Pots: true
|
||||
Gold_Nuggets:
|
||||
ID: 371
|
||||
Data: 0
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 100.0
|
||||
Drop_Level: 0
|
||||
Drops_From:
|
||||
Pots: true
|
Loading…
Reference in New Issue
Block a user