Created Transmission extension

This commit is contained in:
Auxilor 2021-08-04 17:48:14 +01:00
parent 925b852130
commit 43e64ed167
6 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,7 @@
group 'com.willfp'
version '1.0.0'
description = 'Transmission Extension'
shadowJar {
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
}

View File

@ -0,0 +1,38 @@
package com.willfp.ecoenchants.transmission;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.itemtypes.Spell;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class Transmission extends Spell {
public Transmission() {
super("transmission");
}
@Override
public boolean onUse(@NotNull final Player player,
final int level,
@NotNull final PlayerInteractEvent event) {
double distance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "distance");
Vector vector = player.getEyeLocation().getDirection().clone();
vector.normalize();
vector.multiply(distance);
Location end = player.getEyeLocation().clone().add(vector);
if (player.rayTraceBlocks(distance) != null) {
player.sendMessage(this.getPlugin().getLangYml().getPrefix() + this.getConfig().getString("block-in-path"));
return false;
}
player.teleport(end);
return true;
}
}

View File

@ -0,0 +1,24 @@
package com.willfp.ecoenchants.transmission;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import org.jetbrains.annotations.NotNull;
public class TransmissionMain extends Extension {
public static final EcoEnchant TRANSMISSION = new Transmission();
public TransmissionMain(@NotNull final EcoPlugin plugin) {
super(plugin);
}
@Override
public void onEnable() {
// Handled by super
}
@Override
public void onDisable() {
// Handled by super
}
}

View File

@ -0,0 +1,28 @@
#
# Firewand EcoEnchant
#
name: "Firewand"
description: Teleports you in the direction you are looking
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: legendary
general-config:
flags: []
targets:
- sword
grindstoneable: true
disabled-in-worlds: [ ]
conflicts: [ ]
maximum-level: 1
config:
activation-sound: ENTITY_ENDERMAN_TELEPORT
cooldown: 15 # In seconds
distance: 8
block-in-path: "&cThere are blocks in the way!"

View File

@ -0,0 +1,4 @@
name: Transmission
main: com.willfp.ecoenchants.transmission.TransmissionMain
version: ${projectVersion}
author: Auxilor

View File

@ -23,4 +23,5 @@ include ':eco-extensions:precision'
include ':eco-extensions:rainbow'
include ':eco-extensions:sprint-artifacts'
include ':eco-extensions:summoning'
include ':eco-extensions:transmission'
include ':eco-extensions:xray'