added rail gun

This commit is contained in:
ImproperIssues
2023-07-25 20:43:25 -07:00
parent 99bb45be9a
commit 1f65b1fbf3
27 changed files with 183 additions and 71 deletions

View File

@@ -74,6 +74,8 @@ public final class OgreDupeAlias extends JavaPlugin {
getCommand("attackcooldown").setTabCompleter(new AttackCooldownCommand());
getCommand("givecustom").setExecutor(new GiveCustomCommand());
getCommand("givecustom").setTabCompleter(new GiveCustomCommand());
getCommand("customitem").setExecutor(new CustomItemCommand());
getCommand("customitem").setTabCompleter(new CustomItemCommand());
getCommand("changerank").setExecutor(new ChangeRankCommand());
getCommand("changerank").setTabCompleter(new ChangeRankCommand());
getCommand("showdonation").setExecutor(new ShowDonationCommand());

View File

@@ -1,7 +1,7 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.data.Config;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.data.Config;
import fun.ogre.ogredupealias.data.ConfigDataType;
import fun.ogre.ogredupealias.utils.ArrayUtils;
import fun.ogre.ogredupealias.utils.Text;

View File

@@ -0,0 +1,53 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.commands.TabComplBuilder;
import fun.ogre.ogredupealias.plugin.custom.items.CustomItem;
import fun.ogre.ogredupealias.plugin.custom.items.CustomItems;
import fun.ogre.ogredupealias.utils.StringUtils;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class CustomItemCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
String name = args[0];
CustomItem result = null;
for (Class<? extends CustomItem> item : CustomItems.getRegistries().keySet()) {
if (item.getSimpleName().equalsIgnoreCase(name)) {
result = item.newInstance();
break;
}
}
if (result == null) {
sender.sendMessage(Text.ofAll("&cItem not found!"));
}
else {
Player player = (Player)sender;
player.getInventory().addItem(result.getItem());
sender.sendMessage(Text.ofAll("&dGave one &7" + StringUtils.capitalizeWords(result.getName())));
}
}
catch (Exception ex) {
CmdExHandler handler = new CmdExHandler(ex, command);
sender.sendMessage(handler.getHelp());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return new TabComplBuilder(sender, command, label, args)
.add(1, CustomItems.getRegistries().keySet().stream().map(item -> item.getSimpleName().toLowerCase()).toList())
.build();
}
}

View File

@@ -2,8 +2,6 @@ package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.events.EntityDamageListener;
import fun.ogre.ogredupealias.events.InteractionListener;
import fun.ogre.ogredupealias.plugin.RecipientList;
import fun.ogre.ogredupealias.utils.DisplayUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;

View File

@@ -1,7 +1,6 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.RankChangeGUI;
import fun.ogre.ogredupealias.plugin.custom.gui.CustomGUIs.StoreGUI;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

View File

@@ -4,18 +4,12 @@ import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.utils.ArrayUtils;
import fun.ogre.ogredupealias.utils.ImageUtils;
import fun.ogre.ogredupealias.utils.Text;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

View File

