Added warpTime option for any waypoint

This commit is contained in:
Indyuce 2022-08-18 13:01:23 +02:00
parent 792ca9af39
commit ab5635432c
3 changed files with 28 additions and 16 deletions

View File

@ -683,12 +683,12 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
final int x = getPlayer().getLocation().getBlockX();
final int y = getPlayer().getLocation().getBlockY();
final int z = getPlayer().getLocation().getBlockZ();
final double warpTime = target.getWarpTime();
int t;
public void run() {
if (!isOnline())
return;
if (getPlayer().getLocation().getBlockX() != x || getPlayer().getLocation().getBlockY() != y
if (!isOnline() || getPlayer().getLocation().getBlockX() != x
|| getPlayer().getLocation().getBlockY() != y
|| getPlayer().getLocation().getBlockZ() != z) {
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CANCELLED).playTo(getPlayer());
MMOCore.plugin.configManager.getSimpleMessage("warping-canceled").send(getPlayer());
@ -697,8 +697,8 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return;
}
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", "" + ((MMOCore.plugin.configManager.waypointWarpTime+20 - t) / 20)).send(getPlayer());
if (t++ >= MMOCore.plugin.configManager.waypointWarpTime) {
MMOCore.plugin.configManager.getSimpleMessage("warping-comencing", "left", String.valueOf((warpTime + 20 - t) / 20)).send(getPlayer());
if (t++ >= warpTime) {
getPlayer().teleport(target.getLocation());
getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 1, false, false));
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_TELEPORT).playTo(getPlayer());
@ -706,12 +706,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return;
}
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (t / Math.PI * 1.5/MMOCore.plugin.configManager.waypointWarpTime + .5));
double r = Math.sin((double) t / MMOCore.plugin.configManager.waypointWarpTime * Math.PI);
MMOCore.plugin.soundManager.getSound(SoundEvent.WARP_CHARGE).playTo(getPlayer(), 1, (float) (.5 + t / warpTime * 1.5));
final double r = Math.sin((double) t / warpTime * Math.PI);
for (double j = 0; j < Math.PI * 2; j += Math.PI / 4)
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE,
getPlayer().getLocation().add(Math.cos((double) 5*t /MMOCore.plugin.configManager.waypointWarpTime + j) * r, (double) 2*t / MMOCore.plugin.configManager.waypointWarpTime, Math.sin((double) 5*t / MMOCore.plugin.configManager.waypointWarpTime + j) * r), 1,
new Particle.DustOptions(Color.PURPLE, 1.25f));
getPlayer().getLocation().getWorld().spawnParticle(Particle.REDSTONE, getPlayer().getLocation().add(
Math.cos((double) 5 * t / warpTime + j) * r,
(double) 2 * t / warpTime,
Math.sin((double) 5 * t / warpTime + j) * r),
1, new Particle.DustOptions(Color.PURPLE, 1.25f));
}
}.runTaskTimer(MMOCore.plugin, 0, 1);
}

View File

@ -2,8 +2,8 @@ package net.Indyuce.mmocore.manager;
import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.input.ChatInput;
import net.Indyuce.mmocore.api.util.input.PlayerInput;
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
@ -68,9 +68,9 @@ public class ConfigManager {
loadDefaultFile("expcurves", "levels.txt");
loadDefaultFile("expcurves", "mining.txt");
}
if(!new File(MMOCore.plugin.getDataFolder()+"/skilltree").exists()) {
loadDefaultFile("skilltree","combat.yml");
}
if (!new File(MMOCore.plugin.getDataFolder() + "/skilltree").exists())
loadDefaultFile("skilltree", "combat.yml");
loadDefaultFile("attributes.yml");
loadDefaultFile("items.yml");
@ -109,7 +109,8 @@ public class ConfigManager {
canCreativeCast = MMOCore.plugin.getConfig().getBoolean("can-creative-cast");
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
maxBoundSkills= MMOCore.plugin.getConfig().getInt("max-bound-skills",6);
maxBoundSkills = MMOCore.plugin.getConfig().getInt("max-bound-skills", 6);
overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp");
}
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {
@ -123,7 +124,7 @@ public class ConfigManager {
@Deprecated
public PlayerInput newPlayerInput(Player player, InputType type, Consumer<String> output) {
return new ChatInput(player, type, output) ;
return new ChatInput(player, type, output);
}
public void loadDefaultFile(String name) {

View File

@ -23,6 +23,7 @@ public class Waypoint extends PostLoadObject implements Unlockable {
private final Location loc;
private final List<String> lore;
private final double radiusSquared;
private final int warpTime;
/**
* Set that saves all the waypoints accessible when in this waypoint.
@ -48,6 +49,7 @@ public class Waypoint extends PostLoadObject implements Unlockable {
loc = readLocation(Objects.requireNonNull(config.getString("location"), "Could not read location"));
radiusSquared = Math.pow(config.getDouble("radius"), 2);
warpTime = config.getInt("warp-time", 100);
dynamicCost = config.getDouble("cost.dynamic-use");
normalCost = config.getDouble("cost.normal-use");
@ -95,10 +97,17 @@ public class Waypoint extends PostLoadObject implements Unlockable {
return loc;
}
public int getWarpTime() {
return warpTime;
}
public double getDynamicCost() {
return dynamicCost;
}
/**
* @deprecated Not implemented yet
*/
@Deprecated
public double getSetSpawnCost() {
return setSpawnCost;