diff --git a/src/main/java/net/Indyuce/mmocore/MMOCore.java b/src/main/java/net/Indyuce/mmocore/MMOCore.java index 04096c71..622b56a8 100644 --- a/src/main/java/net/Indyuce/mmocore/MMOCore.java +++ b/src/main/java/net/Indyuce/mmocore/MMOCore.java @@ -39,7 +39,7 @@ import net.Indyuce.mmocore.manager.profession.*; import net.Indyuce.mmocore.manager.social.BoosterManager; import net.Indyuce.mmocore.manager.social.PartyManager; import net.Indyuce.mmocore.manager.social.RequestManager; -import net.Indyuce.mmocore.party.PartyMemberTargetRestriction; +import net.Indyuce.mmocore.party.MMOCoreTargetRestriction; import net.Indyuce.mmocore.party.PartyModule; import net.Indyuce.mmocore.party.PartyModuleType; import net.Indyuce.mmocore.party.provided.MMOCorePartyModule; @@ -116,7 +116,7 @@ public class MMOCore extends LuminePlugin { } // Register MMOCore-specific objects - MythicLib.plugin.getEntities().registerRestriction(new PartyMemberTargetRestriction()); + MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction()); MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject)); // Register extra objective, drop items... diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/MineBlockExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/MineBlockExperienceSource.java index 4eef178f..fcc457a4 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/MineBlockExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/MineBlockExperienceSource.java @@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; public class MineBlockExperienceSource extends SpecificExperienceSource { - public final Material material; + private final Material material; private final boolean silkTouch; private final boolean crop; diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/MoveExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/MoveExperienceSource.java index 6af6bf03..66ae8959 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/MoveExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/MoveExperienceSource.java @@ -1,18 +1,14 @@ package net.Indyuce.mmocore.experience.source; -import com.mojang.datafixers.types.Func; import io.lumine.mythic.lib.api.MMOLineConfig; -import io.lumine.mythic.lib.damage.DamageType; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerMoveEvent; -import org.xml.sax.SAXParseException; import java.util.Arrays; import java.util.Objects; @@ -20,9 +16,7 @@ import java.util.function.Function; import java.util.stream.Collectors; public class MoveExperienceSource extends SpecificExperienceSource { - MovingType type; - - + private final MovingType type; public MoveExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) { super(dispenser, config); @@ -42,18 +36,18 @@ public class MoveExperienceSource extends SpecificExperienceSource { return new ExperienceSourceManager() { @EventHandler public void onMove(PlayerMoveEvent e) { - double deltax=e.getTo().getBlockX()-e.getFrom().getBlockX(); - double deltay=e.getTo().getBlockY()-e.getFrom().getBlockY(); - double deltaz=e.getTo().getBlockZ()-e.getFrom().getBlockZ(); - if(deltax!=0&&deltay!=0&&deltaz!=0) { - double delta=Math.sqrt(deltax*deltax+deltay*deltay+deltaz*deltaz); - if(e.getPlayer().hasMetadata("NPC")) + double deltax = e.getTo().getBlockX() - e.getFrom().getBlockX(); + double deltay = e.getTo().getBlockY() - e.getFrom().getBlockY(); + double deltaz = e.getTo().getBlockZ() - e.getFrom().getBlockZ(); + if (deltax != 0 && deltay != 0 && deltaz != 0) { + double delta = Math.sqrt(deltax * deltax + deltay * deltay + deltaz * deltaz); + if (e.getPlayer().hasMetadata("NPC")) return; - Player player=e.getPlayer(); - PlayerData playerData =PlayerData.get(player); - for(MoveExperienceSource source:getSources()) { - if(source.matchesParameter(playerData,null)) { - giveExperience(playerData,delta,null); + Player player = e.getPlayer(); + PlayerData playerData = PlayerData.get(player); + for (MoveExperienceSource source : getSources()) { + if (source.matchesParameter(playerData, null)) { + giveExperience(playerData, delta, null); } } } @@ -63,13 +57,13 @@ public class MoveExperienceSource extends SpecificExperienceSource { @Override public boolean matchesParameter(PlayerData player, Object obj) { - return type==null||type.matches(player.getPlayer()); + return type == null || type.matches(player.getPlayer()); } public enum MovingType { SNEAK(Player::isSneaking), - FLY((p)->p.isFlying()||p.isGliding()), - SWIM((p)->p.getLocation().getBlock().isLiquid()), + FLY((p) -> p.isFlying() || p.isGliding()), + SWIM((p) -> p.getLocation().getBlock().isLiquid()), SPRINT(Player::isSprinting), WALK((p) -> !p.isSneaking() && !p.isSprinting() && !p.isFlying() && !p.getLocation().getBlock().isLiquid()); @@ -80,7 +74,7 @@ public class MoveExperienceSource extends SpecificExperienceSource { } public boolean matches(Player player) { - return !player.isInsideVehicle()&&matching.apply(player); + return !player.isInsideVehicle() && matching.apply(player); } } diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/PlayExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/PlayExperienceSource.java index d95e6a7b..b2f49d62 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/PlayExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/PlayExperienceSource.java @@ -6,12 +6,13 @@ import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; -import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.scheduler.BukkitRunnable; +import java.util.Objects; + public class PlayExperienceSource extends SpecificExperienceSource { private final World world; @@ -25,18 +26,9 @@ public class PlayExperienceSource extends SpecificExperienceSource { */ public PlayExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) { super(dispenser, config); - if (!config.contains("in-combat")) - inCombat = false; - else { - inCombat = config.getBoolean("in-combat"); - } - if (!config.contains("world")) - world = null; - else { - String name = config.getString("world"); - Validate.notNull(world = Bukkit.getWorld(name), "Could not find world " + config.getString("world")); - } + inCombat = config.getBoolean("in-combat", false); + world = config.contains("world") ? Objects.requireNonNull(Bukkit.getWorld(config.getString("world")), "Could not find world " + config.getString("world")) : null; if (!config.contains("x1") || !config.contains("x2")) { x1 = Double.NEGATIVE_INFINITY; x2 = Double.POSITIVE_INFINITY; diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/ProjectileExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/ProjectileExperienceSource.java index 49647b70..c3ac3578 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/ProjectileExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/ProjectileExperienceSource.java @@ -1,18 +1,17 @@ package net.Indyuce.mmocore.experience.source; -import de.schlichtherle.key.passwd.swing.BasicUnknownKeyFeedback; -import io.lumine.mythic.core.skills.mechanics.ShootMechanic; import io.lumine.mythic.lib.api.MMOLineConfig; -import me.glaremasters.guilds.utils.BackupUtils; import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser; import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource; import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.entity.*; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Trident; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -21,13 +20,10 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; -import java.util.Locale; import java.util.function.Function; import java.util.stream.Collectors; public class ProjectileExperienceSource extends SpecificExperienceSource { - private final ProjectileType projectileType; public ProjectileExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) { @@ -59,7 +55,7 @@ public class ProjectileExperienceSource extends SpecificExperienceSource { private final PlayerResource resource; - /** * Gives experience when the player uses a specific resoure. If no resource is precised it will trigger for * mana, stamina and stellium. The amount specified si the xp given per resource consummed. diff --git a/src/main/java/net/Indyuce/mmocore/experience/source/TameExperienceSource.java b/src/main/java/net/Indyuce/mmocore/experience/source/TameExperienceSource.java index af7a22a4..83a455c6 100644 --- a/src/main/java/net/Indyuce/mmocore/experience/source/TameExperienceSource.java +++ b/src/main/java/net/Indyuce/mmocore/experience/source/TameExperienceSource.java @@ -13,8 +13,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageByEntityEvent; public class TameExperienceSource extends SpecificExperienceSource { - - public TameExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) { super(dispenser, config); } @@ -22,6 +20,7 @@ public class TameExperienceSource extends SpecificExperienceSource { @Override public ExperienceSourceManager newManager() { return new ExperienceSourceManager() { + @EventHandler public void onWolfHit(EntityDamageByEntityEvent e) { if(e.getDamager() instanceof Wolf) { diff --git a/src/main/java/net/Indyuce/mmocore/party/PartyMemberTargetRestriction.java b/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java similarity index 88% rename from src/main/java/net/Indyuce/mmocore/party/PartyMemberTargetRestriction.java rename to src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java index d2a6989f..e3603461 100644 --- a/src/main/java/net/Indyuce/mmocore/party/PartyMemberTargetRestriction.java +++ b/src/main/java/net/Indyuce/mmocore/party/MMOCoreTargetRestriction.java @@ -7,7 +7,7 @@ import net.Indyuce.mmocore.api.player.PlayerData; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -public class PartyMemberTargetRestriction implements TargetRestriction { +public class MMOCoreTargetRestriction implements TargetRestriction { @Override public boolean canTarget(Player player, LivingEntity livingEntity, InteractionType interactionType) { @@ -15,6 +15,7 @@ public class PartyMemberTargetRestriction implements TargetRestriction { return true; AbstractParty party = MMOCore.plugin.partyModule.getParty(PlayerData.get(player)); + // TODO check for guild return party == null || !party.hasMember((Player) livingEntity); } } diff --git a/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java b/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java index f6b0370a..8a031652 100644 --- a/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java +++ b/src/main/java/net/Indyuce/mmocore/party/PartyModuleType.java @@ -1,13 +1,16 @@ package net.Indyuce.mmocore.party; -import net.Indyuce.mmocore.party.compat.*; +import net.Indyuce.mmocore.party.compat.DungeonsXLPartyModule; +import net.Indyuce.mmocore.party.compat.McMMOPartyModule; +import net.Indyuce.mmocore.party.compat.PAFPartyModule; +import net.Indyuce.mmocore.party.compat.PartiesPartyModule; import net.Indyuce.mmocore.party.provided.MMOCorePartyModule; import org.bukkit.Bukkit; import javax.inject.Provider; public enum PartyModuleType { - DUNGEONS("Dungeons", DungeonsPartyModule::new), + // DUNGEONS("Dungeons", DungeonsPartyModule::new), DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new), MCMMO("mcMMO", McMMOPartyModule::new), MMOCORE("MMOCore", MMOCorePartyModule::new), diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 0ccdbde5..db45266d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -55,7 +55,8 @@ protect-custom-mine: false # - mmocore # - dungeonsxl # - parties -# - parties_and_friends +# - party_and_friends +# - mcmmo party-plugin: mmocore ## Edit the plugin handling parties here.