Skip to content

Commit

Permalink
Helmet and head block merging
Browse files Browse the repository at this point in the history
  • Loading branch information
UltraFaceguy committed Apr 18, 2020
1 parent 74a1e05 commit ec82cf9
Show file tree
Hide file tree
Showing 28 changed files with 511 additions and 199 deletions.
22 changes: 22 additions & 0 deletions src/main/java/info/faceland/loot/LootPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import info.faceland.loot.listeners.EnchantDegradeListener;
import info.faceland.loot.listeners.EnchantMenuListener;
import info.faceland.loot.listeners.EntityDeathListener;
import info.faceland.loot.listeners.HeadHelmetsListener;
import info.faceland.loot.listeners.InteractListener;
import info.faceland.loot.listeners.ItemListListener;
import info.faceland.loot.listeners.PawnMenuListener;
Expand Down Expand Up @@ -107,13 +108,16 @@
import land.face.market.data.PlayerMarketState.FilterFlagA;
import land.face.strife.StrifePlugin;
import net.milkbowl.vault.economy.Economy;
import org.black_ixx.playerpoints.PlayerPoints;
import org.black_ixx.playerpoints.PlayerPointsAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import se.ranzdo.bukkit.methodcommand.CommandHandler;

Expand Down Expand Up @@ -161,6 +165,7 @@ public final class LootPlugin extends FacePlugin {
private StrifePlugin strifePlugin;

private Economy economy;
private PlayerPointsAPI playerPointsAPI;

public static LootPlugin getInstance() {
return instance;
Expand Down Expand Up @@ -219,6 +224,7 @@ public void enable() {
scrollManager = new ScrollManager();

setupEconomy();
setupPlayerPoints();

loadItemGroups();
loadCraftBases();
Expand Down Expand Up @@ -255,6 +261,7 @@ public void enable() {
Bukkit.getPluginManager().registerEvents(new EnchantDegradeListener(this), this);
Bukkit.getPluginManager().registerEvents(new EnchantMenuListener(), this);
Bukkit.getPluginManager().registerEvents(new ItemListListener(this), this);
Bukkit.getPluginManager().registerEvents(new HeadHelmetsListener(), this);
Bukkit.getPluginManager().registerEvents(new PawnMenuListener(this), this);
if (potionTriggersEnabled) {
Bukkit.getPluginManager().registerEvents(new SocketsListener(gemCacheManager), this);
Expand All @@ -270,9 +277,20 @@ public void disable() {
HandlerList.unregisterAll(this);
Bukkit.getScheduler().cancelTasks(this);

playerPointsAPI = null;
economy = null;
}

private boolean setupPlayerPoints() {
Plugin ppplugin = Bukkit.getPluginManager().getPlugin("PlayerPoints");
if (ppplugin == null) {
playerPointsAPI = null;
return false;
}
playerPointsAPI = ((PlayerPoints) ppplugin).getAPI();
return true;
}

private boolean setupEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return false;
Expand Down Expand Up @@ -981,6 +999,10 @@ public Economy getEconomy() {
return economy;
}

public PlayerPointsAPI getPlayerPointsAPI() {
return playerPointsAPI;
}

public StrifePlugin getStrifePlugin() {
return strifePlugin;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

import info.faceland.loot.api.items.CustomItem;
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.api.tier.Tier;

import info.faceland.loot.data.JunkItemData;
import info.faceland.loot.enchantments.EnchantmentTome;
import info.faceland.loot.tier.Tier;
import java.util.Map;

public interface CreatureModBuilder {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/info/faceland/loot/api/creatures/MobInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

import info.faceland.loot.api.items.CustomItem;
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.data.JunkItemData;
import info.faceland.loot.enchantments.EnchantmentTome;
import org.bukkit.entity.EntityType;

import info.faceland.loot.tier.Tier;
import java.util.Map;
import org.bukkit.entity.EntityType;

public interface MobInfo {

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/info/faceland/loot/api/groups/ItemGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
*/
package info.faceland.loot.api.groups;

import org.bukkit.Material;

import java.util.Set;
import org.bukkit.Material;

public interface ItemGroup {

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/info/faceland/loot/api/items/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@
*/
package info.faceland.loot.api.items;

import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.data.BuiltItem;
import info.faceland.loot.data.ItemRarity;
import info.faceland.loot.tier.Tier;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

public interface ItemBuilder {
boolean isBuilt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
package info.faceland.loot.api.managers;

import info.faceland.loot.api.groups.ItemGroup;
import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.tier.Tier;
import java.util.Map;
import org.bukkit.Material;

import java.util.Set;
import org.bukkit.Material;

public interface ItemGroupManager {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/info/faceland/loot/api/sockets/SocketGem.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

import info.faceland.loot.api.groups.ItemGroup;
import info.faceland.loot.api.sockets.effects.SocketEffect;
import org.bukkit.inventory.ItemStack;

import java.util.List;
import org.bukkit.inventory.ItemStack;

public interface SocketGem extends Comparable<SocketGem> {

String getName();

double getWeight();
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/info/faceland/loot/api/tier/TierBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

import info.faceland.loot.api.groups.ItemGroup;
import info.faceland.loot.data.ItemStat;
import org.bukkit.ChatColor;

import info.faceland.loot.tier.Tier;
import java.util.List;
import java.util.Set;
import land.face.market.data.PlayerMarketState.FilterFlagA;

public interface TierBuilder {

Expand Down Expand Up @@ -55,6 +55,8 @@ public interface TierBuilder {

TierBuilder withCustomDataInterval(int i);

TierBuilder withFilterFlag(FilterFlagA filterFlag);

TierBuilder withItemGroups(Set<ItemGroup> s);

}
110 changes: 96 additions & 14 deletions src/main/java/info/faceland/loot/commands/LootCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,89 @@
*/
package info.faceland.loot.commands;

import static com.tealcube.minecraft.bukkit.facecore.utilities.MessageUtils.sendMessage;

import com.tealcube.minecraft.bukkit.TextUtils;
import com.tealcube.minecraft.bukkit.shade.google.common.collect.Sets;
import info.faceland.loot.LootPlugin;
import info.faceland.loot.api.items.CustomItem;
import info.faceland.loot.api.items.ItemGenerationReason;
import info.faceland.loot.api.math.Vec3;
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.data.ItemRarity;
import info.faceland.loot.data.UpgradeScroll;
import info.faceland.loot.enchantments.EnchantmentTome;
import info.faceland.loot.items.prefabs.ArcaneEnhancer;
import info.faceland.loot.items.prefabs.IdentityTome;
import info.faceland.loot.items.prefabs.PurifyingScroll;
import info.faceland.loot.items.prefabs.SocketExtender;
import info.faceland.loot.items.prefabs.UnidentifiedItem;
import info.faceland.loot.data.UpgradeScroll;
import info.faceland.loot.math.LootRandom;
import info.faceland.loot.menu.pawn.PawnMenu;
import info.faceland.loot.menu.upgrade.EnchantMenu;
import info.faceland.loot.tier.Tier;
import info.faceland.loot.utils.DropUtil;
import info.faceland.loot.utils.InventoryUtil;
import info.faceland.loot.utils.MaterialUtil;
import io.pixeloutlaw.minecraft.spigot.hilt.ItemStackExtensionsKt;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import se.ranzdo.bukkit.methodcommand.*;

import java.util.List;

import static com.tealcube.minecraft.bukkit.facecore.utilities.MessageUtils.sendMessage;
import se.ranzdo.bukkit.methodcommand.Arg;
import se.ranzdo.bukkit.methodcommand.Command;
import se.ranzdo.bukkit.methodcommand.FlagArg;
import se.ranzdo.bukkit.methodcommand.Flags;
import se.ranzdo.bukkit.methodcommand.Wildcard;

public final class LootCommand {

private final LootPlugin plugin;
private final LootRandom random;
private String awardFormat;
private String awardFormatSelf;

public LootCommand(LootPlugin plugin) {
this.plugin = plugin;
this.random = new LootRandom(System.currentTimeMillis());
awardFormat = plugin.getSettings().getString("language.broadcast.reward-item", "");
awardFormatSelf = plugin.getSettings().getString("language.broadcast.reward-item-self", "");
}

@Command(identifier = "loot reward", permissions = "loot.command.spawn", onlyPlayers = false)
public void reward(CommandSender sender,
@Arg(name = "target") Player target,
@Arg(name = "minLevel", def = "1") int minLevel,
@Arg(name = "maxLevel", def = "100") int maxLevel,
@Arg(name = "rarity") String rarity) {
Tier t = DropUtil.getTier(target);
if (t == null) {
sendMessage(sender,
plugin.getSettings().getString("language.commands.spawn.other-failure", ""));
return;
}

int level = minLevel + (int) ((maxLevel - minLevel) * Math.random());

ItemRarity itemRarity = plugin.getRarityManager().getRarity(rarity);

ItemStack item = plugin.getNewItemBuilder()
.withTier(t)
.withLevel(level)
.withRarity(itemRarity)
.withItemGenerationReason(ItemGenerationReason.COMMAND)
.build().getStack();

target.playSound(target.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
target.playSound(target.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
target.getInventory().addItem(item);
if (itemRarity.isBroadcast()) {
InventoryUtil.broadcast(target, item, awardFormat, true);
} else {
InventoryUtil.broadcast(target, item, awardFormatSelf, false);
}
sendMessage(sender, "Rewarded " + target.getName() + " successfully!");
}

@Command(identifier = "loot spawn", permissions = "loot.command.spawn")
Expand Down Expand Up @@ -123,9 +168,12 @@ public void spawnCommand(Player sender, @Arg(name = "amount", def = "1") int amo
if (enchantment) {
if (name.equals("")) {
for (int i = 0; i < amount; i++) {
sender.getInventory().addItem(plugin.getEnchantTomeManager().getRandomEnchantTome().toItemStack(1));
sender.getInventory()
.addItem(plugin.getEnchantTomeManager().getRandomEnchantTome().toItemStack(1));
}
sendMessage(sender, plugin.getSettings().getString("language.commands.spawn.stone-success", ""), new String[][]{{"%amount%", amount + ""}});
sendMessage(sender,
plugin.getSettings().getString("language.commands.spawn.stone-success", ""),
new String[][]{{"%amount%", amount + ""}});
return;
}
EnchantmentTome es = plugin.getEnchantTomeManager().getEnchantTome(name);
Expand Down Expand Up @@ -207,7 +255,8 @@ public void spawnCommand(Player sender, @Arg(name = "amount", def = "1") int amo
if (upgradeScroll) {
if (name.equals("")) {
for (int i = 0; i < amount; i++) {
sender.getInventory().addItem(plugin.getScrollManager().buildItemStack(plugin.getScrollManager().getRandomScroll()));
sender.getInventory().addItem(plugin.getScrollManager()
.buildItemStack(plugin.getScrollManager().getRandomScroll()));
}
sendMessage(sender,
plugin.getSettings().getString("language.commands.spawn.upgrade-scroll", ""),
Expand Down Expand Up @@ -239,6 +288,38 @@ public void spawnCommand(Player sender, @Arg(name = "amount", def = "1") int amo
new String[][]{{"%amount%", amount + ""}});
}

@Command(identifier = "loot materials", permissions = "loot.command.spawn", onlyPlayers = false)
public void reward(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "itemLevel", def = "1") int itemLevel,
@Arg(name = "itemQuality", def = "1") int quality) {

quality = Math.min(5, Math.max(quality, 1));

for (Material m : plugin.getCraftMatManager().getCraftMaterials().keySet()) {
ItemStack itemStack = MaterialUtil.buildMaterial(m,
plugin.getCraftMatManager().getCraftMaterials().get(m), itemLevel, quality);
target.getInventory().addItem(itemStack);
}
}

@Command(identifier = "loot give purify", permissions = "loot.command.spawn", onlyPlayers = false)
public void givePurify(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "amount", def = "1") int amount) {

ItemStack scroll = PurifyingScroll.get();
scroll.setAmount(amount);
target.getInventory().addItem(scroll);
}

@Command(identifier = "loot give enhance", permissions = "loot.command.spawn", onlyPlayers = false)
public void giveEnhance(CommandSender sender, @Arg(name = "target") Player target,
@Arg(name = "amount", def = "1") int amount) {

ItemStack enhancer = ArcaneEnhancer.get();
enhancer.setAmount(amount);
target.getInventory().addItem(enhancer);
}

@Command(identifier = "loot simulate", permissions = "loot.command.simulate")
@Flags(identifier = {"c", "s", "t", "e", "se", "u", "id", "us", "rp"},
description = {"custom", "socket gem", "tier", "enchantment", "socket extender",
Expand Down Expand Up @@ -385,7 +466,8 @@ public void simulateCommand(Player sender, @Arg(name = "amount", def = "1") int
} else if (upgradeScroll) {
if (name.equals("")) {
for (int i = 0; i < amount; i++) {
sender.getInventory().addItem(plugin.getScrollManager().buildItemStack(plugin.getScrollManager().getRandomScroll()));
sender.getInventory().addItem(plugin.getScrollManager()
.buildItemStack(plugin.getScrollManager().getRandomScroll()));
}
sendMessage(sender,
plugin.getSettings().getString("language.commands.spawn.upgrade-scroll", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@
*/
package info.faceland.loot.creatures;

import info.faceland.loot.api.creatures.MobInfo;
import info.faceland.loot.api.creatures.CreatureModBuilder;
import info.faceland.loot.api.creatures.MobInfo;
import info.faceland.loot.api.items.CustomItem;
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.data.JunkItemData;
import info.faceland.loot.enchantments.EnchantmentTome;
import org.bukkit.entity.EntityType;

import info.faceland.loot.tier.Tier;
import java.util.Map;
import org.bukkit.entity.EntityType;

public final class LootCreatureModBuilder implements CreatureModBuilder {

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/info/faceland/loot/creatures/LootMobInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
*/
package info.faceland.loot.creatures;

import com.tealcube.minecraft.bukkit.shade.objecthunter.exp4j.Expression;
import info.faceland.loot.api.creatures.MobInfo;
import info.faceland.loot.api.items.CustomItem;
import info.faceland.loot.api.sockets.SocketGem;
import info.faceland.loot.api.tier.Tier;
import info.faceland.loot.data.JunkItemData;
import com.tealcube.minecraft.bukkit.shade.objecthunter.exp4j.Expression;
import info.faceland.loot.enchantments.EnchantmentTome;
import org.bukkit.entity.EntityType;

import info.faceland.loot.tier.Tier;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.EntityType;

public final class LootMobInfo implements MobInfo {

Expand Down
Loading

0 comments on commit ec82cf9

Please sign in to comment.