First commit
This commit is contained in:
commit
9139dd49cb
|
@ -0,0 +1,3 @@
|
||||||
|
target
|
||||||
|
out
|
||||||
|
.idea
|
|
@ -0,0 +1 @@
|
||||||
|
Sand gun - Gun shooting sand
|
|
@ -0,0 +1,2 @@
|
||||||
|
damage shield - sphere particles as a damage shield
|
||||||
|
particle tail - particle tail following the player
|
|
@ -0,0 +1,71 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>dev.xoy</groupId>
|
||||||
|
<artifactId>xoyShowOff</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>xoy Show Off</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>papermc-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype</id>
|
||||||
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,31 @@
|
||||||
|
package dev.xoy.xoyshowoff;
|
||||||
|
|
||||||
|
import dev.xoy.xoyshowoff.commands.GiveSandArrowCommand;
|
||||||
|
import dev.xoy.xoyshowoff.commands.GiveSandGunCommand;
|
||||||
|
import dev.xoy.xoyshowoff.items.SandGunListener;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public final class XoyShowOff extends JavaPlugin {
|
||||||
|
|
||||||
|
public static final Logger LOGGER = Logger.getLogger("xoyShowOff");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
LOGGER.info("xoyShowOff is now enabled!");
|
||||||
|
getServer().getPluginManager().registerEvents(new SandGunListener(), this);
|
||||||
|
getCommand("givesandgun").setExecutor(new GiveSandGunCommand());
|
||||||
|
getCommand("givesandarrow").setExecutor(new GiveSandArrowCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
LOGGER.info("xoyShowOff is now disabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XoyShowOff getInstance() {
|
||||||
|
return getPlugin(XoyShowOff.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package dev.xoy.xoyshowoff.commands;
|
||||||
|
|
||||||
|
import dev.xoy.xoyshowoff.items.SandArrow;
|
||||||
|
import dev.xoy.xoyshowoff.items.SandGun;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class GiveSandArrowCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
ItemStack stack = new SandArrow();
|
||||||
|
stack.setAmount(16);
|
||||||
|
player.getInventory().addItem(stack);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("This command can only be used by a player.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package dev.xoy.xoyshowoff.commands;
|
||||||
|
|
||||||
|
import dev.xoy.xoyshowoff.items.SandGun;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class GiveSandGunCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
player.getInventory().addItem(new SandGun());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("This command can only be used by a player.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package dev.xoy.xoyshowoff.items;
|
||||||
|
|
||||||
|
import dev.xoy.xoyshowoff.XoyShowOff;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public class Keys {
|
||||||
|
public static final NamespacedKey SANDGUN = new NamespacedKey(XoyShowOff.getInstance(), "SandGun");
|
||||||
|
public static final NamespacedKey SANDARROW = new NamespacedKey(XoyShowOff.getInstance(), "SandArrow");
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package dev.xoy.xoyshowoff.items;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class SandArrow extends ItemStack {
|
||||||
|
public SandArrow() {
|
||||||
|
super(Material.ARROW);
|
||||||
|
ItemMeta meta = getItemMeta();
|
||||||
|
meta.displayName(Component.text("Sand Arrow"));
|
||||||
|
meta.setMaxStackSize(16);
|
||||||
|
meta.getPersistentDataContainer().set(Keys.SANDARROW, PersistentDataType.BOOLEAN, true);
|
||||||
|
setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package dev.xoy.xoyshowoff.items;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class SandGun extends ItemStack{
|
||||||
|
|
||||||
|
public SandGun() {
|
||||||
|
super(Material.BOW);
|
||||||
|
ItemMeta meta = getItemMeta();
|
||||||
|
meta.displayName(Component.text("Sand Gun"));
|
||||||
|
meta.getPersistentDataContainer().set(Keys.SANDGUN, PersistentDataType.BOOLEAN, true);
|
||||||
|
setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package dev.xoy.xoyshowoff.items;
|
||||||
|
|
||||||
|
import dev.xoy.xoyshowoff.XoyShowOff;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class SandGunListener implements Listener {
|
||||||
|
private ItemStack inventoryContainsItemStackWithKey(Player player, NamespacedKey key) {
|
||||||
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
for(ItemStack stack : inventory.getContents()) {
|
||||||
|
if(stack != null && stack.getItemMeta() != null &&
|
||||||
|
stack.getItemMeta().getPersistentDataContainer().has(key)) return stack;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FallingBlock spawnSandEntityWithVelocity(Location location, Vector velocity) {
|
||||||
|
FallingBlock sand = (FallingBlock) location.getWorld().spawnEntity(location, EntityType.FALLING_BLOCK);
|
||||||
|
sand.setBlockData(Material.SAND.createBlockData());
|
||||||
|
sand.setVelocity(velocity);
|
||||||
|
|
||||||
|
return sand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
|
XoyShowOff.LOGGER.info("onEntityShootBow");
|
||||||
|
if(event.getEntity() instanceof Player) {
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
ItemStack bow = event.getBow();
|
||||||
|
if(bow != null && bow.getItemMeta() != null && bow.getItemMeta().getPersistentDataContainer().has(Keys.SANDGUN)) {
|
||||||
|
XoyShowOff.LOGGER.info("isSandGun");
|
||||||
|
ItemStack ammo = inventoryContainsItemStackWithKey(player, Keys.SANDARROW);
|
||||||
|
if(ammo != null) {
|
||||||
|
//ammo.setAmount(ammo.getAmount() - 1);
|
||||||
|
Vector velocity = player.getEyeLocation().getDirection();
|
||||||
|
FallingBlock sand = spawnSandEntityWithVelocity(player.getEyeLocation(), velocity);
|
||||||
|
XoyShowOff.LOGGER.info("Spawned: " + sand.getName());
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
name: xoyShowOff
|
||||||
|
version: '${project.version}'
|
||||||
|
main: dev.xoy.xoyshowoff.XoyShowOff
|
||||||
|
api-version: '1.20'
|
||||||
|
commands:
|
||||||
|
givesandgun:
|
||||||
|
description: Gives the player a Sand Gun.
|
||||||
|
usage: /givesandgun
|
||||||
|
givesandarrow:
|
||||||
|
description: Gives the player a stack Sand Arrows.
|
||||||
|
usage: /givesandarrow
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>PAPER</platformType>
|
||||||
|
<platformType>ADVENTURE</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
<projectReimportVersion>1</projectReimportVersion>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
</module>
|
Loading…
Reference in New Issue