2023.03 update 2 / 2

I think we're done!!!
This commit is contained in:
Paul Reilly
2023-03-09 03:50:47 -06:00
parent 2265783afb
commit b7ea1b8b3e
101 changed files with 534 additions and 380 deletions

View File

@ -1,35 +1,14 @@
package me.totalfreedom.totalfreedommod.fun;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.SplittableRandom;
import java.util.UUID;
import me.totalfreedom.shop.ShopItem;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@ -45,6 +24,8 @@ import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.*;
public class ItemFun extends FreedomService
{
@ -61,8 +42,7 @@ public class ItemFun extends FreedomService
List<String> featureList = new ArrayList<>();
featureList.add(item.getDataName());
cooldownTracker.put(player.getName(), featureList);
}
else
} else
{
cooldownTracker.get(player.getName()).add(item.getDataName());
}
@ -73,7 +53,7 @@ public class ItemFun extends FreedomService
{
cooldownTracker.get(player.getName()).remove(item.getDataName());
}
}.runTaskLater(plugin, seconds * 20);
}.runTaskLater(plugin, seconds * 20L);
}
public boolean onCooldown(Player player, ShopItem item)
@ -98,6 +78,7 @@ public class ItemFun extends FreedomService
@EventHandler
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
{
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
Player player = event.getPlayer();
Entity entity = event.getRightClicked();
@ -126,7 +107,7 @@ public class ItemFun extends FreedomService
Location playerLoc = player.getLocation();
Vector direction = playerLoc.getDirection().normalize();
LivingEntity livingEntity = (LivingEntity)event.getRightClicked();
LivingEntity livingEntity = (LivingEntity) event.getRightClicked();
EntityType entityType = livingEntity.getType();
if (entityType != fPlayer.mobThrowerCreature())
{
@ -141,6 +122,8 @@ public class ItemFun extends FreedomService
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamage(EntityDamageByEntityEvent event)
{
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
Entity entity = event.getEntity();
if (entity instanceof Player || !(event.getDamager() instanceof Player))
@ -148,7 +131,7 @@ public class ItemFun extends FreedomService
return;
}
Player player = (Player)event.getDamager();
Player player = (Player) event.getDamager();
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
{
@ -167,6 +150,8 @@ public class ItemFun extends FreedomService
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event)
{
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
if (event.getAction() == Action.LEFT_CLICK_AIR
|| event.getAction() == Action.LEFT_CLICK_BLOCK)
{
@ -178,7 +163,7 @@ public class ItemFun extends FreedomService
switch (event.getMaterial())
{
case GUNPOWDER:
case GUNPOWDER ->
{
if (!fPlayer.isMP44Armed())
{
@ -190,15 +175,12 @@ public class ItemFun extends FreedomService
if (fPlayer.toggleMP44Firing())
{
fPlayer.startArrowShooter(plugin);
}
else
} else
{
fPlayer.stopArrowShooter();
}
break;
}
case BLAZE_ROD:
case BLAZE_ROD ->
{
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory(), plugin.sh.getLightningRod()))
{
@ -219,10 +201,8 @@ public class ItemFun extends FreedomService
player.getWorld().strikeLightning(targetBlock.getLocation());
}
cooldown(player, ShopItem.LIGHTNING_ROD, 10);
break;
}
case FIRE_CHARGE:
case FIRE_CHARGE ->
{
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory(), plugin.sh.getFireBall()))
{
@ -240,14 +220,12 @@ public class ItemFun extends FreedomService
FIRE_BALL_UUIDS.add(fireball.getUniqueId());
fireball.setVelocity(player.getLocation().getDirection().multiply(2));
cooldown(player, ShopItem.FIRE_BALL, 5);
break;
}
case TROPICAL_FISH:
case TROPICAL_FISH ->
{
final int RADIUS_HIT = 5;
final int STRENGTH = 4;
if (plugin.lp.CLOWNFISH_TOGGLE.contains(player.getName()))
{
player.sendMessage(ChatColor.GRAY + "An admin has disabled your ability to use clownfish.");
@ -284,8 +262,7 @@ public class ItemFun extends FreedomService
target.setVelocity(targetPosVec.subtract(playerLocVec).normalize().multiply(STRENGTH));
didHit = true;
}
}
catch (IllegalArgumentException ignored)
} catch (IllegalArgumentException ignored)
{
}
}
@ -302,12 +279,10 @@ public class ItemFun extends FreedomService
}
cooldown(player, ShopItem.CLOWN_FISH, 30);
}
break;
}
default:
default ->
{
// Do nothing
break;
}
}
}
@ -315,10 +290,12 @@ public class ItemFun extends FreedomService
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event)
{
if (plugin.sh == null) return;
Projectile entity = event.getEntity();
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
{
Player player = (Player)entity.getShooter();
Player player = (Player) entity.getShooter();
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory(), plugin.sh.getRideablePearl()))
{
entity.addPassenger(player);
@ -333,7 +310,7 @@ public class ItemFun extends FreedomService
Arrow arrow = null;
if (entity instanceof Arrow)
{
arrow = (Arrow)entity;
arrow = (Arrow) entity;
}
//Redundant Player cast is required to avoid suspicious method calls.
if (arrow != null
@ -349,7 +326,7 @@ public class ItemFun extends FreedomService
if (FIRE_BALL_UUIDS.contains(entity.getUniqueId()))
{
FIRE_BALL_UUIDS.remove(entity.getUniqueId());
Firework firework = (Firework)entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
Firework firework = (Firework) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.FIREWORK);
firework.setSilent(true);
FireworkMeta meta = firework.getFireworkMeta();
FireworkEffect explosionEffect = FireworkEffect.builder().withColor(Color.ORANGE).withFade(Color.YELLOW).with(FireworkEffect.Type.BALL_LARGE).trail(true).build();
@ -376,6 +353,8 @@ public class ItemFun extends FreedomService
@EventHandler
public void onFish(PlayerFishEvent event)
{
if (plugin.sh == null) return;
Player player = event.getPlayer();
PlayerData data = plugin.pl.getData(player);
PlayerInventory inv = event.getPlayer().getInventory();
@ -404,40 +383,32 @@ public class ItemFun extends FreedomService
if (orientation >= 0.0 && orientation < 22.5)
{
zVel = speed;
}
else if (orientation >= 22.5 && orientation < 67.5)
} else if (orientation >= 22.5 && orientation < 67.5)
{
xVel = -(speed / 2.0);
zVel = speed / 2.0;
}
else if (orientation >= 67.5 && orientation < 112.5)
} else if (orientation >= 67.5 && orientation < 112.5)
{
xVel = -speed;
}
else if (orientation >= 112.5 && orientation < 157.5)
} else if (orientation >= 112.5 && orientation < 157.5)
{
xVel = -(speed / 2.0);
zVel = -(speed / 2.0);
}
else if (orientation >= 157.5 && orientation < 202.5)
} else if (orientation >= 157.5 && orientation < 202.5)
{
zVel = -speed;
}
else if (orientation >= 202.5 && orientation < 247.5)
} else if (orientation >= 202.5 && orientation < 247.5)
{
xVel = speed / 2.0;
zVel = -(speed / 2.0);
}
else if (orientation >= 247.5 && orientation < 292.5)
} else if (orientation >= 247.5 && orientation < 292.5)
{
xVel = speed;
}
else if (orientation >= 292.5 && orientation < 337.5)
} else if (orientation >= 292.5 && orientation < 337.5)
{
xVel = speed / 2.0;
zVel = speed / 2.0;
}
else if (orientation >= 337.5 && orientation < 360.0)
} else if (orientation >= 337.5 && orientation < 360.0)
{
zVel = speed;
}
@ -447,8 +418,7 @@ public class ItemFun extends FreedomService
if (event.getState() == PlayerFishEvent.State.FISHING)
{
orientationTracker.put(player, player.getLocation().getYaw());
}
else
} else
{
orientationTracker.remove(player);
}

View File

@ -7,7 +7,7 @@ import java.util.SplittableRandom;
import java.util.UUID;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.shop.ShopItem;
import me.totalfreedom.shop.ShopItem;
import me.totalfreedom.totalfreedommod.util.Groups;
import org.bukkit.Location;
import org.bukkit.Material;
@ -36,6 +36,8 @@ public class Trailer extends FreedomService
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event)
{
if (plugin.sh == null) return; // Shop is disabled
/* Doesn't continue any further if...
* - The trail list is empty
* - The player doesn't have their trail enabled in the first place
@ -63,6 +65,7 @@ public class Trailer extends FreedomService
return;
}
// TODO: Make this particles instead of blocks!
fromBlock.setType(Groups.WOOL_COLORS.get(random.nextInt(Groups.WOOL_COLORS.size())));
BlockData data = fromBlock.getBlockData();
Material material = Material.getMaterial(String.valueOf(fromBlock.getType()));