mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
Debug Experience Sources
This commit is contained in:
parent
2e5cb2b725
commit
2d05bd770b
@ -124,6 +124,10 @@ public class DefaultMMOLoader extends MMOLoader {
|
|||||||
if (config.getKey().equals("climb"))
|
if (config.getKey().equals("climb"))
|
||||||
return new ClimbExperienceSource(dispenser, config);
|
return new ClimbExperienceSource(dispenser, config);
|
||||||
|
|
||||||
|
if (config.getKey().equals("eat")) {
|
||||||
|
return new EatExperienceSource(dispenser, config);
|
||||||
|
}
|
||||||
|
|
||||||
if (config.getKey().equals("damagedealt"))
|
if (config.getKey().equals("damagedealt"))
|
||||||
return new DamageDealtExperienceSource(dispenser, config);
|
return new DamageDealtExperienceSource(dispenser, config);
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
public void refreshVanillaExp() {
|
public void refreshVanillaExp() {
|
||||||
if (!isOnline() || !MMOCore.plugin.configManager.overrideVanillaExp)
|
if (!isOnline() || !MMOCore.plugin.configManager.overrideVanillaExp)
|
||||||
return;
|
return;
|
||||||
|
getPlayer().sendExperienceChange(0.01f);
|
||||||
getPlayer().setLevel(getLevel());
|
getPlayer().setLevel(getLevel());
|
||||||
getPlayer().setExp(Math.max(0, Math.min(1, (float) experience / (float) getLevelUpExperience())));
|
getPlayer().setExp(Math.max(0, Math.min(1, (float) experience / (float) getLevelUpExperience())));
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import net.Indyuce.mmocore.player.stats.StatInfo;
|
|||||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
@ -4,15 +4,18 @@ import io.lumine.mythic.lib.api.MMOLineConfig;
|
|||||||
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
||||||
import io.lumine.mythic.lib.damage.DamagePacket;
|
import io.lumine.mythic.lib.damage.DamagePacket;
|
||||||
import io.lumine.mythic.lib.damage.DamageType;
|
import io.lumine.mythic.lib.damage.DamageType;
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DamageDealtExperienceSource extends SpecificExperienceSource<DamageType> {
|
public class DamageDealtExperienceSource extends SpecificExperienceSource<DamageType> {
|
||||||
@ -43,6 +46,7 @@ public class DamageDealtExperienceSource extends SpecificExperienceSource<Damage
|
|||||||
return new ExperienceSourceManager<DamageDealtExperienceSource>() {
|
return new ExperienceSourceManager<DamageDealtExperienceSource>() {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDamageDealt(PlayerAttackEvent e) {
|
public void onDamageDealt(PlayerAttackEvent e) {
|
||||||
|
|
||||||
PlayerData playerData = PlayerData.get(e.getPlayer());
|
PlayerData playerData = PlayerData.get(e.getPlayer());
|
||||||
for (DamageDealtExperienceSource source : getSources()) {
|
for (DamageDealtExperienceSource source : getSources()) {
|
||||||
double value = 0;
|
double value = 0;
|
||||||
@ -62,10 +66,13 @@ public class DamageDealtExperienceSource extends SpecificExperienceSource<Damage
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesParameter(PlayerData player, DamageType damageType) {
|
public boolean matchesParameter(PlayerData player, DamageType damageType) {
|
||||||
if (type == null)
|
if (type == null) {
|
||||||
return true;
|
return true;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
return type.equals(damageType);
|
return type.equals(damageType);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class EatExperienceSource extends SpecificExperienceSource<ItemStack> {
|
public class EatExperienceSource extends SpecificExperienceSource<ItemStack> {
|
||||||
@ -36,13 +37,13 @@ public class EatExperienceSource extends SpecificExperienceSource<ItemStack> {
|
|||||||
return new ExperienceSourceManager<EatExperienceSource>() {
|
return new ExperienceSourceManager<EatExperienceSource>() {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void a(FoodLevelChangeEvent e) {
|
public void a(PlayerItemConsumeEvent e) {
|
||||||
if (!(e.getEntity() instanceof Player) || e.getEntity().hasMetadata("NPC"))
|
if(!e.getPlayer().hasMetadata("NPC")) {
|
||||||
return;
|
PlayerData playerData = PlayerData.get(e.getPlayer());
|
||||||
PlayerData playerData = PlayerData.get((OfflinePlayer) e.getEntity());
|
for (EatExperienceSource source : getSources()) {
|
||||||
for (EatExperienceSource source : getSources()) {
|
if (source.matchesParameter(playerData, e.getItem()))
|
||||||
if (source.matchesParameter(playerData, e.getItem()))
|
source.giveExperience(playerData, 1, null);
|
||||||
source.giveExperience(playerData, e.getFoodLevel(), null);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
|||||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -39,7 +40,8 @@ public class MineBlockExperienceSource extends SpecificExperienceSource<Material
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExperienceSourceManager<MineBlockExperienceSource> newManager() {
|
public ExperienceSourceManager<MineBlockExperienceSource> newManager() {
|
||||||
return new ExperienceSourceManager<MineBlockExperienceSource>() {
|
return
|
||||||
|
new ExperienceSourceManager<MineBlockExperienceSource>() {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void a(BlockBreakEvent event) {
|
public void a(BlockBreakEvent event) {
|
||||||
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
|
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
|
||||||
@ -63,11 +65,13 @@ public class MineBlockExperienceSource extends SpecificExperienceSource<Material
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasSilkTouch(ItemStack item) {
|
private boolean hasSilkTouch(ItemStack item) {
|
||||||
|
|
||||||
return item != null && item.hasItemMeta() && item.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
|
return item != null && item.hasItemMeta() && item.getItemMeta().hasEnchant(Enchantment.SILK_TOUCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesParameter(PlayerData player, Material obj) {
|
public boolean matchesParameter(PlayerData player, Material obj) {
|
||||||
|
|
||||||
return material == obj;
|
return material == obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
|||||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
@ -39,7 +40,8 @@ public class MoveExperienceSource extends SpecificExperienceSource {
|
|||||||
double deltax = e.getTo().getBlockX() - e.getFrom().getBlockX();
|
double deltax = e.getTo().getBlockX() - e.getFrom().getBlockX();
|
||||||
double deltay = e.getTo().getBlockY() - e.getFrom().getBlockY();
|
double deltay = e.getTo().getBlockY() - e.getFrom().getBlockY();
|
||||||
double deltaz = e.getTo().getBlockZ() - e.getFrom().getBlockZ();
|
double deltaz = e.getTo().getBlockZ() - e.getFrom().getBlockZ();
|
||||||
if (deltax != 0 && deltay != 0 && deltaz != 0) {
|
if (deltax != 0 || deltay != 0 || deltaz != 0) {
|
||||||
|
|
||||||
double delta = Math.sqrt(deltax * deltax + deltay * deltay + deltaz * deltaz);
|
double delta = Math.sqrt(deltax * deltax + deltay * deltay + deltaz * deltaz);
|
||||||
if (e.getPlayer().hasMetadata("NPC"))
|
if (e.getPlayer().hasMetadata("NPC"))
|
||||||
return;
|
return;
|
||||||
|
@ -126,7 +126,6 @@ public class PlayerStats extends EditableInventory {
|
|||||||
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
||||||
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
||||||
String replaced;
|
String replaced;
|
||||||
|
|
||||||
if (holder.endsWith("_base")) {
|
if (holder.endsWith("_base")) {
|
||||||
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
StatInfo info = StatInfo.valueOf(UtilityMethods.enumName(holder.substring(0, holder.length() - 5)));
|
||||||
replaced = info.format(stats.getBase(info.name));
|
replaced = info.format(stats.getBase(info.name));
|
||||||
|
Loading…
Reference in New Issue
Block a user