This commit is contained in:
Indyuce 2022-06-04 12:10:01 +02:00
parent 560a2def41
commit 9a08c142fb
10 changed files with 38 additions and 53 deletions

View File

@ -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...

View File

@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class MineBlockExperienceSource extends SpecificExperienceSource<Material> {
public final Material material;
private final Material material;
private final boolean silkTouch;
private final boolean crop;

View File

@ -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<MoveExperienceSource>() {
@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);
}
}

View File

@ -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;

View File

@ -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<Projectile> {
private final ProjectileType projectileType;
public ProjectileExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
@ -59,7 +55,7 @@ public class ProjectileExperienceSource extends SpecificExperienceSource<Project
if (e.getEntity() instanceof Projectile) {
Projectile projectile = (Projectile) e.getEntity();
if(!projectiles.containsKey(projectile))
if (!projectiles.containsKey(projectile))
return;
if (projectile.getShooter() instanceof Player && !((Player) projectile.getShooter()).hasMetadata("NPC")) {
Player player = (Player) projectile.getShooter();

View File

@ -17,7 +17,6 @@ import java.util.stream.Collectors;
public class ResourceExperienceSource extends SpecificExperienceSource<PlayerResource> {
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.

View File

@ -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<TameExperienceSource> newManager() {
return new ExperienceSourceManager<TameExperienceSource>() {
@EventHandler
public void onWolfHit(EntityDamageByEntityEvent e) {
if(e.getDamager() instanceof Wolf) {

View File

@ -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);
}
}

View File

@ -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),

View File

@ -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.