@@ -14,7 +14,6 @@ public class InteractionListener implements Listener {
@EventHandler
public void onClick(PlayerInteractEvent e) {
try {
this.processTable(e);
NetSkyBlade.handleNetskyBlade(e);
Defender.handleDefender(e);

View File

@@ -3,12 +3,8 @@ package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.utils.DisplayUtils;
import fun.ogre.ogredupealias.utils.PlayerUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.data.type.Snow;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;

View File

@@ -1,23 +1,19 @@
package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.data.Config;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.*;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.Objects;

View File

@@ -1,7 +1,9 @@
package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.plugin.funitems.*;
import fun.ogre.ogredupealias.utils.*;
import fun.ogre.ogredupealias.utils.PlayerUtils;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
@@ -11,7 +13,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;

View File

@@ -168,6 +168,13 @@ public abstract class ItemPresets {
.customModelData(1111)
.build();
public static ItemStack RAILGUN = ItemBuilder.create()
.material(Material.DIAMOND_HORSE_ARMOR)
.name("Railgun")
.lore(Text.color("&7- Another funny gadget!"))
.customModelData(1111)
.build();
public static ItemStack BLANK = ItemBuilder.create()
.material(Material.LIGHT_GRAY_STAINED_GLASS_PANE)
.name(" ")

View File

@@ -2,7 +2,6 @@ package fun.ogre.ogredupealias.plugin.custom.forging;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;

View File

@@ -1,7 +1,7 @@
package fun.ogre.ogredupealias.plugin.custom.forging;
import fun.ogre.ogredupealias.utils.ServerUtils;
import fun.ogre.ogredupealias.plugin.RecipientList;
import fun.ogre.ogredupealias.utils.ServerUtils;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

View File

@@ -8,12 +8,9 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.awt.*;
public final class StoreGUI {
public static final ItemStack knightItem = new ItemStack(ItemBuilder.create()
.material(Material.LIGHT_BLUE_WOOL)

View File

@@ -1,6 +1,7 @@
package fun.ogre.ogredupealias.plugin.custom.items;
import fun.ogre.ogredupealias.plugin.custom.items.customitems.LazerItem;
import fun.ogre.ogredupealias.plugin.custom.items.customitems.RailgunItem;
import fun.ogre.ogredupealias.plugin.custom.items.customitems.TazerItem;
import fun.ogre.ogredupealias.utils.ItemUtils;
import org.bukkit.event.EventHandler;
@@ -19,6 +20,7 @@ public final class CustomItems implements Listener {
public static void init() {
register(new TazerItem());
register(new LazerItem());
register(new RailgunItem());
}
public static ItemStack register(ItemStack item, CustomItemInteractionCallback interactionCallback) {
@@ -32,6 +34,10 @@ public final class CustomItems implements Listener {
return item.getItem();
}
public static Map<Class<? extends CustomItem>, String> getRegistries() {
return new HashMap<>(namesList);
}
public static void onInteract(ItemStack item, PlayerInteractEvent event) {
String nbt = ItemUtils.nbtOf(item);
if (callbackList.containsKey(nbt)) {

View File

@@ -0,0 +1,81 @@
package fun.ogre.ogredupealias.plugin.custom.items.customitems;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.plugin.custom.items.CustomItem;
import fun.ogre.ogredupealias.plugin.custom.items.CustomItemInteractionCallback;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.*;
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.Display;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Transformation;
import org.joml.AxisAngle4f;
import org.joml.Vector3f;
import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
public class RailgunItem extends CustomItem {
public RailgunItem() {
super("railgun", ItemPresets.RAILGUN);
}
@Override
public CustomItemInteractionCallback getCallback() {
return (player, item, event) -> {
Location loc = player.getLocation();
Location eye = player.getEyeLocation();
World world = player.getWorld();
Location end = RaycastUtils.raycast(eye, loc.getDirection(), 100, 0.5, point -> {
boolean hitBlock = !point.getBlock().isPassable();
boolean hitEntity = !world.getNearbyEntities(point, 3, 3, 3, entity -> {
return entity instanceof LivingEntity le && !le.isDead() && le != player && le.getBoundingBox().contains(point.toVector());
}).isEmpty();
return hitBlock || hitEntity;
});
Particle.DustOptions dust = new Particle.DustOptions(Color.AQUA, 10F);
world.spawnParticle(Particle.REDSTONE, end, 30, 0, 0, 0, 1, dust);
float dist = (float)loc.distance(end);
float rad = 0.02F;
AxisAngle4f angle = new AxisAngle4f(0F, 0F, 0F, 1F);
Vector3f translation = new Vector3f(-0.05F, -0.2F, 0F);
BlockDisplay beam = world.spawn(eye, BlockDisplay.class, entity -> {
SoundPlayer sound = new SoundPlayer(loc, Sound.BLOCK_BEACON_POWER_SELECT, 5.0F, 10.0F);
Vector3f scale = new Vector3f(rad, rad, 0F);
Transformation transformation = new Transformation(translation, angle, scale, angle);
entity.setBrightness(new Display.Brightness(15, 15));
entity.setViewRange(dist);
entity.setRotation(eye.getYaw(), eye.getPitch());
entity.setBlock(Material.DIAMOND_BLOCK.createBlockData());
entity.setTransformation(transformation);
sound.playWithin(500);
Bukkit.getScheduler().runTaskLater(instance, entity::remove, 60);
});
Bukkit.getScheduler().runTaskLater(instance, () -> {
Vector3f scale = new Vector3f(rad, rad, dist);
Transformation transformation = new Transformation(translation, angle, scale, angle);
beam.setInterpolationDelay(0);
beam.setInterpolationDuration((int)(dist / 2));
beam.setTransformation(transformation);
}, 5);
Bukkit.getScheduler().runTaskLater(instance, () -> {
Vector3f scale = new Vector3f(rad, rad, 0.0F);
Transformation transformation = new Transformation(translation, angle, scale, angle);
world.createExplosion(end, 3, false, false, player);
beam.setInterpolationDelay(0);
beam.setInterpolationDuration(20);
beam.setTransformation(transformation);
}, 40);
};
}
}

View File

@@ -7,11 +7,9 @@ import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.*;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Bed;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;

View File

@@ -1,16 +1,16 @@
package fun.ogre.ogredupealias.plugin.funitems;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.events.EntityDamageListener;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.*;
import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.*;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;

View File

@@ -8,12 +8,10 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
@@ -21,7 +19,6 @@ import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class Pickler implements Listener {
public static void handlePickler(PlayerInteractEvent e) {

View File

@@ -5,8 +5,6 @@ import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import fun.ogre.ogredupealias.utils.Text;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@@ -16,11 +14,11 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PotatoCannon implements Listener {

View File

@@ -1,18 +1,15 @@
package fun.ogre.ogredupealias.plugin.funitems;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.PlayerUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;

View File

@@ -1,28 +1,21 @@
package fun.ogre.ogredupealias.plugin.funitems;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.events.EntityDamageListener;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.*;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.Random;
import static org.bukkit.event.block.Action.*;
public class SnowChinegun {

View File

@@ -1,6 +1,5 @@
package fun.ogre.ogredupealias.utils;
import com.google.common.collect.ObjectArrays;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;

View File

@@ -1,13 +1,10 @@
package fun.ogre.ogredupealias.utils;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.data.BlockStorage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,6 +1,8 @@
package fun.ogre.ogredupealias.utils;
import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public final class MathUtils {

View File

@@ -6,7 +6,6 @@ import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.List;

View File

@@ -78,6 +78,10 @@ commands:
permission: oda.command.givecustom
aliases:
- givec
customitem:
description: Gives custom items
usage: /customitem <customitem>
permission: oda.command.givecustom
config:
description: Config management
usage: /config [get|set] <path> <datatype> <value>