Initial commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<?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">
|
||||
<parent>
|
||||
<artifactId>ProjectCranked</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>StarItems</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<artifactId>Utils</artifactId>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Armor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Masks</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>Leaderboards</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.golfing.wineSpigot</groupId>
|
||||
<artifactId>winespigot</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../.lib/WineSpigot-V1.7.4.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crankedpvp</groupId>
|
||||
<artifactId>StorageUtilsShaded</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/../StorageUtils/target/StorageUtils-1.0-shaded.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,201 @@
|
||||
package net.crankedpvp.staritems;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTCompound;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import net.crankedpvp.crankedutils.utils.HookUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.staritems.inventory.StarItemsInventory;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class StarItemsAPI {
|
||||
|
||||
public static final ItemStack starItemExtractor = buildStarItemExtractor();
|
||||
|
||||
private static ItemStack buildStarItemExtractor() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.FEATHER, "&6&lStar Item Extractor",
|
||||
"&7Drag n Drop onto an item that",
|
||||
"&7has a star item equipped to",
|
||||
"&7remove the star item from it");
|
||||
NBTItem nbtItem = new NBTItem(itemBuilder.colorize().build());
|
||||
nbtItem.setString("crankedCustomItem", "starItemExtractor");
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public static boolean playerHasStarItemEquipped(Player player) {
|
||||
return Objects.requireNonNull(getPlayersEquippedStarItems(player)).size() > 0;
|
||||
}
|
||||
|
||||
public static List<StarItem> getPlayersEquippedStarItems(Player player) {
|
||||
List<StarItem> starItems = new ArrayList<>();
|
||||
for(ItemStack armorContent : player.getInventory().getArmorContents()) {
|
||||
if(!itemHasStarItemEquipped(armorContent)) continue;
|
||||
if(isFounderStar(armorContent)) {
|
||||
return new ArrayList<>(StarItemsPlugin.getInstance().getStarItemManager().getStarItems());
|
||||
}
|
||||
starItems.add(getEquippedStarItem(armorContent));
|
||||
}
|
||||
return starItems;
|
||||
}
|
||||
|
||||
private static boolean isFounderStar(ItemStack itemStack) {
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasNBTData()) return false;
|
||||
return nbtItem.getString("starItem").equals("founderStar");
|
||||
}
|
||||
|
||||
public static StarItem getEquippedStarItem(ItemStack itemStack) {
|
||||
if(!itemHasStarItemEquipped(itemStack)) return null;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
return StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID(nbtItem.getString("starItem"));
|
||||
}
|
||||
|
||||
public static boolean itemHasStarItemEquipped(ItemStack itemStack) {
|
||||
if(itemStack == null || itemStack.getType() == Material.AIR) return false;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasNBTData()) return false;
|
||||
return nbtItem.hasKey("starItem");
|
||||
}
|
||||
|
||||
public static boolean isStarItem(ItemStack itemStack) {
|
||||
if(itemStack == null) return false;
|
||||
if(itemStack.getType() == Material.AIR) return false;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasNBTData()) return false;
|
||||
if(!nbtItem.hasKey("cosmicType")) return false;
|
||||
if(!nbtItem.getString("cosmicType").equals("staritem")) return false;
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("cosmicData");
|
||||
if(nbtCompound == null) return false;
|
||||
if(!StarItemsPlugin.getInstance().getStarItemManager().isStarItem(nbtCompound.getString("starItemType"))) return false;
|
||||
StarItem starItem = StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID(nbtCompound.getString("starItemType"));
|
||||
return starItem != null;
|
||||
}
|
||||
|
||||
public static StarItem getStarItemFromItemStack(ItemStack itemStack) {
|
||||
if(!isStarItem(itemStack)) return null;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
NBTCompound nbtCompound = nbtItem.getCompound("cosmicData");
|
||||
if(nbtCompound == null) return null;
|
||||
if(!StarItemsPlugin.getInstance().getStarItemManager().isStarItem(nbtCompound.getString("starItemType"))) return null;
|
||||
return StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID(nbtCompound.getString("starItemType"));
|
||||
}
|
||||
|
||||
public static void refreshStarItemForPlayer(Player player) {
|
||||
if(!playerHasStarItemEquipped(player)) {
|
||||
StarItemsPlugin.getInstance().getStarItemManager().removeFromCacheCompletely(player);
|
||||
return;
|
||||
}
|
||||
List<StarItem> starItems = getPlayersEquippedStarItems(player);
|
||||
StarItemsPlugin.getInstance().getStarItemManager().addToCache(player, starItems);
|
||||
}
|
||||
|
||||
public static List<StarItem> getStarItemFromCache(Player player) {
|
||||
Map<Player, List<StarItem>> cachedPlayers = StarItemsPlugin.getInstance().getStarItemManager().getCachedPlayers();
|
||||
if(!cachedPlayers.containsKey(player)) return new ArrayList<>();
|
||||
return cachedPlayers.get(player);
|
||||
}
|
||||
|
||||
public static boolean playerHasStarItemInCache(Player player) {
|
||||
return StarItemsPlugin.getInstance().getStarItemManager().getCachedPlayers().containsKey(player);
|
||||
}
|
||||
|
||||
public static boolean playerHasStarItem(Player player, StarItem starItem) {
|
||||
if(!playerHasStarItemInCache(player)) return false;
|
||||
return getStarItemFromCache(player).contains(starItem);
|
||||
}
|
||||
|
||||
public static boolean playerHasStarItem(Player player, String starItemString) {
|
||||
StarItem starItem = StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID(starItemString);
|
||||
if(starItem == null) return false;
|
||||
if(!playerHasStarItem(player, starItem)) return false;
|
||||
return getStarItemFromCache(player).contains(starItem);
|
||||
}
|
||||
|
||||
public static boolean isStarItemExtractor(ItemStack itemStack) {
|
||||
if(itemStack == null) return false;
|
||||
if(itemStack.getType() == Material.AIR) return false;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasNBTData()) return false;
|
||||
return nbtItem.getString("crankedCustomItem").equals("starItemExtractor");
|
||||
}
|
||||
|
||||
public static ItemStack buildGoldenKnife() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.GOLD_SWORD);
|
||||
itemBuilder.setDurability((short) 31);
|
||||
itemBuilder.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1000);
|
||||
itemBuilder.setName("&8» &6&lThe Golden Knife &8«");
|
||||
itemBuilder.setLore(
|
||||
"",
|
||||
"&fVanquish the soul of anything that",
|
||||
"&fyou strike, in a fair exchange for",
|
||||
"&fthis divine blade.",
|
||||
"",
|
||||
"&7&oThis item is Unrepairable"
|
||||
);
|
||||
NBTItem nbtItem = new NBTItem(itemBuilder.colorize().build());
|
||||
nbtItem.setString("crankedCustomItem", "goldenKnife");
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public static ItemStack buildHook() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.DIAMOND_HOE, "&8» &b&lThe Diamond Hook &8«");
|
||||
itemBuilder.addEnchantment(Enchantment.DAMAGE_ALL, 5);
|
||||
itemBuilder.addEnchantment(Enchantment.DURABILITY, 3);
|
||||
return HookUtils.applyHookData(itemBuilder.colorize().build());
|
||||
}
|
||||
|
||||
public static boolean isGoldenKnife(ItemStack itemStack) {
|
||||
if(ItemUtils.isAirOrNull(itemStack)) return false;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasKey("crankedCustomItem")) return false;
|
||||
return nbtItem.getString("crankedCustomItem").equals("goldenKnife");
|
||||
}
|
||||
|
||||
public static boolean isDeathNote(ItemStack itemStack) {
|
||||
if(ItemUtils.isAirOrNull(itemStack)) return false;
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
if(!nbtItem.hasKey("crankedCustomItem")) return false;
|
||||
return nbtItem.getString("crankedCustomItem").equals("deathNote");
|
||||
}
|
||||
|
||||
public static void addItemToStarItemsUI(ItemStack itemStack) {
|
||||
StarItemsPlugin.getInstance().getStarItemsInventory().getUI().addItem(new GuiItem(itemStack, event -> {
|
||||
if(event.getWhoClicked().hasPermission("cranked.admin")) {
|
||||
event.getWhoClicked().getInventory().addItem(event.getCurrentItem().clone());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public static StarItemsInventory getStarItemsUI() {
|
||||
return StarItemsPlugin.getInstance().getStarItemsInventory();
|
||||
}
|
||||
|
||||
|
||||
public static ItemStack buildDeathNote() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(Material.PAPER);
|
||||
itemBuilder.setName("&8» &8&lDeath Note &8«");
|
||||
itemBuilder.setLore(
|
||||
"",
|
||||
"&7One death granted from the shingami world.",
|
||||
"",
|
||||
"&fChoose the player you wish to",
|
||||
"&fvanquish by typing their name",
|
||||
"&fafter using this divine note.",
|
||||
"",
|
||||
"&7&oThis item has ONE use."
|
||||
);
|
||||
NBTItem nbtItem = new NBTItem(itemBuilder.colorize().build());
|
||||
nbtItem.setString("crankedCustomItem", "deathNote");
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package net.crankedpvp.staritems;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.mattstudios.mf.base.CommandManager;
|
||||
import me.mattstudios.mf.base.components.TypeResult;
|
||||
import net.crankedpvp.staritems.abilities.IceTrapAbility;
|
||||
import net.crankedpvp.staritems.commands.*;
|
||||
import net.crankedpvp.staritems.inventory.StarItemsInventory;
|
||||
import net.crankedpvp.staritems.listeners.*;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import net.crankedpvp.staritems.struct.StarItemManager;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StarItemsPlugin extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static StarItemsPlugin instance;
|
||||
|
||||
public static String prefix = "&d&lStar Items &8➥ ";
|
||||
|
||||
@Getter
|
||||
private StarItemManager starItemManager;
|
||||
@Getter
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Getter
|
||||
private IceTrapAbility iceTrapAbility;
|
||||
|
||||
@Getter
|
||||
private StarItemsInventory starItemsInventory;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.starItemManager = new StarItemManager(this);
|
||||
this.starItemManager.initialize();
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.registerCommandCompletion();
|
||||
this.registerCommandParameters();
|
||||
this.commandManager.register(new DeathNoteCommand(this), new StarItemsAdminCommand(this), new StarItemsCommand(this), new GoldenKnifeCommand(this), new GoldenKnifeInventoryViewCommand());
|
||||
this.registerListeners();
|
||||
|
||||
/*
|
||||
new ChromaPacketTask(this).runTaskTimer(this, 20L, 20L);
|
||||
new PrismaPacketTask(this).runTaskTimer(this, 20L, 20L);
|
||||
new FounderStarPacketTask(this).runTaskTimer(this, 20L, 20L);
|
||||
new RainbowArmorTask().runTaskTimer(this, 2L, 20L);
|
||||
|
||||
*/
|
||||
|
||||
this.iceTrapAbility = new IceTrapAbility(this);
|
||||
|
||||
this.starItemsInventory = new StarItemsInventory();
|
||||
StarItemsAPI.addItemToStarItemsUI(StarItemsAPI.buildGoldenKnife());
|
||||
//StarItemsAPI.addItemToStarItemsUI(StarItemsAPI.buildHook());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
private void registerListeners() {
|
||||
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||
pluginManager.registerEvents(new PlayerListener(this), this);
|
||||
pluginManager.registerEvents(new ApplyStarItemListener(this), this);
|
||||
pluginManager.registerEvents(new PotionAddListener(), this);
|
||||
pluginManager.registerEvents(new ApplyStarItemExtractorListener(this), this);
|
||||
pluginManager.registerEvents(new PacketListeners(this), this);
|
||||
pluginManager.registerEvents(new GoldenKnifeListener(), this);
|
||||
pluginManager.registerEvents(new DeathNoteListener(this), this);
|
||||
}
|
||||
|
||||
|
||||
private void registerCommandParameters() {
|
||||
this.commandManager.getParameterHandler().register(StarItem.class, argument -> {
|
||||
StarItem armorSet = this.starItemManager.getStarItemFromID(this.starItemManager.getStarItemIDFromName(String.valueOf(argument)));
|
||||
return new TypeResult(armorSet, argument);
|
||||
});
|
||||
}
|
||||
|
||||
private void registerCommandCompletion() {
|
||||
this.commandManager.getCompletionHandler().register("#staritems", input -> this.starItemManager.getStarItems().stream().map(StarItem::getID).collect(Collectors.toList()));
|
||||
this.commandManager.getCompletionHandler().register("#boolean", input -> Arrays.asList("true", "false"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.crankedpvp.staritems.abilities;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.PlayerUtils;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class IceTrapAbility {
|
||||
|
||||
private final static int ABILITY_DURATION = 4;
|
||||
|
||||
private final Map<Player, Location> playersAffected;
|
||||
|
||||
private final StarItemsPlugin plugin;
|
||||
public IceTrapAbility(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.playersAffected = Maps.newConcurrentMap();
|
||||
}
|
||||
|
||||
public void procAbility(Player sender, Player affected) {
|
||||
this.procAbility(sender, affected, "&bFrostbite");
|
||||
}
|
||||
|
||||
public void procAbility(Player sender, Player affected, String reason) {
|
||||
PlayerUtils.teleportPlayerToClosestLocation(affected);
|
||||
this.setSurroundingBlocksToIce(affected);
|
||||
for(Player nearbyPlayer : PlayerUtils.getNearbyPlayers(affected, 10)) {
|
||||
nearbyPlayer.sendMessage(CC.translate("&6&lStar Items &8" + Arrow.arrow() + " " + reason + " &7has been activated by &c" + sender.getName() + "&7!"));
|
||||
}
|
||||
this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> this.finishAbility(affected), ABILITY_DURATION * 20L);
|
||||
}
|
||||
|
||||
public void finishAbility(Player affected) {
|
||||
this.setSurroundingBlocksToAir(affected);
|
||||
affected.sendMessage(CC.translate("&6&lStar Items &8" + Arrow.arrow() + " &7You are no longer affected by the &bFrostbite &7ability"));
|
||||
}
|
||||
|
||||
public void setSurroundingBlocksToAir(Player player) {
|
||||
Location eyeLoc = this.playersAffected.get(player);
|
||||
this.playersAffected.remove(player);
|
||||
Block block = eyeLoc.getBlock();
|
||||
if(block.getRelative(BlockFace.NORTH).getType() == Material.ICE) block.getRelative(BlockFace.NORTH).setType(Material.AIR);
|
||||
if(block.getRelative(BlockFace.EAST).getType() == Material.ICE) block.getRelative(BlockFace.EAST).setType(Material.AIR);
|
||||
if(block.getRelative(BlockFace.SOUTH).getType() == Material.ICE) block.getRelative(BlockFace.SOUTH).setType(Material.AIR);
|
||||
if(block.getRelative(BlockFace.WEST).getType() == Material.ICE) block.getRelative(BlockFace.WEST).setType(Material.AIR);
|
||||
if(block.getRelative(BlockFace.UP).getType() == Material.ICE) block.getRelative(BlockFace.UP).setType(Material.AIR);
|
||||
}
|
||||
|
||||
public void setSurroundingBlocksToIce(Player player) {
|
||||
Location eyeLoc = player.getEyeLocation();
|
||||
this.playersAffected.put(player, eyeLoc);
|
||||
Block block = eyeLoc.getBlock();
|
||||
if(block.getRelative(BlockFace.NORTH).getType() == Material.AIR) block.getRelative(BlockFace.NORTH).setType(Material.ICE);
|
||||
if(block.getRelative(BlockFace.EAST).getType() == Material.AIR) block.getRelative(BlockFace.EAST).setType(Material.ICE);
|
||||
if(block.getRelative(BlockFace.SOUTH).getType() == Material.AIR) block.getRelative(BlockFace.SOUTH).setType(Material.ICE);
|
||||
if(block.getRelative(BlockFace.WEST).getType() == Material.AIR) block.getRelative(BlockFace.WEST).setType(Material.ICE);
|
||||
if(block.getRelative(BlockFace.UP).getType() == Material.AIR) block.getRelative(BlockFace.UP).setType(Material.ICE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.crankedpvp.staritems.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("deathnote")
|
||||
@Alias("dnote")
|
||||
public class DeathNoteCommand extends CommandBase {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public DeathNoteCommand(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
@Permission("cranked.admin")
|
||||
public void defaultCommand(final CommandSender commandSender, @Optional @Completion("#players") Player receiver) {
|
||||
if(receiver == null && commandSender instanceof Player) {
|
||||
receiver = (Player) commandSender;
|
||||
}
|
||||
assert receiver != null;
|
||||
receiver.getInventory().addItem(StarItemsAPI.buildDeathNote());
|
||||
receiver.sendMessage(CC.translate("&6&lStar Items &8" + Arrow.arrow() + " &7You have received the &4&lDeath Note"));
|
||||
receiver.playSound(receiver.getLocation(), Sound.CHICKEN_EGG_POP, 2.0f, 2.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.crankedpvp.staritems.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("goldenknife")
|
||||
@Alias("gknife")
|
||||
public class GoldenKnifeCommand extends CommandBase {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public GoldenKnifeCommand(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
@Permission("cranked.admin")
|
||||
public void defaultCommand(final CommandSender commandSender, @Optional @Completion("#players") Player receiver) {
|
||||
if(receiver == null && commandSender instanceof Player) {
|
||||
receiver = (Player) commandSender;
|
||||
}
|
||||
assert receiver != null;
|
||||
receiver.getInventory().addItem(StarItemsAPI.buildGoldenKnife());
|
||||
receiver.sendMessage(CC.translate("&6&lStar Items &8" + Arrow.arrow() + " &7You have received the &6&lGolden Knife"));
|
||||
receiver.playSound(receiver.getLocation(), Sound.CHICKEN_EGG_POP, 2.0f, 2.0f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package net.crankedpvp.staritems.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Default;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.staritems.listeners.GoldenKnifeListener;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Command("goldenknifedeathinventoryview")
|
||||
public class GoldenKnifeInventoryViewCommand extends CommandBase {
|
||||
|
||||
@Default
|
||||
public void openInventory(final Player sender, String uuid) {
|
||||
UUID playerUUID = UUID.fromString(uuid);
|
||||
if(!GoldenKnifeListener.inventories.containsKey(playerUUID)) return;
|
||||
GoldenKnifeListener.inventories.get(playerUUID).getGui().open(sender);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package net.crankedpvp.staritems.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.*;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.PlayerUtils;
|
||||
import net.crankedpvp.crankedutils.utils.SoundUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("csi")
|
||||
@Alias("crankedstaritems")
|
||||
public class StarItemsAdminCommand extends CommandBase {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public StarItemsAdminCommand(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
@Permission("cranked.admin")
|
||||
public void defaultCommand(final CommandSender commandSender) {
|
||||
sendHelp(commandSender);
|
||||
}
|
||||
|
||||
@SubCommand("help")
|
||||
@Permission("cranked.admin")
|
||||
public void helpCommand(final CommandSender commandSender) {
|
||||
sendHelp(commandSender);
|
||||
}
|
||||
|
||||
@SubCommand("give")
|
||||
@Permission("cranked.admin")
|
||||
public void giveCommand(final CommandSender commandSender, @Completion("#staritems") String staritem, @Optional @Completion("#players") Player player) {
|
||||
if(player == null) {
|
||||
if(!(commandSender instanceof Player)) {
|
||||
commandSender.sendMessage(CC.translate("&cUsage: /csi give <staritem> [player]"));
|
||||
return;
|
||||
}
|
||||
player = (Player)commandSender;
|
||||
}
|
||||
|
||||
if(!this.plugin.getStarItemManager().isStarItem(staritem)) {
|
||||
commandSender.sendMessage(CC.translate(StarItemsPlugin.prefix + "&cThis is not a registered star item"));
|
||||
SoundUtils.tryPlayErrorSound(commandSender);
|
||||
return;
|
||||
}
|
||||
|
||||
StarItem starItem = this.plugin.getStarItemManager().getStarItemFromID(staritem);
|
||||
PlayerUtils.giveOrDropProtectedItem(player, starItem.buildItem(), 15);
|
||||
player.sendMessage(CC.translate(StarItemsPlugin.prefix + "&aYou have received a " + starItem.getDisplayName() + " &afrom " + commandSender.getName()));
|
||||
player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 2.0F, 2.0F);
|
||||
}
|
||||
|
||||
private void sendHelp(final CommandSender commandSender) {
|
||||
commandSender.sendMessage(CC.translate(""));
|
||||
commandSender.sendMessage(CC.translate("&c&lStar Items"));
|
||||
commandSender.sendMessage(CC.translate("&c* &f/csi give <staritem> [player]"));
|
||||
commandSender.sendMessage(CC.translate("&c* &f/csi extractor [player]"));
|
||||
SoundUtils.playSoundIfPlayer(commandSender, Sound.LAVA_POP);
|
||||
}
|
||||
|
||||
@SubCommand("debug")
|
||||
@Permission("cranked.admin")
|
||||
public void debugCommand(final CommandSender commandSender, @Optional @Completion("#players") Player player) {
|
||||
if(player == null) player = (Player) commandSender;
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
|
||||
@SubCommand("extractor")
|
||||
@Permission("cranked.admin")
|
||||
public void extractorCommand(final CommandSender commandSender, @Optional @Completion("#players") Player player) {
|
||||
if(player == null) {
|
||||
if(commandSender instanceof Player) {
|
||||
player = (Player) commandSender;
|
||||
} else {
|
||||
commandSender.sendMessage("&cYou must choose a player to give the item to");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().addItem(StarItemsAPI.starItemExtractor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.crankedpvp.staritems.commands;
|
||||
|
||||
import me.mattstudios.mf.annotations.Alias;
|
||||
import me.mattstudios.mf.annotations.Command;
|
||||
import me.mattstudios.mf.annotations.Default;
|
||||
import me.mattstudios.mf.base.CommandBase;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.inventory.StarItemsInventory;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Command("staritems")
|
||||
@Alias("staritem")
|
||||
public class StarItemsCommand extends CommandBase {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public StarItemsCommand(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void defaultCommand(final Player player) {
|
||||
this.plugin.getStarItemsInventory().getUI().open(player);
|
||||
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 2.0F, 2.0F);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class DirtyBombCooldown extends CurrentCooldown {
|
||||
public DirtyBombCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class EyeBandageHealCooldown extends CurrentCooldown {
|
||||
public EyeBandageHealCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class FrostBiteCooldown extends CurrentCooldown {
|
||||
public FrostBiteCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class GloopGetawayCooldown extends CurrentCooldown {
|
||||
public GloopGetawayCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class HotPotatoCooldown extends CurrentCooldown {
|
||||
public HotPotatoCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class PhoenixAbilityCooldown extends CurrentCooldown {
|
||||
public PhoenixAbilityCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class SantasPieAbility extends CurrentCooldown {
|
||||
public SantasPieAbility() {
|
||||
super("santas_beard_pie_eater_ability", 120);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class SantasPresentAbility extends CurrentCooldown {
|
||||
public SantasPresentAbility() {
|
||||
super("santas_beard_present_ability", 20);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.crankedpvp.staritems.cooldowns;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.cache.cooldown.CurrentCooldown;
|
||||
|
||||
public class ShackleAbilityCooldown extends CurrentCooldown {
|
||||
public ShackleAbilityCooldown(String name, int durationInSeconds) {
|
||||
super(name, durationInSeconds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.crankedpvp.staritems.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import dev.triumphteam.gui.guis.PaginatedGui;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class GoldenKnivedInventory {
|
||||
@Getter
|
||||
private final PaginatedGui gui;
|
||||
public GoldenKnivedInventory(Player toView) {
|
||||
this.gui = new PaginatedGui(5, 54, toView.getName() + "'s Inventory");
|
||||
this.gui.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
ItemStack[] items = toView.getInventory().getContents();
|
||||
for (int i = 0; i < 36; i++) {
|
||||
if (items[i] != null)
|
||||
gui.setItem(i, new GuiItem(items[i]));
|
||||
}
|
||||
gui.setItem(36, getFillterItem());
|
||||
gui.setItem(37, getFillterItem());
|
||||
gui.setItem(40, getFillterItem());
|
||||
gui.setItem(43, getFillterItem());
|
||||
gui.setItem(44, getFillterItem());
|
||||
|
||||
PlayerInventory oldInv = toView.getInventory();
|
||||
if (oldInv.getHelmet() != null)
|
||||
gui.setItem(38, new GuiItem( oldInv.getHelmet()));
|
||||
if (oldInv.getChestplate() != null)
|
||||
gui.setItem(39, new GuiItem(oldInv.getChestplate()));
|
||||
if (oldInv.getLeggings() != null)
|
||||
gui.setItem(41, new GuiItem(oldInv.getLeggings()));
|
||||
if (oldInv.getBoots() != null)
|
||||
gui.setItem(42, new GuiItem(oldInv.getBoots()));
|
||||
}
|
||||
|
||||
public GuiItem getFillterItem() {
|
||||
return new GuiItem(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (byte)7, "&7 ").colorize().build());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.crankedpvp.staritems.inventory;
|
||||
|
||||
import dev.triumphteam.gui.guis.Gui;
|
||||
import dev.triumphteam.gui.guis.GuiItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.HookUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class StarItemsInventory {
|
||||
|
||||
private final Gui starItemsInventory;
|
||||
|
||||
public Gui getUI() {
|
||||
return this.starItemsInventory;
|
||||
}
|
||||
|
||||
Collection<StarItem> starItems = StarItemsPlugin.getInstance().getStarItemManager().getStarItems();
|
||||
|
||||
public StarItemsInventory() {
|
||||
this.starItemsInventory = new Gui(6, "Cranked Star Items");
|
||||
this.starItemsInventory.setDefaultClickAction(event -> event.setCancelled(true));
|
||||
this.starItemsInventory.getFiller().fillBorder(new GuiItem(createFillerItem()));
|
||||
this.starItemsInventory.updateItem(6, 5, new GuiItem(createExitItem(), event -> event.getWhoClicked().closeInventory()));
|
||||
this.starItemsInventory.updateItem(1, 5, new GuiItem(createInformationItem()));
|
||||
|
||||
for(StarItem starItem : starItems) {
|
||||
this.starItemsInventory.addItem(new GuiItem(starItem.buildItem(), event -> {
|
||||
if(event.getWhoClicked().hasPermission("cranked.admin")) event.getWhoClicked().getInventory().addItem(starItem.buildItem());
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ItemStack createExitItem() {
|
||||
ItemStack item = new ItemStack(Material.BED);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(CC.translate("&cExit Star Items Menu"));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack createInformationItem() {
|
||||
return new ItemBuilder(Material.BOOK, "&d&lStar Items",
|
||||
"&7Star Items are physical, applyable",
|
||||
"&7items which exhibit a visual override.",
|
||||
"",
|
||||
"&7They can only be applied to",
|
||||
"&7helmets, however are very powerful."
|
||||
)
|
||||
.colorize().build();
|
||||
}
|
||||
|
||||
private ItemStack createFillerItem() {
|
||||
ItemStack item = new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.GRAY.getData());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(" ");
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.InventoryClickUtils;
|
||||
import net.crankedpvp.crankedutils.utils.InventoryUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ApplyStarItemExtractorListener implements Listener {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public ApplyStarItemExtractorListener(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event) {
|
||||
if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) return;
|
||||
if(event.getCursor() == null || event.getCursor().getType() == Material.AIR) return;
|
||||
|
||||
//if(event.isCancelled()) return;
|
||||
//if (event.getClickedInventory() != event.getWhoClicked().getInventory()) return;
|
||||
|
||||
ItemStack cursor = event.getCursor();
|
||||
if(!StarItemsAPI.isStarItemExtractor(event.getCursor())) return;
|
||||
//if (event.getClickedInventory() != event.getWhoClicked().getOpenInventory().getBottomInventory()) return;
|
||||
if(!InventoryClickUtils.canClickItem(event)) return;
|
||||
StarItem starItem = StarItemsAPI.getEquippedStarItem(event.getCurrentItem());
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if(starItem == null) {
|
||||
player.sendMessage(CC.translate(StarItemsPlugin.prefix + "&cThis item does not have a star item equipped"));
|
||||
return;
|
||||
}
|
||||
if(!InventoryUtils.hasAvaliableSlot(player, 1)) {
|
||||
player.sendMessage(CC.translate(StarItemsPlugin.prefix + "&cYou do not have enough inventory slots to extract a star item"));
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.getInventory().addItem(starItem.buildItem());
|
||||
event.setCursor(ItemUtils.decreaseItemStackAmountByOne(cursor));
|
||||
event.setCurrentItem(starItem.unapply(event.getCurrentItem()));
|
||||
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.InventoryClickUtils;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.leaderboards.LeaderboardsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ApplyStarItemListener implements Listener {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public ApplyStarItemListener(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryClick(InventoryClickEvent event) {
|
||||
if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) return;
|
||||
if(event.getCursor() == null || event.getCursor().getType() == Material.AIR) return;
|
||||
|
||||
//if(event.isCancelled()) return;
|
||||
//if (event.getClickedInventory() != event.getWhoClicked().getInventory()) return;
|
||||
|
||||
ItemStack cursor = event.getCursor();
|
||||
if(!StarItemsAPI.isStarItem(cursor)) return;
|
||||
//if (event.getClickedInventory() != event.getWhoClicked().getOpenInventory().getBottomInventory()) return;
|
||||
if(!InventoryClickUtils.canClickItem(event)) return;
|
||||
StarItem starItem = StarItemsAPI.getStarItemFromItemStack(cursor);
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
assert starItem != null;
|
||||
if(!event.getCurrentItem().getType().name().endsWith(starItem.getArmorType().name())) {
|
||||
//if(starItem.getArmorTypes().stream().map(armorType -> armorType.name().toUpperCase(Locale.ROOT)).noneMatch(string -> event.getCurrentItem().getType().name().endsWith(string))) {
|
||||
player.sendMessage(CC.translate(StarItemsPlugin.prefix + "&cThis star item cannot be applied to this item type"));
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, 2.0F, 2.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
if(StarItemsAPI.itemHasStarItemEquipped(event.getCurrentItem())) {
|
||||
player.sendMessage(CC.translate(StarItemsPlugin.prefix + "&cThis item already has a star item equipped"));
|
||||
player.playSound(player.getLocation(), Sound.ANVIL_LAND, 2.0F, 2.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCursor(ItemUtils.decreaseItemStackAmountByOne(cursor));
|
||||
event.setCurrentItem(starItem.apply(event.getCurrentItem()));
|
||||
player.updateInventory();
|
||||
LeaderboardsAPI.getPlayerStats(player.getUniqueId()).incrementStarItemsApplied();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
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.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeathNoteListener implements Listener {
|
||||
|
||||
public static List<Player> deathNoted = new ArrayList<>();
|
||||
|
||||
private final StarItemsPlugin plugin;
|
||||
public DeathNoteListener(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
if(event.getPlayer() == null || event.getMessage() == null) return;
|
||||
if(!deathNoted.contains(event.getPlayer())) return;
|
||||
Player chosen = Bukkit.getPlayer(event.getMessage());
|
||||
if(chosen == null) {
|
||||
this.sendMessage(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
if(!chosen.isOnline()) {
|
||||
this.sendMessage(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
if(chosen.getUniqueId().equals(event.getPlayer().getUniqueId())) {
|
||||
this.sendMessage(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
deathNoted.remove(event.getPlayer());
|
||||
chosen.setHealth(0);
|
||||
|
||||
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage("");
|
||||
event.getPlayer().sendMessage(CC.translate("&8&lDeath Note &8" + Arrow.arrow() + " &7The player &c" + chosen.getName() + " &7has been vanquished by the &8Death Note"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void sendMessage(Player player) {
|
||||
player.sendMessage(CC.translate("&8&lDeath Note &8" + Arrow.arrow() + " &7Choose a player's name and vanquish their soul..."));
|
||||
player.sendMessage(CC.translate("&8&lDeath Note &8" + Arrow.arrow() + " &7Enter the name of any online player to instantly kill them: "));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if(event.getPlayer() == null || ItemUtils.isAirOrNull(event.getItem())) return;
|
||||
if(event.getAction() != Action.RIGHT_CLICK_AIR || event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||
|
||||
ItemStack itemStack = event.getPlayer().getItemInHand();
|
||||
if(!StarItemsAPI.isDeathNote(itemStack)) return;
|
||||
event.getPlayer().setItemInHand(null);
|
||||
deathNoted.add(event.getPlayer());
|
||||
event.getPlayer().sendMessage("");
|
||||
event.getPlayer().sendMessage(CC.translate("&8&lDeath Note &8" + Arrow.arrow() + " &7Choose a player's name and vanquish their soul..."));
|
||||
event.getPlayer().sendMessage(CC.translate("&8&lDeath Note &8" + Arrow.arrow() + " &7Enter the name of any online player to instantly kill them: "));
|
||||
event.getPlayer().sendMessage("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.*;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.inventory.GoldenKnivedInventory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GoldenKnifeListener implements Listener {
|
||||
|
||||
public static Map<UUID, GoldenKnivedInventory> inventories = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onIncomingDamage(EntityDamageByEntityEvent event) {
|
||||
if(!(event.getDamager() instanceof Player)) return;
|
||||
Player attacker = (Player) event.getDamager();
|
||||
ItemStack knife = attacker.getItemInHand();
|
||||
if(ItemUtils.isAirOrNull(knife)) return;
|
||||
if(!StarItemsAPI.isGoldenKnife(knife)) return;
|
||||
if(!(event.getEntity() instanceof Player)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
if(!WorldGuardUtils.canPvPInRegion(victim)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(FactionUtils.inSameFaction(attacker, victim)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
inventories.put(victim.getUniqueId(), new GoldenKnivedInventory(victim));
|
||||
event.setCancelled(true);
|
||||
attacker.setItemInHand(null);
|
||||
victim.setHealth(0);
|
||||
victim.playSound(victim.getLocation(), Sound.ITEM_BREAK, 2.0f, 2.0f);
|
||||
attacker.playSound(attacker.getLocation(), Sound.ITEM_BREAK, 2.0f, 2.0f);
|
||||
Clickable clickable = new Clickable(StringUtils.getCenteredMessage("&8» &e&l" + victim.getName() + "'s Inventory &8«"), "&eClick to view &6" + victim.getName() + "'s &edeath inventory", "/goldenknifedeathinventoryview " + victim.getUniqueId());
|
||||
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
onlinePlayer.sendMessage(StringUtils.getCenteredMessage(CC.translate("&e" + attacker.getName() + " &6has slain &e" + victim.getName())));
|
||||
onlinePlayer.sendMessage(StringUtils.getCenteredMessage(CC.translate("&eusing &8» &6&lThe Golden Knife &8«")));
|
||||
clickable.sendToPlayer(onlinePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PacketListeners implements Listener {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public PacketListeners(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if(event.getPlayer() == null) return;
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
|
||||
for(StarItem starItem : StarItemsAPI.getStarItemFromCache(event.getPlayer())) {
|
||||
if(starItem instanceof Chroma) {
|
||||
ChromaPacketTask.playersWithChromaEquipped.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet());
|
||||
} else if(starItem instanceof Prisma) {
|
||||
PrismaPacketTask.playersWithPrismaEquipped.put(event.getPlayer(), event.getPlayer().getInventory().getChestplate());
|
||||
} else if(starItem instanceof FounderStar) {
|
||||
FounderStarPacketTask.playersWithFounderStarEquipped.put(event.getPlayer(), event.getPlayer().getInventory().getHelmet());
|
||||
}
|
||||
}
|
||||
}, 40L);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
if(event.getPlayer() == null) return;
|
||||
for(StarItem starItem : StarItemsAPI.getStarItemFromCache(event.getPlayer())) {
|
||||
if(starItem instanceof Chroma) {
|
||||
ChromaPacketTask.playersWithChromaEquipped.remove(event.getPlayer());
|
||||
} else if(starItem instanceof Prisma) {
|
||||
PrismaPacketTask.playersWithPrismaEquipped.remove(event.getPlayer());
|
||||
} else if(starItem instanceof FounderStar) {
|
||||
FounderStarPacketTask.playersWithFounderStarEquipped.remove(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void armorChangeEvent(ArmorEquipEvent event) {
|
||||
|
||||
if (event.getOldArmorPiece() != null && event.getOldArmorPiece().getType() != Material.AIR) {
|
||||
if (StarItemsAPI.itemHasStarItemEquipped(event.getOldArmorPiece())) {
|
||||
StarItem starItem = StarItemsAPI.getEquippedStarItem(event.getOldArmorPiece().clone());
|
||||
if(starItem instanceof Chroma) {
|
||||
ChromaPacketTask.playersWithChromaEquipped.remove(event.getPlayer());
|
||||
} else if(starItem instanceof Prisma) {
|
||||
PrismaPacketTask.playersWithPrismaEquipped.remove(event.getPlayer());
|
||||
} else if(starItem instanceof FounderStar) {
|
||||
FounderStarPacketTask.playersWithFounderStarEquipped.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (event.getNewArmorPiece() != null && event.getNewArmorPiece().getType() != Material.AIR) {
|
||||
if (StarItemsAPI.itemHasStarItemEquipped(event.getNewArmorPiece())) {
|
||||
StarItem starItem = StarItemsAPI.getEquippedStarItem(event.getNewArmorPiece());
|
||||
if(starItem instanceof Chroma) {
|
||||
ChromaPacketTask.playersWithChromaEquipped.put(event.getPlayer(), event.getNewArmorPiece().clone());
|
||||
} else if(starItem instanceof Prisma) {
|
||||
PrismaPacketTask.playersWithPrismaEquipped.put(event.getPlayer(), event.getNewArmorPiece().clone());
|
||||
} else if(starItem instanceof FounderStar) {
|
||||
FounderStarPacketTask.playersWithFounderStarEquipped.put(event.getPlayer(), event.getNewArmorPiece().clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.events.ArmorEquipEvent;
|
||||
import net.crankedpvp.crankedutils.utils.WorldGuardUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
private StarItemsPlugin plugin;
|
||||
public PlayerListener(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void placeStarItem(PlayerInteractEvent event) {
|
||||
if(event.getItem() == null || event.getItem().getType() == Material.AIR) return;
|
||||
if(StarItemsAPI.isStarItem(event.getItem())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(this.plugin, () -> StarItemsAPI.refreshStarItemForPlayer(event.getPlayer()), 30L);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
if (event.getEntity() != null) {
|
||||
StarItemsPlugin.getInstance().getStarItemManager().removeFromCacheCompletely(event.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onArmorChange(ArmorEquipEvent event) {
|
||||
if (event.getOldArmorPiece() != null && event.getOldArmorPiece().getType() != Material.AIR) {
|
||||
if (StarItemsAPI.itemHasStarItemEquipped(event.getOldArmorPiece())) {
|
||||
StarItem starItem = StarItemsAPI.getEquippedStarItem(event.getOldArmorPiece());
|
||||
assert starItem != null;
|
||||
starItem.onUnequip(event.getPlayer());
|
||||
//StarItemsPlugin.getInstance().getStarItemManager().getCachedPlayers().remove(event.getPlayer());
|
||||
StarItemsPlugin.getInstance().getStarItemManager().removeFromCache(event.getPlayer(), starItem);
|
||||
}
|
||||
}
|
||||
if (event.getNewArmorPiece() != null && event.getNewArmorPiece().getType() != Material.AIR) {
|
||||
if (StarItemsAPI.itemHasStarItemEquipped(event.getNewArmorPiece())) {
|
||||
StarItem starItem = StarItemsAPI.getEquippedStarItem(event.getNewArmorPiece());
|
||||
assert starItem != null;
|
||||
starItem.onEquip(event.getPlayer());
|
||||
StarItemsPlugin.getInstance().getStarItemManager().addToCache(event.getPlayer(), starItem);
|
||||
//StarItemsPlugin.getInstance().getStarItemManager().getCachedPlayers().put(event.getPlayer(), starItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerReceiveDamage(EntityDamageByEntityEvent event) {
|
||||
Entity damager = event.getDamager();
|
||||
Entity victim = event.getEntity();
|
||||
if (victim instanceof Player) {
|
||||
Player player = (Player) victim;
|
||||
if(!StarItemsAPI.playerHasStarItemInCache(player)) return;
|
||||
List<StarItem> starItems = StarItemsAPI.getStarItemFromCache(player);
|
||||
if(starItems == null || starItems.size() == 0) return;
|
||||
if (!WorldGuardUtils.canPvPInRegion(victim.getLocation()) || !WorldGuardUtils.canPvPInRegion(damager.getLocation())) return;
|
||||
for(StarItem starItem : starItems)
|
||||
starItem.onIncomingDamage(player, damager, event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerSendDamage(EntityDamageByEntityEvent event) {
|
||||
Entity damager = event.getDamager();
|
||||
Entity victim = event.getEntity();
|
||||
if (damager instanceof Player) {
|
||||
Player player = (Player) damager;
|
||||
if(!StarItemsAPI.playerHasStarItemInCache(player)) return;
|
||||
List<StarItem> starItems = StarItemsAPI.getStarItemFromCache(player);
|
||||
if(starItems == null || starItems.size() == 0) return;
|
||||
if (!WorldGuardUtils.canPvPInRegion(victim.getLocation()) || !WorldGuardUtils.canPvPInRegion(damager.getLocation())) return;
|
||||
for(StarItem starItem : starItems)
|
||||
starItem.onOutgoingDamage(player, victim, event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.crankedpvp.staritems.listeners;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PotionEffectAddEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class PotionAddListener implements Listener {
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPotionEffectWithBlurredSoaker(PotionEffectAddEvent event) {
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
Player player = ((Player) event.getEntity());
|
||||
if (StarItemsAPI.getStarItemFromCache(player) == null) return;
|
||||
if(Objects.requireNonNull(StarItemsAPI.getStarItemFromCache(player)).contains(StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID("blurredsoaker"))) {
|
||||
if(!player.getLocation().getBlock().isLiquid()) return;
|
||||
if (PotionEffectUtils.getDebuffsList().contains(event.getEffect().getType()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if(Objects.requireNonNull(StarItemsAPI.getStarItemFromCache(player)).contains(StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID("angelboots"))) {
|
||||
if (PotionEffectUtils.getDebuffsList().contains(event.getEffect().getType()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
if (Objects.requireNonNull(StarItemsAPI.getStarItemFromCache(player)).contains(StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID("detioratedgolem"))) {
|
||||
if (PotionEffectUtils.getDebuffsList().contains(event.getEffect().getType()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
*/
|
||||
|
||||
if (Objects.requireNonNull(StarItemsAPI.getStarItemFromCache(player)).contains(StarItemsPlugin.getInstance().getStarItemManager().getStarItemFromID("blackoutblindfold"))) {
|
||||
if(player.hasPotionEffect(PotionEffectType.BLINDNESS))
|
||||
player.removePotionEffect(PotionEffectType.BLINDNESS);
|
||||
if(event.getEffect().getType() != PotionEffectType.BLINDNESS) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Absence extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Absence";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SNOW_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SNOW_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&b&lAbsence";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe absence of sound or noise...",
|
||||
"&fDo not allow yourself to be silenced",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("-25% Silence Duration", "+5% Outgoing Damage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(5, event, "Absence");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AngelBoots extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Angel Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.GOLD_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.GOLD_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&b&lAngel Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fA developed pair of boots",
|
||||
"&fwhich allow for faster, cleaner",
|
||||
"&fmovement throughout the warzone",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV Effect", "Auto Bless", "-3% Incoming Damage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.BOOTS;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Angel Boots");
|
||||
PotionEffectUtils.bless(player);
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Angel Boots");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().reduceDamage(3, event, "Angel Boots");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlackoutBlindfold extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Blackout Blindfold";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.IRON_PLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.IRON_PLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&c&lBlackout Blindfold";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fA pitch-black blindfold that",
|
||||
"&fenlightens your body",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Immune to blindness",
|
||||
"+35% Silence Duration",
|
||||
"50% Chance to block galactic visor phoenix"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEquip(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequip(Player player) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlurredSoaker extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Blurred Soaker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SPONGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SPONGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&b&lBlurred Soaker";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fControl the power of this infinitely",
|
||||
"&fsoaking sponge and conquer with it.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"+15% Damage while in water",
|
||||
"Immune to new debuffs while in water"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
if(attacker.getLocation().getBlock().isLiquid())
|
||||
super.getDamageHandler().increaseDamage(15, event, "BlurredSoaker");
|
||||
}
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.bless(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Combo extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Combo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.RAW_FISH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.GOLD_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&e&lCombo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fWe used to like this.. now we do not.",
|
||||
"&fThe yellow pufferfish, it needs to go.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Immune to Titan Pet",
|
||||
"Immune to Spider Pet",
|
||||
"Rage Enchantment deals +25% more damage",
|
||||
"Deal +7.5% more damage to enemies wielding hooks"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(7.5, event, "BlurredSoaker");
|
||||
}
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.crankedutils.utils.TitleUtils;
|
||||
import net.crankedpvp.staritems.cooldowns.ShackleAbilityCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DeterioratedGolem extends StarItem {
|
||||
|
||||
private final static double ABILITY_CHANCE = 0.05;
|
||||
private final static int ABILITY_DURATION = 3;
|
||||
private final static int ABILITY_COOLDOWN = 120;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Deteriorated Golem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.IRON_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.IRON_BLOCK;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&7&lDeteriorated Golem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe golem is a piece of art.",
|
||||
"&fHowever its strengths are never",
|
||||
"&fto be undermined..",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"-10% Incoming damage from enemy players",
|
||||
"Negative potion effects have a chance to heal you",
|
||||
"Shackle Ability"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().reduceDamage(10, event, this.getName());
|
||||
if (event.isCancelled()) return;
|
||||
if(Math.random() > ABILITY_CHANCE) return;
|
||||
if (CooldownUtils.isCooldownActive(victim, "shackleAbility")) return;
|
||||
CooldownUtils.registerCooldown(victim, new ShackleAbilityCooldown("shackleAbility", ABILITY_COOLDOWN));
|
||||
|
||||
Player att = (Player) attacker;
|
||||
att.setWalkSpeed(0.0F);
|
||||
PotionEffectUtils.addPotionEffect(att, PotionEffectType.JUMP, 129, "shackleAbility", ABILITY_DURATION);
|
||||
att.playSound(att.getLocation(), Sound.PISTON_RETRACT, 2.0F, 3.0F);
|
||||
TitleUtils.sendTitle(att, CC.translate("&7&l* SHACKLED *"), CC.translate("&fYou have been shackled in place"), 1, 2, 1);
|
||||
victim.sendMessage(CC.translate("&7&l* SHACKLED (" + att.getName() + ") *"));
|
||||
Bukkit.getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> att.setWalkSpeed(0.2F), ABILITY_DURATION * 20L);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.perms.Relation;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PVPUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.cooldowns.DirtyBombCooldown;
|
||||
import net.crankedpvp.staritems.cooldowns.HotPotatoCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class Discharge extends StarItem implements Listener {
|
||||
|
||||
private final List<Player> hotPotatoPlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Discharge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&4&lD&c&lI&4&lS&c&lC&4&lH&c&lA&4&lR&c&lG&4&lE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fA piece of fragile equipment which",
|
||||
"&fmay detonate at any given moment.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV effect", "+5% Outgoing Damage", "Hot Potato Ability", "Dirty Bomb Ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Discharge");
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Discharge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(5, event, "Discharge");
|
||||
if(this.hotPotatoPlayers.contains(attacker)) super.getDamageHandler().increaseDamage(10, event, "HotPotato");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(event.isCancelled() || event.getFinalDamage() <= 0) return;
|
||||
tryProcDirtyBombAbility(victim);
|
||||
tryProcHotPotatoAbility(victim);
|
||||
}
|
||||
}
|
||||
|
||||
private void tryProcHotPotatoAbility(Player victim) {
|
||||
if(Math.random() > 0.02) return;
|
||||
if (CooldownUtils.isCooldownActive(victim, "hotPotatoAbility")) return;
|
||||
CooldownUtils.registerCooldown(victim, new HotPotatoCooldown("hotPotatoAbility", 90));
|
||||
PotionEffectUtils.addPotionEffect(victim, PotionEffectType.SPEED, 5, "hotPotatoAbility", 5);
|
||||
this.hotPotatoPlayers.add(victim);
|
||||
Bukkit.getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> this.hotPotatoPlayers.remove(victim), 5 * 20L);
|
||||
victim.sendMessage(CC.translate("&c&lDischarge &8➥ &eYour have became a &cHot Potato&e, strike while it lasts."));
|
||||
}
|
||||
|
||||
public void tryProcDirtyBombAbility(Player player) {
|
||||
if(Math.random() > 0.02) return;
|
||||
if (CooldownUtils.isCooldownActive(player, "dirtyBombAbility")) return;
|
||||
CooldownUtils.registerCooldown(player, new DirtyBombCooldown("dirtyBombAbility", 120));
|
||||
for(int i = 0; i < ThreadLocalRandom.current().nextInt(3, 6); i++) {
|
||||
this.spawnExplosion(player, this.getNearbyLocation(player.getLocation(), 10, 8), 2*20);
|
||||
//super.getStarItemsPlugin().getServer().getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> this.spawnExplosion(player, this.getNearbyLocation(player.getLocation(), 10, 8), 6), 25L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority= EventPriority.LOWEST)
|
||||
public void onBlockExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntity() != null && event.getEntity().hasMetadata("DirtyBombTNT")) {
|
||||
event.setYield(0.0f);
|
||||
event.blockList().clear();
|
||||
if (!PVPUtils.canPvPInRegion(event.getLocation())) return;
|
||||
Location loc = event.getLocation();
|
||||
loc.getWorld().playSound(loc, Sound.EXPLODE, 1.0f, 1.0f);
|
||||
|
||||
String exploder = event.getEntity().getMetadata("DirtyBombTNT").get(0).asString();
|
||||
Player pExploder = Bukkit.getPlayer(exploder);
|
||||
FPlayer fp = pExploder != null ? FPlayers.getInstance().getByPlayer(pExploder) : null;
|
||||
for (Entity ent : event.getEntity().getNearbyEntities(6, 6, 6)) {
|
||||
if(!(ent instanceof Player)) continue;
|
||||
if(fp == null) continue;
|
||||
if(!fp.getRelationTo(FPlayers.getInstance().getByPlayer((Player) ent)).isAtLeast(Relation.TRUCE)) continue;
|
||||
if(!PVPUtils.canPvPInRegion(ent.getLocation())) continue;
|
||||
Player loopPlayer = (Player)ent;
|
||||
loopPlayer.sendMessage(CC.translate("&c&lDischarge &8➥ &eYou have been struck by a &cDirty Bomb"));
|
||||
loopPlayer.setFireTicks(40);
|
||||
loopPlayer.damage(8.0);
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.EXPLODE, 1.0F, 1.0F);
|
||||
PotionEffectUtils.addPotionEffect(loopPlayer, PotionEffectType.SLOW, 4, "DirtyBomb", 3);
|
||||
}
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnExplosion(Player exploder, Location location, int fuseTicks) {
|
||||
if (location.getBlock().getType().isSolid()) {
|
||||
return;
|
||||
}
|
||||
TNTPrimed tnt = (TNTPrimed)location.getWorld().spawnEntity(location, EntityType.PRIMED_TNT);
|
||||
tnt.setFuseTicks(fuseTicks);
|
||||
tnt.setMetadata("DirtyBombTNT", new FixedMetadataValue(StarItemsPlugin.getInstance(), exploder.getName()));
|
||||
}
|
||||
|
||||
private Location getNearbyLocation(Location location, int radius, int y_boost) {
|
||||
Random rand = new Random();
|
||||
Location rand_loc = location.clone();
|
||||
rand_loc.add((rand.nextBoolean() ? 1 : -1) * (rand.nextInt(radius) + 1), 0.0, (rand.nextBoolean() ? 1 : -1) * (rand.nextInt(radius) + 1));
|
||||
rand_loc.add(0.5, y_boost, 0.5);
|
||||
while ((rand_loc.getBlock().getType() != Material.AIR || rand_loc.getBlock().getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() != Material.AIR) && rand_loc.getY() < 255.0) {
|
||||
rand_loc = rand_loc.add(0.0, 1.0, 0.0);
|
||||
}
|
||||
return rand_loc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Frostbite extends StarItem {
|
||||
|
||||
private final static double ABILITY_CHANCE = 0.01;
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Frostbite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&9&lFrostbite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fHarness the power of indestructible ice.",
|
||||
"&fProtect yourself with layers of ice",
|
||||
"&fand trap others in it's path",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"-10% Incoming damage from enemies in water",
|
||||
"Immune to Divine Immolation",
|
||||
"Water Polaroid Ability"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(victim.getLocation().getBlock().isLiquid())
|
||||
super.getDamageHandler().reduceDamage(10, event, "Frostbite");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Player)) return;
|
||||
if (event.isCancelled()) return;
|
||||
if(Math.random() > ABILITY_CHANCE) return;
|
||||
Player victimPlayer = (Player)victim;
|
||||
super.getStarItemsPlugin().getIceTrapAbility().procAbility(attacker, victimPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedarmor.CrankedArmor;
|
||||
import net.crankedpvp.crankedarmor.CrankedArmorAPI;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.cooldowns.PhoenixAbilityCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GalacticVisor extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Galactic Visor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.STAINED_GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.STAINED_GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&5&lGalactic Visor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fBecome one with space, this visor",
|
||||
"&fguides you through the cosmoverse.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("75% Holy White Scroll Negation", "Phoenix Ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (event.isCancelled()) return;
|
||||
if(victim.getHealth() < 5) {
|
||||
if(Math.random() > 0.2) return;
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
if(CooldownUtils.isCooldownActive(victim, "PhoenixAbility")) return;
|
||||
CooldownUtils.registerCooldown(victim, new PhoenixAbilityCooldown("PhoenixAbility", 120));
|
||||
if(Objects.equals(CrankedArmorAPI.getCurrentArmorSet(attackingPlayer), CrankedArmor.getInstance().getArmorSetRegister().getArmorSetFromID("draco"))) {
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &cYour phoenix ability has been &nblocked&r &cby " + attackingPlayer.getName() + "'s draco set"));
|
||||
victim.playSound(victim.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
attackingPlayer.sendMessage(CC.translate("&c&lDraco &8➥ &eYour draco set has &c&lBLOCKED &e" + victim.getName() + "'s phoenix ability"));
|
||||
return;
|
||||
}
|
||||
if(StarItemsAPI.playerHasStarItemInCache(attackingPlayer)) {
|
||||
if(StarItemsAPI.getStarItemFromCache(attackingPlayer).contains(super.getStarItemsPlugin().getStarItemManager().getStarItemFromID("blackoutblindfold"))) {
|
||||
if(Math.random() < 0.5) {
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &cYour phoenix ability has been &nblocked&r &cby " + attackingPlayer.getName() + "'s blackout blindfold"));
|
||||
victim.playSound(victim.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
victim.setHealth(victim.getMaxHealth());
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &eYour phoenix ability has &a&lHEALED &eyou to full health"));
|
||||
victim.playSound(victim.getLocation(), Sound.GHAST_DEATH, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.crankedutils.utils.TitleUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.cooldowns.GloopGetawayCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GloopGetaway extends StarItem implements Listener {
|
||||
|
||||
private final List<Player> gloopGetawayAbility = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Gloop Getaway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SLIME_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SLIME_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&a&lGloop Getaway";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fAn informal variation of the slime",
|
||||
"&fthat allows you to passively escape",
|
||||
"&fat low HP",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("10% Holy White Scroll Negation", "Immune to fall damage", "Slime Fall Ability", "Gloop Getaway Ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
if(!this.gloopGetawayAbility.contains(attacker)) return;
|
||||
super.getDamageHandler().increaseDamage(10, event, "SlimeFallAbility");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(!(attacker instanceof Player)) return;
|
||||
if (event.isCancelled()) return;
|
||||
if (CooldownUtils.isCooldownActive(victim, "gloopGetawayAbility")) return;
|
||||
if(victim.getHealth() > victim.getMaxHealth() / 4) return;
|
||||
if(Math.random() > 0.05) return;
|
||||
CooldownUtils.registerCooldown(victim, new GloopGetawayCooldown("gloopGetawayAbility", 90));
|
||||
victim.setVelocity(new Vector(0, 12, 0));
|
||||
PotionEffectUtils.addPotionEffect(victim, PotionEffectType.REGENERATION, 3, "GloopGetawayAbility", 3);
|
||||
TitleUtils.sendTitle(victim, CC.translate("&a&lGloop Getaway"), CC.translate("&7&oIt's your time to escape..."), 1, 2, 1);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onJoinEvent(final PlayerJoinEvent event) {
|
||||
if(event.getPlayer() == null) return;
|
||||
this.gloopGetawayAbility.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamageEvent(final EntityDamageEvent event) {
|
||||
if(!(event.getEntity() instanceof Player)) return;
|
||||
final Player player = (Player) event.getEntity();
|
||||
if(event.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
if(!StarItemsAPI.playerHasStarItemInCache(player)) return;
|
||||
if(!StarItemsAPI.getStarItemFromCache(player).contains(this)) return;
|
||||
event.setCancelled(true);
|
||||
if(Math.random() < 0.01) {
|
||||
this.gloopGetawayAbility.add(player);
|
||||
Bukkit.getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> this.gloopGetawayAbility.remove(player), 5 * 20L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.staritems.cooldowns.EyeBandageHealCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GoldenEyeBandage extends StarItem {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Golden Eye Bandage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.GOLD_PLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.GOLD_PLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lGolden Eye Bandage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fWhat is preventing your eye from healing?",
|
||||
"&fThis will speed up it's process.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"15% Chance to negate enemy holy white scrolls",
|
||||
"Chance to heal +4HP when hit"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(Math.random() > 0.02) return;
|
||||
if (event.isCancelled()) return;
|
||||
if(CooldownUtils.isCooldownActive(victim, "eyebandagehealcooldown")) return;
|
||||
CooldownUtils.registerCooldown(victim, new EyeBandageHealCooldown("eyebandagehealcooldown", 20));
|
||||
super.getDamageHandler().healEntity(victim, 4, "Golden Eye Bandage");
|
||||
victim.sendMessage(CC.translate("&6&lEye Bandage &8➥ &eYou have been healed by your eye bandage &7(&a+4HP&7)"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class HermesBoots extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Hermes Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.DIAMOND_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.DIAMOND_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lHermes Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fAn underdeveloped pair of boots",
|
||||
"&fwhich allow for faster, cleaner",
|
||||
"&fmovement throughout the warzone",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV Effect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.BOOTS;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Hermes Boots");
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Hermes Boots");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedarmor.CrankedArmor;
|
||||
import net.crankedpvp.crankedarmor.CrankedArmorAPI;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class IgnitedHolograph extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Ignited Holograph";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.JACK_O_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.JACK_O_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lIgnited Holograph";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fIt may scare you at first, but",
|
||||
"&fit holds immense power and must",
|
||||
"&fnot be looked past",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Immune to spider pet",
|
||||
"+12.5% Outgoing damage to burning enemies"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
Player playerVictim = (Player) victim;
|
||||
if(playerVictim.getFireTicks() <= 0) return;
|
||||
if(Objects.equals(CrankedArmorAPI.getCurrentArmorSet(playerVictim), CrankedArmor.getInstance().getArmorSetRegister().getArmorSetFromID("nightmare"))) return;
|
||||
super.getDamageHandler().increaseDamage(15, event, "Ignited Holograph");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Olympus extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Olympus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.BEACON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.BEACON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&3&lO&b&ll&3&ly&b&lm&3&lp&b&lu&3&ls";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe gates of olympus await you...",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"-5.5% Incoming Damage",
|
||||
"+4% Outgoing Damage",
|
||||
"Immune to titan pet",
|
||||
"66% Holy White Scroll Negation"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().reduceDamage(5.5, event, "Olympus");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(4, event, "Olympus");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PortableBard extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Portable Bard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.GOLD_HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lPortable Bard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fHow are you using bard effects",
|
||||
"&fwith a diamond set...? wow.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Ability to use bard buffs", "+25% Incoming Damage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(25, event, this.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.crankedmasks.CrankedMasksAPI;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.cooldowns.SantasPieAbility;
|
||||
import net.crankedpvp.staritems.cooldowns.SantasPresentAbility;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class SantasBeard extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Santas Beard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SNOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SNOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&c&lSantas Beard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe long and fluffy beard",
|
||||
"&floved by all at Christmas",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Bypass Abyss slowness",
|
||||
"Santas Present Ability",
|
||||
" &7&o(Chance to gain positive effects)",
|
||||
"Santas Pie Eater Ability",
|
||||
" &7&o(Chance to gain +6 absorption hearts)"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEquip(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequip(Player player) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(CooldownUtils.isCooldownActive(victim, "santas_beard_pie_eater_ability")) return;
|
||||
CooldownUtils.registerCooldown(victim, new SantasPieAbility());
|
||||
PotionEffectUtils.addExtraPotionEffect(victim, PotionEffectType.ABSORPTION, 3, "santas_beard_pie_eater_ability", 5);
|
||||
victim.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7You ate ALOT of pies, lots of fat, lots of &eabsorption")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Player> damageIncrease = new ArrayList<>();
|
||||
private List<Player> damageDecrease = new ArrayList<>();
|
||||
private List<Player> rageDamage = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Player)) return;
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if(damageIncrease.contains(attacker)) super.getDamageHandler().increaseDamage(5, event, "santas_beard_inc");
|
||||
if(damageDecrease.contains(victim)) super.getDamageHandler().reduceDamage(5, event, "santas_beard_reduc");
|
||||
|
||||
double chance = 0.5D;
|
||||
if(CrankedMasksAPI.hasMaskEquipped(attacker, "santa")) chance *= 2;
|
||||
if(ThreadLocalRandom.current().nextDouble() > chance) return;
|
||||
|
||||
if(CooldownUtils.isCooldownActive(attacker, "santas_beard_present_ability")) return;
|
||||
CooldownUtils.registerCooldown(attacker, new SantasPresentAbility());
|
||||
int num = ThreadLocalRandom.current().nextInt(1, 4);
|
||||
switch(num) {
|
||||
case 1:
|
||||
damageIncrease.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &c+5% outgoing damage")));
|
||||
break;
|
||||
case 2:
|
||||
damageDecrease.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &b-5% incoming damage")));
|
||||
break;
|
||||
case 3:
|
||||
PotionEffectUtils.addPotionEffect(attacker, PotionEffectType.SPEED, 5, "santas_beard_speed", 5);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &aSpeed V")));
|
||||
break;
|
||||
case 4:
|
||||
rageDamage.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &4+10% Rage Damage")));
|
||||
break;
|
||||
}
|
||||
|
||||
this.getStarItemsPlugin().getServer().getScheduler().runTaskLater(this.getStarItemsPlugin(), () -> this.removeFromAll(attacker), 5 * 20L);
|
||||
}
|
||||
|
||||
private void removeFromAll(Player player) {
|
||||
this.rageDamage.remove(player);
|
||||
this.damageDecrease.remove(player);
|
||||
this.damageIncrease.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.crankedpvp.staritems.staritems;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Void extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Void";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SOUL_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SOUL_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&d&lVoid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fConquer the abyss, conquer the void.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Immune to Abyss Enchant", "Bypass Snow Golem Pet", "Deal +7.5% more damage while wielding a hook");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(7.5, event, "Void");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmicAbsence extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Absence";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SNOW_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SNOW_BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&b&lAbsence";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe absence of sound or noise...",
|
||||
"&fDo not allow yourself to be silenced",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("-25% Silence Duration", "+5% Outgoing Damage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(5, event, "Absence");
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmicAngelBoots extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Angel Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.GOLD_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.GOLD_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&b&lAngel Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fA developed pair of boots",
|
||||
"&fwhich allow for faster, cleaner",
|
||||
"&fmovement throughout the warzone",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV Effect", "Auto Bless", "-3% Incoming Damage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.BOOTS;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Angel Boots");
|
||||
PotionEffectUtils.bless(player);
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Angel Boots");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().reduceDamage(3, event, "Angel Boots");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.perms.Relation;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PVPUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.cooldowns.DirtyBombCooldown;
|
||||
import net.crankedpvp.staritems.cooldowns.HotPotatoCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CosmicDischarge extends StarItem implements Listener {
|
||||
|
||||
private final List<Player> hotPotatoPlayers = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Discharge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&4&lD&c&lI&4&lS&c&lC&4&lH&c&lA&4&lR&c&lG&4&lE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fA piece of fragile equipment which",
|
||||
"&fmay detonate at any given moment.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV effect", "+5% Outgoing Damage", "Hot Potato Ability", "Dirty Bomb Ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Discharge");
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Discharge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(5, event, "Discharge");
|
||||
if(this.hotPotatoPlayers.contains(attacker)) super.getDamageHandler().increaseDamage(10, event, "HotPotato");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(event.isCancelled() || event.getFinalDamage() <= 0) return;
|
||||
tryProcDirtyBombAbility(victim);
|
||||
tryProcHotPotatoAbility(victim);
|
||||
}
|
||||
}
|
||||
|
||||
private void tryProcHotPotatoAbility(Player victim) {
|
||||
if(Math.random() > 0.02) return;
|
||||
if (CooldownUtils.isCooldownActive(victim, "hotPotatoAbility")) return;
|
||||
CooldownUtils.registerCooldown(victim, new HotPotatoCooldown("hotPotatoAbility", 90));
|
||||
PotionEffectUtils.addPotionEffect(victim, PotionEffectType.SPEED, 5, "hotPotatoAbility", 5);
|
||||
this.hotPotatoPlayers.add(victim);
|
||||
Bukkit.getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> this.hotPotatoPlayers.remove(victim), 5 * 20L);
|
||||
victim.sendMessage(CC.translate("&c&lDischarge &8➥ &eYour have became a &cHot Potato&e, strike while it lasts."));
|
||||
}
|
||||
|
||||
public void tryProcDirtyBombAbility(Player player) {
|
||||
if(Math.random() > 0.02) return;
|
||||
if (CooldownUtils.isCooldownActive(player, "dirtyBombAbility")) return;
|
||||
CooldownUtils.registerCooldown(player, new DirtyBombCooldown("dirtyBombAbility", 120));
|
||||
for(int i = 0; i < ThreadLocalRandom.current().nextInt(3, 6); i++) {
|
||||
this.spawnExplosion(player, this.getNearbyLocation(player.getLocation(), 10, 8), 2*20);
|
||||
//super.getStarItemsPlugin().getServer().getScheduler().runTaskLater(super.getStarItemsPlugin(), () -> this.spawnExplosion(player, this.getNearbyLocation(player.getLocation(), 10, 8), 6), 25L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority= EventPriority.LOWEST)
|
||||
public void onBlockExplode(EntityExplodeEvent event) {
|
||||
if (event.getEntity() != null && event.getEntity().hasMetadata("DirtyBombTNT")) {
|
||||
event.setYield(0.0f);
|
||||
event.blockList().clear();
|
||||
if (!PVPUtils.canPvPInRegion(event.getLocation())) return;
|
||||
Location loc = event.getLocation();
|
||||
loc.getWorld().playSound(loc, Sound.EXPLODE, 1.0f, 1.0f);
|
||||
|
||||
String exploder = event.getEntity().getMetadata("DirtyBombTNT").get(0).asString();
|
||||
Player pExploder = Bukkit.getPlayer(exploder);
|
||||
FPlayer fp = pExploder != null ? FPlayers.getInstance().getByPlayer(pExploder) : null;
|
||||
for (Entity ent : event.getEntity().getNearbyEntities(6, 6, 6)) {
|
||||
if(!(ent instanceof Player)) continue;
|
||||
if(fp == null) continue;
|
||||
if(!fp.getRelationTo(FPlayers.getInstance().getByPlayer((Player) ent)).isAtLeast(Relation.TRUCE)) continue;
|
||||
if(!PVPUtils.canPvPInRegion(ent.getLocation())) continue;
|
||||
Player loopPlayer = (Player)ent;
|
||||
loopPlayer.sendMessage(CC.translate("&c&lDischarge &8➥ &eYou have been struck by a &cDirty Bomb"));
|
||||
loopPlayer.setFireTicks(40);
|
||||
loopPlayer.damage(8.0);
|
||||
loopPlayer.playSound(loopPlayer.getLocation(), Sound.EXPLODE, 1.0F, 1.0F);
|
||||
PotionEffectUtils.addPotionEffect(loopPlayer, PotionEffectType.SLOW, 4, "DirtyBomb", 3);
|
||||
}
|
||||
event.getEntity().remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnExplosion(Player exploder, Location location, int fuseTicks) {
|
||||
if (location.getBlock().getType().isSolid()) {
|
||||
return;
|
||||
}
|
||||
TNTPrimed tnt = (TNTPrimed)location.getWorld().spawnEntity(location, EntityType.PRIMED_TNT);
|
||||
tnt.setFuseTicks(fuseTicks);
|
||||
tnt.setMetadata("DirtyBombTNT", new FixedMetadataValue(StarItemsPlugin.getInstance(), exploder.getName()));
|
||||
}
|
||||
|
||||
private Location getNearbyLocation(Location location, int radius, int y_boost) {
|
||||
Random rand = new Random();
|
||||
Location rand_loc = location.clone();
|
||||
rand_loc.add((rand.nextBoolean() ? 1 : -1) * (rand.nextInt(radius) + 1), 0.0, (rand.nextBoolean() ? 1 : -1) * (rand.nextInt(radius) + 1));
|
||||
rand_loc.add(0.5, y_boost, 0.5);
|
||||
while ((rand_loc.getBlock().getType() != Material.AIR || rand_loc.getBlock().getLocation().subtract(0.0, 1.0, 0.0).getBlock().getType() != Material.AIR) && rand_loc.getY() < 255.0) {
|
||||
rand_loc = rand_loc.add(0.0, 1.0, 0.0);
|
||||
}
|
||||
return rand_loc;
|
||||
}
|
||||
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.crankedarmor.CrankedArmor;
|
||||
import net.crankedpvp.crankedarmor.CrankedArmorAPI;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.staritems.StarItemsAPI;
|
||||
import net.crankedpvp.staritems.cooldowns.PhoenixAbilityCooldown;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CosmicGalacticVisor extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Galactic Visor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.STAINED_GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.STAINED_GLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&5&lGalactic Visor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fBecome one with space, this visor",
|
||||
"&fguides you through the cosmoverse.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("75% Holy White Scroll Negation", "Phoenix Ability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if (event.isCancelled()) return;
|
||||
if(victim.getHealth() < 5) {
|
||||
if(Math.random() > 0.2) return;
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
if(CooldownUtils.isCooldownActive(victim, "PhoenixAbility")) return;
|
||||
CooldownUtils.registerCooldown(victim, new PhoenixAbilityCooldown("PhoenixAbility", 120));
|
||||
if(Objects.equals(CrankedArmorAPI.getCurrentArmorSet(attackingPlayer), CrankedArmor.getInstance().getArmorSetRegister().getArmorSetFromID("draco"))) {
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &cYour phoenix ability has been &nblocked&r &cby " + attackingPlayer.getName() + "'s draco set"));
|
||||
victim.playSound(victim.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
attackingPlayer.sendMessage(CC.translate("&c&lDraco &8➥ &eYour draco set has &c&lBLOCKED &e" + victim.getName() + "'s phoenix ability"));
|
||||
return;
|
||||
}
|
||||
if(StarItemsAPI.playerHasStarItemInCache(attackingPlayer)) {
|
||||
if(StarItemsAPI.getStarItemFromCache(attackingPlayer).contains(super.getStarItemsPlugin().getStarItemManager().getStarItemFromID("blackoutblindfold"))) {
|
||||
if(Math.random() < 0.5) {
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &cYour phoenix ability has been &nblocked&r &cby " + attackingPlayer.getName() + "'s blackout blindfold"));
|
||||
victim.playSound(victim.getLocation(), Sound.ANVIL_BREAK, 1.0F, 1.0F);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
victim.setHealth(victim.getMaxHealth());
|
||||
victim.sendMessage(CC.translate("&5&lGalactic Visor &8➥ &eYour phoenix ability has &a&lHEALED &eyou to full health"));
|
||||
victim.playSound(victim.getLocation(), Sound.GHAST_DEATH, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmicHermesBoots extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Hermes Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.DIAMOND_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.DIAMOND_BOOTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lHermes Boots";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fAn underdeveloped pair of boots",
|
||||
"&fwhich allow for faster, cleaner",
|
||||
"&fmovement throughout the warzone",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Permanent Speed IV Effect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.BOOTS;
|
||||
}
|
||||
|
||||
public void onEquip(Player player) {
|
||||
PotionEffectUtils.addPotionEffect(player, PotionEffectType.SPEED, 4, "Hermes Boots");
|
||||
}
|
||||
|
||||
public void onUnequip(Player player) {
|
||||
PotionEffectUtils.removePotionEffect(player, "Hermes Boots");
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.crankedarmor.CrankedArmor;
|
||||
import net.crankedpvp.crankedarmor.CrankedArmorAPI;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CosmicIgnitedHolograph extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Ignited Holograph";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.JACK_O_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.JACK_O_LANTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&6&lIgnited Holograph";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fIt may scare you at first, but",
|
||||
"&fit holds immense power and must",
|
||||
"&fnot be looked past",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Immune to spider pet",
|
||||
"+12.5% Outgoing damage to burning enemies"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
Player playerVictim = (Player) victim;
|
||||
if(playerVictim.getFireTicks() <= 0) return;
|
||||
if(Objects.equals(CrankedArmorAPI.getCurrentArmorSet(playerVictim), CrankedArmor.getInstance().getArmorSetRegister().getArmorSetFromID("nightmare"))) return;
|
||||
super.getDamageHandler().increaseDamage(15, event, "Ignited Holograph");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmicOlympus extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Olympus";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.BEACON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.BEACON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&3&lO&b&ll&3&ly&b&lm&3&lp&b&lu&3&ls";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe gates of olympus await you...",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"-3.5% Incoming Damage",
|
||||
"+3% Outgoing Damage",
|
||||
"Immune to titan pet",
|
||||
"66% Holy White Scroll Negation"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
super.getDamageHandler().reduceDamage(3.5, event, "Olympus");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(victim instanceof Player) {
|
||||
super.getDamageHandler().increaseDamage(3, event, "Olympus");
|
||||
}
|
||||
}
|
||||
}
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.crankedmasks.CrankedMasksAPI;
|
||||
import net.crankedpvp.crankedutils.utils.Arrow;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.CooldownUtils;
|
||||
import net.crankedpvp.crankedutils.utils.PotionEffectUtils;
|
||||
import net.crankedpvp.staritems.cooldowns.SantasPieAbility;
|
||||
import net.crankedpvp.staritems.cooldowns.SantasPresentAbility;
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class CosmicSantasBeard extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Santas Beard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SNOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SNOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&c&lSantas Beard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fThe long and fluffy beard",
|
||||
"&floved by all at Christmas",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList(
|
||||
"Bypass Abyss slowness",
|
||||
"Santas Present Ability",
|
||||
" &7&o(Chance to gain positive effects)",
|
||||
"Santas Pie Eater Ability",
|
||||
" &7&o(Chance to gain +6 absorption hearts)"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEquip(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequip(Player player) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker instanceof Player) {
|
||||
if(CooldownUtils.isCooldownActive(victim, "santas_beard_pie_eater_ability")) return;
|
||||
CooldownUtils.registerCooldown(victim, new SantasPieAbility());
|
||||
PotionEffectUtils.addExtraPotionEffect(victim, PotionEffectType.ABSORPTION, 3, "santas_beard_pie_eater_ability", 5);
|
||||
victim.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7You ate ALOT of pies, lots of fat, lots of &eabsorption")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<Player> damageIncrease = new ArrayList<>();
|
||||
private List<Player> damageDecrease = new ArrayList<>();
|
||||
private List<Player> rageDamage = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if(!(victim instanceof Player)) return;
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if(damageIncrease.contains(attacker)) super.getDamageHandler().increaseDamage(5, event, "santas_beard_inc");
|
||||
if(damageDecrease.contains(victim)) super.getDamageHandler().reduceDamage(5, event, "santas_beard_reduc");
|
||||
|
||||
double chance = 0.5D;
|
||||
if(CrankedMasksAPI.hasMaskEquipped(attacker, "santa")) chance *= 2;
|
||||
if(ThreadLocalRandom.current().nextDouble() > chance) return;
|
||||
|
||||
if(CooldownUtils.isCooldownActive(attacker, "santas_beard_present_ability")) return;
|
||||
CooldownUtils.registerCooldown(attacker, new SantasPresentAbility());
|
||||
int num = ThreadLocalRandom.current().nextInt(1, 4);
|
||||
switch(num) {
|
||||
case 1:
|
||||
damageIncrease.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &c+5% outgoing damage")));
|
||||
break;
|
||||
case 2:
|
||||
damageDecrease.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &b-5% incoming damage")));
|
||||
break;
|
||||
case 3:
|
||||
PotionEffectUtils.addPotionEffect(attacker, PotionEffectType.SPEED, 5, "santas_beard_speed", 5);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &aSpeed V")));
|
||||
break;
|
||||
case 4:
|
||||
rageDamage.add(attacker);
|
||||
attacker.sendMessage(CC.translate(CC.translate("&c&lSantas Beard &8" + Arrow.arrow() + " &7Santa dropped a present giving you &4+10% Rage Damage")));
|
||||
break;
|
||||
}
|
||||
|
||||
this.getStarItemsPlugin().getServer().getScheduler().runTaskLater(this.getStarItemsPlugin(), () -> this.removeFromAll(attacker), 5 * 20L);
|
||||
}
|
||||
|
||||
private void removeFromAll(Player player) {
|
||||
this.rageDamage.remove(player);
|
||||
this.damageDecrease.remove(player);
|
||||
this.damageIncrease.remove(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.crankedpvp.staritems.staritems.cosmic;
|
||||
|
||||
import net.crankedpvp.staritems.struct.ArmorType;
|
||||
import net.crankedpvp.staritems.struct.StarItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CosmicVoid extends StarItem {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Void";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getHeldMaterial() {
|
||||
return Material.SOUL_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getVisualMaterial() {
|
||||
return Material.SOUL_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getData() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "&d&lVoid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getLore() {
|
||||
return Arrays.asList(
|
||||
"&fConquer the abyss, conquer the void.",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAbilities() {
|
||||
return Arrays.asList("Immune to Abyss Enchant", "Bypass Snow Golem Pet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorType getArmorType() {
|
||||
return ArmorType.HELMET;
|
||||
}
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {
|
||||
if (victim instanceof Player) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.crankedpvp.staritems.struct;
|
||||
|
||||
public enum ArmorType {
|
||||
HELMET, CHESTPLATE, LEGGINGS, BOOTS, SWORD, AXE, BOW, WEAPON;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package net.crankedpvp.staritems.struct;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTCompound;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.crankedutils.CrankedUtils;
|
||||
import net.crankedpvp.crankedutils.utils.CC;
|
||||
import net.crankedpvp.crankedutils.utils.DamageHandler;
|
||||
import net.crankedpvp.crankedutils.utils.items.ItemBuilder;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class StarItem implements Listener {
|
||||
|
||||
@Getter
|
||||
private final DamageHandler damageHandler;
|
||||
@Getter
|
||||
private final StarItemsPlugin starItemsPlugin;
|
||||
|
||||
public StarItem() {
|
||||
this.damageHandler = CrankedUtils.instance.getDamageHandler();
|
||||
this.starItemsPlugin = StarItemsPlugin.getInstance();
|
||||
}
|
||||
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract Material getHeldMaterial();
|
||||
|
||||
public abstract Material getVisualMaterial();
|
||||
|
||||
public abstract short getData();
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract List<String> getLore();
|
||||
|
||||
public abstract List<String> getAbilities();
|
||||
|
||||
public abstract ArmorType getArmorType();
|
||||
|
||||
public String getID() {
|
||||
return this.getName().toLowerCase(Locale.ROOT).replace(" ", "");
|
||||
}
|
||||
|
||||
|
||||
public void onOutgoingDamage(Player attacker, Entity victim, EntityDamageByEntityEvent event) {}
|
||||
|
||||
public void onIncomingDamage(Player victim, Entity attacker, EntityDamageByEntityEvent event) {}
|
||||
|
||||
public void onEquip(Player player) {}
|
||||
|
||||
public void onUnequip(Player player) {}
|
||||
|
||||
|
||||
|
||||
|
||||
public ItemStack buildItem() {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(this.getHeldMaterial(), 1, getData(), getDisplayName());
|
||||
itemBuilder.setLore(getLore());
|
||||
itemBuilder.addLoreLine("&eAbilities:");
|
||||
getAbilities().forEach(ability -> itemBuilder.addLoreLine(" &f• " + ability));
|
||||
itemBuilder.addLore("", "&7&oAttach this item to any " + getMaterialStringForLore(),
|
||||
"&7&oto give it a visual override!",
|
||||
"",
|
||||
"&7&oTo attach, place this item on a " + getMaterialStringForLore(),
|
||||
"&7&oOnce attached, it cannot be removed!");
|
||||
|
||||
NBTItem wrapper = new NBTItem(itemBuilder.colorize().build());
|
||||
wrapper.setString("cosmicType", "staritem");
|
||||
wrapper.setString("starItemType", this.getID());
|
||||
NBTCompound cosmicData = wrapper.getOrCreateCompound("cosmicData");
|
||||
cosmicData.setString("starItemType", this.getID());
|
||||
return wrapper.getItem();
|
||||
}
|
||||
|
||||
private String getMaterialStringForLore() {
|
||||
return this.isWeapon() ? this.getArmorType().name().toLowerCase(Locale.ROOT) : this.isBow() ? "bow" :
|
||||
(this.getArmorType() == ArmorType.LEGGINGS || this.getArmorType() == ArmorType.BOOTS)
|
||||
? "pair of " + this.getArmorType().name().toLowerCase(Locale.ROOT) :
|
||||
this.getArmorType().name().toLowerCase(Locale.ROOT);
|
||||
|
||||
}
|
||||
|
||||
private boolean isBow() {
|
||||
return this.getArmorType() == ArmorType.BOW;
|
||||
}
|
||||
|
||||
private boolean isWeapon() {
|
||||
return (this.getArmorType() == ArmorType.AXE || this.getArmorType() == ArmorType.SWORD || this.getArmorType() == ArmorType.WEAPON);
|
||||
}
|
||||
|
||||
public ItemStack apply(ItemStack itemStack) {
|
||||
ItemBuilder clickedItem = new ItemBuilder(itemStack);
|
||||
clickedItem.addLore("&f&lSTAR ITEM: " + this.getDisplayName());
|
||||
NBTItem clickedItemNBT = new NBTItem(clickedItem.colorize().build());
|
||||
clickedItemNBT.setString("starItem", this.getID());
|
||||
return clickedItemNBT.getItem();
|
||||
}
|
||||
|
||||
public ItemStack unapply(ItemStack itemStack) {
|
||||
ItemBuilder clickedItem = new ItemBuilder(itemStack);
|
||||
clickedItem.removeLoreLine(CC.translate("&f&lSTAR ITEM: " + this.getDisplayName()));
|
||||
NBTItem clickedItemNBT = new NBTItem(clickedItem.colorize().build());
|
||||
clickedItemNBT.removeKey("starItem");
|
||||
return clickedItemNBT.getItem();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
package net.crankedpvp.staritems.struct;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import lombok.Getter;
|
||||
import net.crankedpvp.staritems.StarItemsPlugin;
|
||||
import net.crankedpvp.staritems.staritems.*;
|
||||
import net.crankedpvp.staritems.staritems.Void;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class StarItemManager {
|
||||
|
||||
private final StarItemsPlugin plugin;
|
||||
private final Map<String, StarItem> starItems;
|
||||
@Getter
|
||||
private final Map<Player, List<StarItem>> cachedPlayers;
|
||||
public StarItemManager(StarItemsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.starItems = Maps.newConcurrentMap();
|
||||
this.cachedPlayers = Maps.newConcurrentMap();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
this.registerAll(
|
||||
new Absence(),
|
||||
new AngelBoots(),
|
||||
new BlackoutBlindfold(),
|
||||
new BlurredSoaker(),
|
||||
new Combo(),
|
||||
new Discharge(),
|
||||
new Frostbite(),
|
||||
new GalacticVisor(),
|
||||
new GloopGetaway(),
|
||||
new GoldenEyeBandage(),
|
||||
new HermesBoots(),
|
||||
new IgnitedHolograph(),
|
||||
new Olympus(),
|
||||
new PortableBard(),
|
||||
new SantasBeard(),
|
||||
new Void()
|
||||
);
|
||||
/*
|
||||
|
||||
this.registerAll(
|
||||
new CosmicAbsence(), new CosmicAngelBoots(), new CosmicDischarge(),
|
||||
new CosmicGalacticVisor(), new CosmicHermesBoots(), new CosmicIgnitedHolograph(),
|
||||
new CosmicOlympus(), new CosmicSantasBeard(), new CosmicVoid()
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
this.registerAll(
|
||||
new Absence(), new Discharge(), new HermesBoots(),
|
||||
new IgnitedHolograph(), new SantasBeard()
|
||||
|
||||
);
|
||||
this.register(new Olympus());
|
||||
this.registerAll(new Void(), new AngelBoots());
|
||||
this.registerAll(new PortableBard(), new Combo());
|
||||
|
||||
this.registerAll(new BlurredSoaker(), new GalacticVisor(), new GloopGetaway(), new GoldenEyeBandage(), new BlackoutBlindfold());
|
||||
|
||||
this.registerAll(new DeterioratedGolem(), new Frostbite());
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public void removeFromCacheCompletely(Player player) {
|
||||
this.cachedPlayers.remove(player);
|
||||
}
|
||||
|
||||
public void addToCache(Player player, List<StarItem> starItems) {
|
||||
this.cachedPlayers.put(player, starItems);
|
||||
}
|
||||
|
||||
public void addToCache(Player player, StarItem starItem) {
|
||||
if(this.cachedPlayers.containsKey(player)) {
|
||||
if(this.cachedPlayers.get(player).size() <= 0) {
|
||||
this.cachedPlayers.put(player, new ArrayList<>(Arrays.asList(starItem)));
|
||||
return;
|
||||
}
|
||||
List<StarItem> starItems = this.cachedPlayers.get(player);
|
||||
if(!starItems.contains(starItem)) starItems.add(starItem);
|
||||
this.cachedPlayers.put(player, starItems);
|
||||
return;
|
||||
}
|
||||
this.cachedPlayers.put(player, new ArrayList<>(Arrays.asList(starItem)));
|
||||
}
|
||||
|
||||
public void removeFromCache(Player player, StarItem starItem) {
|
||||
if(this.cachedPlayers.containsKey(player)) {
|
||||
if(this.cachedPlayers.get(player).contains(starItem)) {
|
||||
List<StarItem> starItems = this.cachedPlayers.get(player);
|
||||
if(starItems.size() == 1) {
|
||||
this.removeFromCacheCompletely(player);
|
||||
return;
|
||||
}
|
||||
starItems.remove(starItem);
|
||||
this.cachedPlayers.put(player, starItems);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.removeFromCacheCompletely(player);
|
||||
}
|
||||
|
||||
public void registerAll(StarItem... starItems) {
|
||||
for (StarItem starItem : starItems) {
|
||||
this.register(starItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void register(StarItem starItem) {
|
||||
try {
|
||||
this.starItems.put(starItem.getID(), starItem);
|
||||
this.plugin.getServer().getPluginManager().registerEvents(starItem, this.plugin);
|
||||
this.plugin.getLogger().info("Successfully registered star item: " + starItem.getID());
|
||||
} catch (Exception e) {
|
||||
this.plugin.getLogger().warning("Failed to register star item: " + starItem.getID());
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterAll() {
|
||||
this.starItems.clear();
|
||||
}
|
||||
|
||||
public void unregister(StarItem starItem) {
|
||||
this.starItems.remove(starItem.getID());
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
this.unregisterAll();
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
public boolean isStarItem(String name) {
|
||||
return (this.getStarItemFromID(name) != null);
|
||||
}
|
||||
|
||||
public StarItem getStarItemFromID(String id) {
|
||||
Validate.notNull(id);
|
||||
Validate.notEmpty(id);
|
||||
return this.starItems.get(id.toLowerCase());
|
||||
}
|
||||
|
||||
public StarItem getStarItemFromName(String name) {
|
||||
Validate.notNull(name);
|
||||
Validate.notEmpty(name);
|
||||
name = this.getStarItemIDFromName(name);
|
||||
return this.starItems.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public String getStarItemIDFromName(String name) {
|
||||
return name.replace(" ", "").toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
public Collection<StarItem> getStarItems() {
|
||||
return Collections.unmodifiableCollection(this.starItems.values());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
name: CrankedStarItems
|
||||
main: net.crankedpvp.staritems.StarItemsPlugin
|
||||
version: ${git.total.commit.count}.0
|
||||
description: "§fCommit ID: §a${git.commit.id.abbrev}"
|
||||
website: https://crankedpvp.net/
|
||||
depend:
|
||||
- CrankedUtils
|
||||
Reference in New Issue
Block a user