mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-12-25 05:07:46 +01:00
Fixed pom+script refactor
This commit is contained in:
parent
adc4f03601
commit
4935406a38
6
pom.xml
6
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<version>1.9.5-SNAPSHOT</version>
|
||||
<name>MMOCore</name>
|
||||
<description>Offer your players a brand new RPG experience!!</description>
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>phoenix</id>
|
||||
<url>http://la-grange-evasion.pro.dns-orange.fr:8081/</url>
|
||||
<url>https://la-grange-evasion.pro.dns-orange.fr/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
@ -161,7 +161,7 @@
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>MythicLib-dist</artifactId>
|
||||
<version>1.3.4</version>
|
||||
<version>1.3.4-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -5,6 +5,10 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
||||
/**
|
||||
* @deprecated Use Bukkit event instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class MMOCommandEvent extends PlayerDataEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
@ -902,13 +902,16 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mmoData.hashCode();
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PlayerData that = (PlayerData) o;
|
||||
return getUniqueId().equals(that.mmoData.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof PlayerData && ((PlayerData) obj).getUniqueId().equals(getUniqueId());
|
||||
public int hashCode() {
|
||||
return mmoData.hashCode();
|
||||
}
|
||||
|
||||
public static PlayerData get(OfflinePlayer player) {
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.Indyuce.mmocore.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.MMOCommandEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.social.Request;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||
import net.Indyuce.mmocore.party.provided.PartyInvite;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -13,65 +15,65 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.party.provided.PartyInvite;
|
||||
import net.Indyuce.mmocore.api.player.social.Request;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartyCommand extends BukkitCommand {
|
||||
|
||||
public PartyCommand(ConfigurationSection config) {
|
||||
super(config.getString("main"));
|
||||
|
||||
setAliases(config.getStringList("aliases"));
|
||||
setDescription("Opens the party menu.");
|
||||
}
|
||||
public PartyCommand(ConfigurationSection config) {
|
||||
super(config.getString("main"));
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only.");
|
||||
return true;
|
||||
}
|
||||
setAliases(config.getStringList("aliases"));
|
||||
setDescription("Opens the party menu.");
|
||||
}
|
||||
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "party");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (args.length > 1) {
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(args[1]);
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command is for players only.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Request request = MMOCore.plugin.requestManager.getRequest(uuid);
|
||||
if (!(request instanceof PartyInvite))
|
||||
return true;
|
||||
PlayerData data = PlayerData.get((OfflinePlayer) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "party");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return true;
|
||||
|
||||
if (request.isTimedOut()) {
|
||||
MMOCore.plugin.requestManager.unregisterRequest(uuid);
|
||||
return true;
|
||||
}
|
||||
if (args.length > 0) {
|
||||
|
||||
if (!((MMOCorePartyModule) MMOCore.plugin.partyModule).isRegistered(((PartyInvite) request).getParty())) {
|
||||
MMOCore.plugin.requestManager.unregisterRequest(uuid);
|
||||
return true;
|
||||
}
|
||||
final @Nullable PartyInvite invite;
|
||||
if (args.length > 1)
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept"))
|
||||
request.accept();
|
||||
if (args[0].equalsIgnoreCase("deny"))
|
||||
request.deny();
|
||||
return true;
|
||||
}
|
||||
// Search by request ID
|
||||
try {
|
||||
final Request req = MMOCore.plugin.requestManager.getRequest(UUID.fromString(args[1]));
|
||||
Validate.isTrue(req instanceof PartyInvite && !req.isTimedOut());
|
||||
invite = (PartyInvite) req;
|
||||
Validate.isTrue(((MMOCorePartyModule) MMOCore.plugin.partyModule).isRegistered(invite.getParty()));
|
||||
} catch (Exception exception) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data.getParty() != null)
|
||||
InventoryManager.PARTY_VIEW.newInventory(data).open();
|
||||
else
|
||||
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
||||
return true;
|
||||
}
|
||||
// Search by target player
|
||||
else
|
||||
invite = MMOCore.plugin.requestManager.findRequest(data, PartyInvite.class);
|
||||
|
||||
// No invite found with given identifier/target player
|
||||
if (invite == null)
|
||||
return true;
|
||||
|
||||
if (args[0].equalsIgnoreCase("accept"))
|
||||
invite.accept();
|
||||
else if (args[0].equalsIgnoreCase("deny"))
|
||||
invite.deny();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (data.getParty() != null)
|
||||
InventoryManager.PARTY_VIEW.newInventory(data).open();
|
||||
else
|
||||
InventoryManager.PARTY_CREATION.newInventory(data).open();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,15 @@
|
||||
package net.Indyuce.mmocore.loot.droptable.dropitem;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.loot.LootBuilder;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.RandomAmount;
|
||||
import net.Indyuce.mmocore.loot.LootBuilder;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class DropItem {
|
||||
protected static final Random random = new Random();
|
||||
|
||||
private static final double CHANCE_COEFFICIENT = 7. / 100;
|
||||
private final double chance, weight;
|
||||
private final RandomAmount amount;
|
||||
|
||||
@ -39,8 +37,6 @@ public abstract class DropItem {
|
||||
return amount.calculateInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* CHANCE stat = 0 | tier chances are unchanged
|
||||
* CHANCE stat = +inf | uniform law for any drop item
|
||||
@ -48,19 +44,9 @@ public abstract class DropItem {
|
||||
*
|
||||
* @return The real weight of an item considering the player's CHANCE stat.
|
||||
*/
|
||||
/**
|
||||
* CHANCE stat = 0 | tier chances are unchanged
|
||||
* CHANCE stat = +inf | uniform law for any drop item
|
||||
* CHANCE stat = 100 | all tier chances are taken their square root
|
||||
*
|
||||
* @return The real weight of an item considering the player's CHANCE stat.
|
||||
*/
|
||||
/**
|
||||
* If the player chance is 0 the random value will remain the same. When he get lucks the chance gets closer to one.
|
||||
*/
|
||||
public boolean rollChance(PlayerData player) {
|
||||
double value=random.nextDouble();
|
||||
return value< Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
double value = random.nextDouble();
|
||||
return value < Math.pow(chance, 1 / Math.pow(1 + CHANCE_COEFFICIENT * player.getStats().getStat("CHANCE"), 1.0 / 3.0));
|
||||
}
|
||||
|
||||
public abstract void collect(LootBuilder builder);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmocore.manager.social;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.social.Request;
|
||||
import net.Indyuce.mmocore.manager.MMOCoreManager;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -14,6 +15,20 @@ public class RequestManager implements MMOCoreManager {
|
||||
|
||||
private boolean ENABLED;
|
||||
|
||||
/**
|
||||
* The request map is NOT cleared, whatever state of the <code>clearBefore</code>
|
||||
* boolean as it's useless because they are guaranteed to disappear with time.
|
||||
*
|
||||
* @param clearBefore Useless here
|
||||
*/
|
||||
@Override
|
||||
public void initialize(boolean clearBefore) {
|
||||
if (!ENABLED) {
|
||||
Bukkit.getScheduler().runTaskTimer(MMOCore.plugin, this::flushRequests, 60 * 20, 60 * 20 * 5);
|
||||
ENABLED = true;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Request getRequest(UUID uuid) {
|
||||
return Objects.requireNonNull(requests.get(uuid), "Could not find request with UUID '" + uuid.toString() + "'");
|
||||
@ -23,6 +38,19 @@ public class RequestManager implements MMOCoreManager {
|
||||
requests.put(request.getUniqueId(), request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <T> Class extending {@link Request}
|
||||
* @return Tries to find and return any non timed-out request
|
||||
* with given target player and request type.
|
||||
*/
|
||||
@Nullable
|
||||
public <T extends Request> T findRequest(PlayerData target, Class<T> givenClass) {
|
||||
for (Request req : requests.values())
|
||||
if (!req.isTimedOut() && req.getTarget().equals(target) && req.getClass().equals(givenClass))
|
||||
return (T) req;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Request unregisterRequest(UUID uuid) {
|
||||
return requests.remove(uuid);
|
||||
@ -38,18 +66,4 @@ public class RequestManager implements MMOCoreManager {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The request map is NOT cleared, whatever state of the <code>clearBefore</code>
|
||||
* boolean as it's useless because they are guaranteed to disappear with time.
|
||||
*
|
||||
* @param clearBefore Useless here
|
||||
*/
|
||||
@Override
|
||||
public void initialize(boolean clearBefore) {
|
||||
if (!ENABLED) {
|
||||
Bukkit.getScheduler().runTaskTimer(MMOCore.plugin, this::flushRequests, 60 * 20, 60 * 20 * 5);
|
||||
ENABLED = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@ package net.Indyuce.mmocore.player.playerclass;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.script.Script;
|
||||
import io.lumine.mythic.lib.script.mechanic.Mechanic;
|
||||
import io.lumine.mythic.lib.skill.SimpleSkill;
|
||||
import io.lumine.mythic.lib.skill.Skill;
|
||||
import io.lumine.mythic.lib.skill.custom.CustomSkill;
|
||||
import io.lumine.mythic.lib.skill.custom.mechanic.Mechanic;
|
||||
import io.lumine.mythic.lib.skill.handler.MythicLibSkillHandler;
|
||||
import io.lumine.mythic.lib.skill.result.SkillResult;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
@Deprecated
|
||||
public class ClassTrigger {
|
||||
private final ClassTriggerType type;
|
||||
private final CustomSkill skill = new CustomSkill("classTrigger", false);
|
||||
private final Script skill = new Script("classTrigger", false);
|
||||
private final Skill castableSkill = new SimpleSkill(TriggerType.CAST, new MythicLibSkillHandler(skill));
|
||||
|
||||
public ClassTrigger(String triggerTypeString, List<String> mechanicStringList) {
|
||||
|
@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.player.cooldown.CooldownObject;
|
||||
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
||||
import io.lumine.mythic.lib.skill.custom.condition.Condition;
|
||||
import io.lumine.mythic.lib.script.condition.Condition;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.IntegerLinearValue;
|
||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.Indyuce.mmocore.skill.custom.mechanic;
|
||||
|
||||
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
||||
import io.lumine.mythic.lib.skill.custom.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.util.DoubleFormula;
|
||||
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
@ -2,7 +2,7 @@ package net.Indyuce.mmocore.skill.custom.mechanic;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
||||
import io.lumine.mythic.lib.skill.custom.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.util.DoubleFormula;
|
||||
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||
|
@ -2,7 +2,7 @@ package net.Indyuce.mmocore.skill.custom.mechanic;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
||||
import io.lumine.mythic.lib.skill.custom.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.util.DoubleFormula;
|
||||
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmocore.skill.custom.mechanic;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.script.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
||||
import io.lumine.mythic.lib.skill.custom.mechanic.type.TargetMechanic;
|
||||
import io.lumine.mythic.lib.util.DoubleFormula;
|
||||
import io.lumine.mythic.lib.util.configobject.ConfigObject;
|
||||
import net.Indyuce.mmocore.api.event.PlayerResourceUpdateEvent;
|
||||
|
Loading…
Reference in New Issue
Block a user