mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-06-26 19:44:27 +00:00
Start implementations
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
package me.totalfreedom.fossil.items;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class ClownfishItem extends ShopItem
|
||||
{
|
||||
public ClownfishItem()
|
||||
{
|
||||
super(Material.TROPICAL_FISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAction(final @NotNull Player user, final @Nullable Entity target)
|
||||
{
|
||||
if (target == null) return;
|
||||
|
||||
final Location location = user.getEyeLocation().clone();
|
||||
final Vector vector = location.getDirection().multiply(2);
|
||||
|
||||
target.setVelocity(vector);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package me.totalfreedom.fossil.items;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class ShopItem
|
||||
{
|
||||
private final ItemStack item;
|
||||
private final ItemMeta meta;
|
||||
|
||||
protected ShopItem(final Material material)
|
||||
{
|
||||
this.item = new ItemStack(material, 1);
|
||||
|
||||
this.meta = this.item.getItemMeta();
|
||||
}
|
||||
|
||||
public abstract void runAction(@NotNull final Player user, @Nullable final Entity target);
|
||||
|
||||
public ItemStack getItem()
|
||||
{
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ItemMeta getMeta()
|
||||
{
|
||||
return this.meta;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package me.totalfreedom.fossil.items;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class TrailItem extends ShopItem
|
||||
{
|
||||
public TrailItem(final Material material)
|
||||
{
|
||||
super(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAction(final @NotNull Player user, final @Nullable Entity target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package me.totalfreedom.fossil.trail;
|
||||
|
||||
import me.totalfreedom.particle.Trail;
|
||||
import me.totalfreedom.particle.TrailType;
|
||||
import me.totalfreedom.service.Service;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Trailer extends Service
|
||||
{
|
||||
private final List<Trail> trailList = new ArrayList<>();
|
||||
|
||||
public Trailer() {
|
||||
super("trailer_service");
|
||||
}
|
||||
|
||||
public void addTrail(final Trail trail) {
|
||||
this.trailList.add(trail);
|
||||
}
|
||||
|
||||
public void removeTrail(final Trail trail) {
|
||||
this.trailList.remove(trail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick()
|
||||
{
|
||||
for (final Trail trail : trailList) {
|
||||
if (trail.getAssociatedPlayer().isOnline()) {
|
||||
final Player player = (Player) trail.getAssociatedPlayer();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package me.totalfreedom.fossil.trail.types;
|
||||
|
||||
import me.totalfreedom.particle.TrailType;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class BasicTrail extends SimpleTrail
|
||||
{
|
||||
protected BasicTrail(final Player player)
|
||||
{
|
||||
super(player, TrailType.DEFAULT);
|
||||
super.setColor(Color.RED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle()
|
||||
{
|
||||
// Exit immediately if either condition is false.
|
||||
if (!isActive() || !getAssociatedPlayer().isOnline()) return;
|
||||
|
||||
// Trail is active and the player is online.
|
||||
final Particle particle = getTrailType().getType();
|
||||
final Particle.DustOptions options = new Particle.DustOptions(getColor(), 3);
|
||||
final Player player = (Player) getAssociatedPlayer();
|
||||
final Location location = player.getLocation()
|
||||
.clone()
|
||||
.subtract(0, 1, 0);
|
||||
location.getWorld().spawnParticle(particle, location, 1, 0.0, 0.5, 0.0, options);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package me.totalfreedom.fossil.trail.types;
|
||||
|
||||
import me.totalfreedom.particle.TrailType;
|
||||
import me.totalfreedom.utils.InterpolationUtils;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public final class RainbowTrail extends SimpleTrail
|
||||
{
|
||||
private Iterator<Color> currentColor;
|
||||
|
||||
protected RainbowTrail(final Player player)
|
||||
{
|
||||
super(player, TrailType.DEFAULT);
|
||||
setColors(InterpolationUtils.rainbow(40 % 7));
|
||||
this.currentColor = getColors().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnParticle()
|
||||
{
|
||||
// Exit immediately if either case is false.
|
||||
if (!isActive() || !getAssociatedPlayer().isOnline()) return;
|
||||
|
||||
// Re-initialize the color iterator if the iterator has previously reached the end of its index.
|
||||
if (!currentColor.hasNext())
|
||||
{
|
||||
this.currentColor = getColors().iterator();
|
||||
}
|
||||
|
||||
final Color color = currentColor.next();
|
||||
final Player player = (Player) getAssociatedPlayer();
|
||||
final Particle particle = getTrailType().getType();
|
||||
final Particle.DustOptions options = new Particle.DustOptions(color, 3);
|
||||
final Location location = player.getLocation()
|
||||
.clone()
|
||||
.subtract(0, 1, 0);
|
||||
|
||||
location.getWorld()
|
||||
.spawnParticle(particle, location, 1, 0.0, 0.5, 0.0, options);
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package me.totalfreedom.fossil.trail.types;
|
||||
|
||||
import me.totalfreedom.particle.Trail;
|
||||
import me.totalfreedom.particle.TrailType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class SimpleTrail implements Trail
|
||||
{
|
||||
private final UUID associatedPlayerUUID;
|
||||
private final TrailType trailType;
|
||||
|
||||
private Color staticColor = null;
|
||||
private Set<Color> gradientColor = null;
|
||||
private boolean active = false;
|
||||
|
||||
protected SimpleTrail(final Player player, final TrailType trailType) {
|
||||
this.associatedPlayerUUID = player.getUniqueId();
|
||||
this.trailType = trailType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull UUID getAssociatedPlayerUUID()
|
||||
{
|
||||
return associatedPlayerUUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull OfflinePlayer getAssociatedPlayer()
|
||||
{
|
||||
return Bukkit.getOfflinePlayer(getAssociatedPlayerUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull TrailType getTrailType()
|
||||
{
|
||||
return trailType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Color getColor()
|
||||
{
|
||||
return staticColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(@NotNull final Color color)
|
||||
{
|
||||
this.gradientColor = null;
|
||||
this.staticColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Set<Color> getColors()
|
||||
{
|
||||
return this.gradientColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColors(@NotNull final Set<Color> colors)
|
||||
{
|
||||
this.staticColor = null;
|
||||
this.gradientColor = colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGradient()
|
||||
{
|
||||
return gradientColor != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(final boolean active)
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package me.totalfreedom.fossil.trail.types;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class TrailProvider
|
||||
{
|
||||
public BasicTrail basicTrail(final Player player) {
|
||||
return new BasicTrail(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user