mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
[COMMONS] Bugfixes, cleanup, and a much-needed clownfish tweak
- Fixes bug that caused non-shop items (like the mob tosser) to not work if the Shop plugin is not already installed - Finally makes the fucking clownfish something that can be turned down in the sound settings by having it play the sound at the Player sound category
This commit is contained in:
parent
5332dc88cd
commit
2e7756ed0f
@ -78,13 +78,11 @@ public class ItemFun extends FreedomService
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerEntityInteract(PlayerInteractEntityEvent event)
|
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();
|
Player player = event.getPlayer();
|
||||||
Entity entity = event.getRightClicked();
|
Entity entity = event.getRightClicked();
|
||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
if (player.getInventory().getItemInMainHand().getType().equals(Material.POTATO) || entity.getType().equals(EntityType.PLAYER))
|
if (plugin.sh != null && player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
|
||||||
{
|
{
|
||||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory(), plugin.sh.getStackingPotato()))
|
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.STACKING_POTATO, player.getInventory(), plugin.sh.getStackingPotato()))
|
||||||
{
|
{
|
||||||
@ -126,13 +124,13 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof Player || !(event.getDamager() instanceof Player))
|
// Why the fuck do we have 3 if checks in a row that do the exact same damn thing? Couldn't this be condensed into a single if check?!
|
||||||
|
|
||||||
|
if (entity instanceof Player || !(event.getDamager() instanceof Player player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) event.getDamager();
|
|
||||||
|
|
||||||
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
|
if (!player.getInventory().getItemInMainHand().getType().equals(Material.POTATO))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -150,8 +148,6 @@ public class ItemFun extends FreedomService
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteractEvent(PlayerInteractEvent event)
|
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
|
if (event.getAction() == Action.LEFT_CLICK_AIR
|
||||||
|| event.getAction() == Action.LEFT_CLICK_BLOCK)
|
|| event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
{
|
{
|
||||||
@ -182,6 +178,8 @@ public class ItemFun extends FreedomService
|
|||||||
}
|
}
|
||||||
case BLAZE_ROD ->
|
case BLAZE_ROD ->
|
||||||
{
|
{
|
||||||
|
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||||
|
|
||||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory(), plugin.sh.getLightningRod()))
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.LIGHTNING_ROD, player.getInventory(), plugin.sh.getLightningRod()))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -204,6 +202,8 @@ public class ItemFun extends FreedomService
|
|||||||
}
|
}
|
||||||
case FIRE_CHARGE ->
|
case FIRE_CHARGE ->
|
||||||
{
|
{
|
||||||
|
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||||
|
|
||||||
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory(), plugin.sh.getFireBall()))
|
if (!plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.FIRE_BALL, player.getInventory(), plugin.sh.getFireBall()))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -223,6 +223,8 @@ public class ItemFun extends FreedomService
|
|||||||
}
|
}
|
||||||
case TROPICAL_FISH ->
|
case TROPICAL_FISH ->
|
||||||
{
|
{
|
||||||
|
if (plugin.sh == null) return; // This is to prevent an NPE if the Shoppe isn't present.
|
||||||
|
|
||||||
final int RADIUS_HIT = 5;
|
final int RADIUS_HIT = 5;
|
||||||
final int STRENGTH = 4;
|
final int STRENGTH = 4;
|
||||||
|
|
||||||
@ -269,14 +271,9 @@ public class ItemFun extends FreedomService
|
|||||||
|
|
||||||
if (didHit)
|
if (didHit)
|
||||||
{
|
{
|
||||||
final Sound[] sounds = Sound.values();
|
Arrays.stream(Sound.values()).filter(sound -> sound.toString().contains("HIT")).forEach(sound ->
|
||||||
for (Sound sound : sounds)
|
Objects.requireNonNull(playerLoc.getWorld()).playSound(randomOffset(playerLoc), sound,
|
||||||
{
|
SoundCategory.PLAYERS, 20f, randomDoubleRange(0.5, 2.0).floatValue()));
|
||||||
if (sound.toString().contains("HIT"))
|
|
||||||
{
|
|
||||||
Objects.requireNonNull(playerLoc.getWorld()).playSound(randomOffset(playerLoc), sound, 20f, randomDoubleRange(0.5, 2.0).floatValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cooldown(player, ShopItem.CLOWN_FISH, 30);
|
cooldown(player, ShopItem.CLOWN_FISH, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,13 +290,10 @@ public class ItemFun extends FreedomService
|
|||||||
if (plugin.sh == null) return;
|
if (plugin.sh == null) return;
|
||||||
|
|
||||||
Projectile entity = event.getEntity();
|
Projectile entity = event.getEntity();
|
||||||
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player)
|
if (entity instanceof EnderPearl && entity.getShooter() instanceof Player player
|
||||||
|
&& plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory(), plugin.sh.getRideablePearl()))
|
||||||
{
|
{
|
||||||
Player player = (Player) entity.getShooter();
|
entity.addPassenger(player);
|
||||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.RIDEABLE_PEARL, player.getInventory(), plugin.sh.getRideablePearl()))
|
|
||||||
{
|
|
||||||
entity.addPassenger(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,9 +350,6 @@ public class ItemFun extends FreedomService
|
|||||||
if (plugin.sh == null) return;
|
if (plugin.sh == null) return;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerData data = plugin.pl.getData(player);
|
|
||||||
PlayerInventory inv = event.getPlayer().getInventory();
|
|
||||||
ItemStack rod = inv.getItemInMainHand();
|
|
||||||
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory(), plugin.sh.getGrapplingHook()))
|
if (plugin.sh.isRealItem(plugin.pl.getData(player), ShopItem.GRAPPLING_HOOK, player.getInventory(), plugin.sh.getGrapplingHook()))
|
||||||
{
|
{
|
||||||
if (event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.IN_GROUND)
|
if (event.getState() == PlayerFishEvent.State.REEL_IN || event.getState() == PlayerFishEvent.State.IN_GROUND)
|
||||||
@ -383,32 +374,40 @@ public class ItemFun extends FreedomService
|
|||||||
if (orientation >= 0.0 && orientation < 22.5)
|
if (orientation >= 0.0 && orientation < 22.5)
|
||||||
{
|
{
|
||||||
zVel = speed;
|
zVel = speed;
|
||||||
} else if (orientation >= 22.5 && orientation < 67.5)
|
}
|
||||||
|
else if (orientation >= 22.5 && orientation < 67.5)
|
||||||
{
|
{
|
||||||
xVel = -(speed / 2.0);
|
xVel = -(speed / 2.0);
|
||||||
zVel = 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;
|
xVel = -speed;
|
||||||
} else if (orientation >= 112.5 && orientation < 157.5)
|
}
|
||||||
|
else if (orientation >= 112.5 && orientation < 157.5)
|
||||||
{
|
{
|
||||||
xVel = -(speed / 2.0);
|
xVel = -(speed / 2.0);
|
||||||
zVel = -(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;
|
zVel = -speed;
|
||||||
} else if (orientation >= 202.5 && orientation < 247.5)
|
}
|
||||||
|
else if (orientation >= 202.5 && orientation < 247.5)
|
||||||
{
|
{
|
||||||
xVel = speed / 2.0;
|
xVel = speed / 2.0;
|
||||||
zVel = -(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;
|
xVel = speed;
|
||||||
} else if (orientation >= 292.5 && orientation < 337.5)
|
}
|
||||||
|
else if (orientation >= 292.5 && orientation < 337.5)
|
||||||
{
|
{
|
||||||
xVel = speed / 2.0;
|
xVel = speed / 2.0;
|
||||||
zVel = 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;
|
zVel = speed;
|
||||||
}
|
}
|
||||||
@ -418,7 +417,8 @@ public class ItemFun extends FreedomService
|
|||||||
if (event.getState() == PlayerFishEvent.State.FISHING)
|
if (event.getState() == PlayerFishEvent.State.FISHING)
|
||||||
{
|
{
|
||||||
orientationTracker.put(player, player.getLocation().getYaw());
|
orientationTracker.put(player, player.getLocation().getYaw());
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
orientationTracker.remove(player);
|
orientationTracker.remove(player);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import me.totalfreedom.totalfreedommod.api.ShopItem;
|
|||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
Loading…
Reference in New Issue
Block a user