forked from Upstream/mmocore
Cleanup
This commit is contained in:
parent
560a2def41
commit
9a08c142fb
@ -39,7 +39,7 @@ import net.Indyuce.mmocore.manager.profession.*;
|
|||||||
import net.Indyuce.mmocore.manager.social.BoosterManager;
|
import net.Indyuce.mmocore.manager.social.BoosterManager;
|
||||||
import net.Indyuce.mmocore.manager.social.PartyManager;
|
import net.Indyuce.mmocore.manager.social.PartyManager;
|
||||||
import net.Indyuce.mmocore.manager.social.RequestManager;
|
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.PartyModule;
|
||||||
import net.Indyuce.mmocore.party.PartyModuleType;
|
import net.Indyuce.mmocore.party.PartyModuleType;
|
||||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||||
@ -116,7 +116,7 @@ public class MMOCore extends LuminePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register MMOCore-specific objects
|
// 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));
|
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
||||||
|
|
||||||
// Register extra objective, drop items...
|
// Register extra objective, drop items...
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class MineBlockExperienceSource extends SpecificExperienceSource<Material> {
|
public class MineBlockExperienceSource extends SpecificExperienceSource<Material> {
|
||||||
public final Material material;
|
private final Material material;
|
||||||
private final boolean silkTouch;
|
private final boolean silkTouch;
|
||||||
private final boolean crop;
|
private final boolean crop;
|
||||||
|
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
package net.Indyuce.mmocore.experience.source;
|
package net.Indyuce.mmocore.experience.source;
|
||||||
|
|
||||||
import com.mojang.datafixers.types.Func;
|
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
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.api.player.PlayerData;
|
||||||
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 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;
|
||||||
import org.xml.sax.SAXParseException;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -20,9 +16,7 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class MoveExperienceSource extends SpecificExperienceSource {
|
public class MoveExperienceSource extends SpecificExperienceSource {
|
||||||
MovingType type;
|
private final MovingType type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MoveExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public MoveExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser, config);
|
super(dispenser, config);
|
||||||
@ -42,18 +36,18 @@ public class MoveExperienceSource extends SpecificExperienceSource {
|
|||||||
return new ExperienceSourceManager<MoveExperienceSource>() {
|
return new ExperienceSourceManager<MoveExperienceSource>() {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onMove(PlayerMoveEvent e) {
|
public void onMove(PlayerMoveEvent e) {
|
||||||
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;
|
||||||
Player player=e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
PlayerData playerData =PlayerData.get(player);
|
PlayerData playerData = PlayerData.get(player);
|
||||||
for(MoveExperienceSource source:getSources()) {
|
for (MoveExperienceSource source : getSources()) {
|
||||||
if(source.matchesParameter(playerData,null)) {
|
if (source.matchesParameter(playerData, null)) {
|
||||||
giveExperience(playerData,delta,null);
|
giveExperience(playerData, delta, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,13 +57,13 @@ public class MoveExperienceSource extends SpecificExperienceSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesParameter(PlayerData player, Object obj) {
|
public boolean matchesParameter(PlayerData player, Object obj) {
|
||||||
return type==null||type.matches(player.getPlayer());
|
return type == null || type.matches(player.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum MovingType {
|
public enum MovingType {
|
||||||
SNEAK(Player::isSneaking),
|
SNEAK(Player::isSneaking),
|
||||||
FLY((p)->p.isFlying()||p.isGliding()),
|
FLY((p) -> p.isFlying() || p.isGliding()),
|
||||||
SWIM((p)->p.getLocation().getBlock().isLiquid()),
|
SWIM((p) -> p.getLocation().getBlock().isLiquid()),
|
||||||
SPRINT(Player::isSprinting),
|
SPRINT(Player::isSprinting),
|
||||||
WALK((p) -> !p.isSneaking() && !p.isSprinting() && !p.isFlying() && !p.getLocation().getBlock().isLiquid());
|
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) {
|
public boolean matches(Player player) {
|
||||||
return !player.isInsideVehicle()&&matching.apply(player);
|
return !player.isInsideVehicle() && matching.apply(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,13 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
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 org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class PlayExperienceSource extends SpecificExperienceSource {
|
public class PlayExperienceSource extends SpecificExperienceSource {
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
@ -25,18 +26,9 @@ public class PlayExperienceSource extends SpecificExperienceSource {
|
|||||||
*/
|
*/
|
||||||
public PlayExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public PlayExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser, config);
|
super(dispenser, config);
|
||||||
if (!config.contains("in-combat"))
|
|
||||||
inCombat = false;
|
|
||||||
else {
|
|
||||||
inCombat = config.getBoolean("in-combat");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.contains("world"))
|
inCombat = config.getBoolean("in-combat", false);
|
||||||
world = null;
|
world = config.contains("world") ? Objects.requireNonNull(Bukkit.getWorld(config.getString("world")), "Could not find world " + config.getString("world")) : null;
|
||||||
else {
|
|
||||||
String name = config.getString("world");
|
|
||||||
Validate.notNull(world = Bukkit.getWorld(name), "Could not find world " + config.getString("world"));
|
|
||||||
}
|
|
||||||
if (!config.contains("x1") || !config.contains("x2")) {
|
if (!config.contains("x1") || !config.contains("x2")) {
|
||||||
x1 = Double.NEGATIVE_INFINITY;
|
x1 = Double.NEGATIVE_INFINITY;
|
||||||
x2 = Double.POSITIVE_INFINITY;
|
x2 = Double.POSITIVE_INFINITY;
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package net.Indyuce.mmocore.experience.source;
|
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 io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
import me.glaremasters.guilds.utils.BackupUtils;
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
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 org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
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.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
@ -21,13 +20,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ProjectileExperienceSource extends SpecificExperienceSource<Projectile> {
|
public class ProjectileExperienceSource extends SpecificExperienceSource<Projectile> {
|
||||||
|
|
||||||
private final ProjectileType projectileType;
|
private final ProjectileType projectileType;
|
||||||
|
|
||||||
public ProjectileExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public ProjectileExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
@ -59,7 +55,7 @@ public class ProjectileExperienceSource extends SpecificExperienceSource<Project
|
|||||||
|
|
||||||
if (e.getEntity() instanceof Projectile) {
|
if (e.getEntity() instanceof Projectile) {
|
||||||
Projectile projectile = (Projectile) e.getEntity();
|
Projectile projectile = (Projectile) e.getEntity();
|
||||||
if(!projectiles.containsKey(projectile))
|
if (!projectiles.containsKey(projectile))
|
||||||
return;
|
return;
|
||||||
if (projectile.getShooter() instanceof Player && !((Player) projectile.getShooter()).hasMetadata("NPC")) {
|
if (projectile.getShooter() instanceof Player && !((Player) projectile.getShooter()).hasMetadata("NPC")) {
|
||||||
Player player = (Player) projectile.getShooter();
|
Player player = (Player) projectile.getShooter();
|
||||||
|
@ -17,7 +17,6 @@ import java.util.stream.Collectors;
|
|||||||
public class ResourceExperienceSource extends SpecificExperienceSource<PlayerResource> {
|
public class ResourceExperienceSource extends SpecificExperienceSource<PlayerResource> {
|
||||||
private final PlayerResource resource;
|
private final PlayerResource resource;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives experience when the player uses a specific resoure. If no resource is precised it will trigger for
|
* 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.
|
* mana, stamina and stellium. The amount specified si the xp given per resource consummed.
|
||||||
|
@ -13,8 +13,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
public class TameExperienceSource extends SpecificExperienceSource {
|
public class TameExperienceSource extends SpecificExperienceSource {
|
||||||
|
|
||||||
|
|
||||||
public TameExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
public TameExperienceSource(ExperienceDispenser dispenser, MMOLineConfig config) {
|
||||||
super(dispenser, config);
|
super(dispenser, config);
|
||||||
}
|
}
|
||||||
@ -22,6 +20,7 @@ public class TameExperienceSource extends SpecificExperienceSource {
|
|||||||
@Override
|
@Override
|
||||||
public ExperienceSourceManager<TameExperienceSource> newManager() {
|
public ExperienceSourceManager<TameExperienceSource> newManager() {
|
||||||
return new ExperienceSourceManager<TameExperienceSource>() {
|
return new ExperienceSourceManager<TameExperienceSource>() {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWolfHit(EntityDamageByEntityEvent e) {
|
public void onWolfHit(EntityDamageByEntityEvent e) {
|
||||||
if(e.getDamager() instanceof Wolf) {
|
if(e.getDamager() instanceof Wolf) {
|
||||||
|
@ -7,7 +7,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PartyMemberTargetRestriction implements TargetRestriction {
|
public class MMOCoreTargetRestriction implements TargetRestriction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(Player player, LivingEntity livingEntity, InteractionType interactionType) {
|
public boolean canTarget(Player player, LivingEntity livingEntity, InteractionType interactionType) {
|
||||||
@ -15,6 +15,7 @@ public class PartyMemberTargetRestriction implements TargetRestriction {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
AbstractParty party = MMOCore.plugin.partyModule.getParty(PlayerData.get(player));
|
AbstractParty party = MMOCore.plugin.partyModule.getParty(PlayerData.get(player));
|
||||||
|
// TODO check for guild
|
||||||
return party == null || !party.hasMember((Player) livingEntity);
|
return party == null || !party.hasMember((Player) livingEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,16 @@
|
|||||||
package net.Indyuce.mmocore.party;
|
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 net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import javax.inject.Provider;
|
import javax.inject.Provider;
|
||||||
|
|
||||||
public enum PartyModuleType {
|
public enum PartyModuleType {
|
||||||
DUNGEONS("Dungeons", DungeonsPartyModule::new),
|
// DUNGEONS("Dungeons", DungeonsPartyModule::new),
|
||||||
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
|
DUNGEONSXL("DungeonsXL", DungeonsXLPartyModule::new),
|
||||||
MCMMO("mcMMO", McMMOPartyModule::new),
|
MCMMO("mcMMO", McMMOPartyModule::new),
|
||||||
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
MMOCORE("MMOCore", MMOCorePartyModule::new),
|
||||||
|
@ -55,7 +55,8 @@ protect-custom-mine: false
|
|||||||
# - mmocore
|
# - mmocore
|
||||||
# - dungeonsxl
|
# - dungeonsxl
|
||||||
# - parties
|
# - parties
|
||||||
# - parties_and_friends
|
# - party_and_friends
|
||||||
|
# - mcmmo
|
||||||
party-plugin: mmocore
|
party-plugin: mmocore
|
||||||
|
|
||||||
## Edit the plugin handling parties here.
|
## Edit the plugin handling parties here.
|
||||||
|
Loading…
Reference in New Issue
Block a user