From 9fabffc824b501a7be35610db50a6169541aa67b Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 3 Aug 2024 22:05:01 -0400 Subject: [PATCH 1/3] All Command noloinger gives 100000 orbs lol Just one --- .../volmit/adapt/api/world/AdaptServer.java | 30 +++---- .../volmit/adapt/command/CommandAdapt.java | 79 ++++++++++--------- .../adapt/content/item/ExperienceOrb.java | 37 +++++++-- .../adapt/content/item/KnowledgeOrb.java | 36 +++++++-- 4 files changed, 120 insertions(+), 62 deletions(-) diff --git a/src/main/java/com/volmit/adapt/api/world/AdaptServer.java b/src/main/java/com/volmit/adapt/api/world/AdaptServer.java index 82279d70..7f41a166 100644 --- a/src/main/java/com/volmit/adapt/api/world/AdaptServer.java +++ b/src/main/java/com/volmit/adapt/api/world/AdaptServer.java @@ -136,17 +136,17 @@ public void on(ProjectileLaunchEvent e) { Skill skill = getSkillRegistry().getSkill(data.getSkill()); data.apply(p); SoundNotification.builder() - .sound(Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM) - .volume(0.35f).pitch(1.455f) - .build().play(getPlayer(p)); + .sound(Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM) + .volume(0.35f).pitch(1.455f) + .build().play(getPlayer(p)); SoundNotification.builder() - .sound(Sound.ENTITY_SHULKER_OPEN) - .volume(1f).pitch(1.655f) - .build().play(getPlayer(p)); + .sound(Sound.ENTITY_SHULKER_OPEN) + .volume(1f).pitch(1.655f) + .build().play(getPlayer(p)); getPlayer(p).getNot().queue(AdvancementNotification.builder() - .icon(Material.BOOK) - .title(C.GRAY + "+ " + C.WHITE + data.getKnowledge() + " " + skill.getDisplayName() + " Knowledge") - .build()); + .icon(Material.BOOK) + .title(C.GRAY + "+ " + C.WHITE + data.getKnowledge() + " " + skill.getDisplayName() + " Knowledge") + .build()); e.setCancelled(false); e.getEntity().setVelocity(e.getEntity().getVelocity().multiply(1000)); } else { @@ -154,13 +154,13 @@ public void on(ProjectileLaunchEvent e) { if (datax != null) { datax.apply(p); SoundNotification.builder() - .sound(Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM) - .volume(0.35f).pitch(1.455f) - .build().play(getPlayer(p)); + .sound(Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM) + .volume(0.35f).pitch(1.455f) + .build().play(getPlayer(p)); SoundNotification.builder() - .sound(Sound.ENTITY_SHULKER_OPEN) - .volume(1f).pitch(1.655f) - .build().play(getPlayer(p)); + .sound(Sound.ENTITY_SHULKER_OPEN) + .volume(1f).pitch(1.655f) + .build().play(getPlayer(p)); e.setCancelled(false); e.getEntity().setVelocity(e.getEntity().getVelocity().multiply(1000)); } diff --git a/src/main/java/com/volmit/adapt/command/CommandAdapt.java b/src/main/java/com/volmit/adapt/command/CommandAdapt.java index f7c02802..1397b52c 100644 --- a/src/main/java/com/volmit/adapt/command/CommandAdapt.java +++ b/src/main/java/com/volmit/adapt/command/CommandAdapt.java @@ -17,18 +17,21 @@ import com.volmit.adapt.util.decree.specialhandlers.NullablePlayerHandler; import org.bukkit.entity.Player; +import java.util.HashMap; +import java.util.Map; + @Decree(name = "adapt", description = "Basic Command") public class CommandAdapt implements DecreeExecutor { private CommandDebug debug; @Decree(description = "Boost Target player, or Global Experience gain.") public void boost( - @Param(aliases = "seconds", description = "Amount of seconds", defaultValue = "10") - int seconds, - @Param(aliases = "multiplier", description = "Strength of the boost ", defaultValue = "10") - int multiplier, - @Param(description = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) - Player player + @Param(aliases = "seconds", description = "Amount of seconds", defaultValue = "10") + int seconds, + @Param(aliases = "multiplier", description = "Strength of the boost ", defaultValue = "10") + int multiplier, + @Param(description = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) + Player player ) { if (!sender().hasPermission("adapt.boost")) { @@ -48,12 +51,12 @@ public void boost( @Decree(description = "Open the Adapt GUI") public void gui( - @Param(aliases = "target", defaultValue = "[Main]") - AdaptationListingHandler.AdaptationList guiTarget, - @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) - Player player, - @Param(aliases = "force", defaultValue = "false") - boolean force + @Param(aliases = "target", defaultValue = "[Main]") + AdaptationListingHandler.AdaptationList guiTarget, + @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) + Player player, + @Param(aliases = "force", defaultValue = "false") + boolean force ) { if (!sender().hasPermission("adapt.gui")) { sender().sendMessage("You lack the Permission 'adapt.gui'"); @@ -103,12 +106,12 @@ public void gui( @Decree(description = "Give yourself an experience orb") public void experience( - @Param(aliases = "skill") - AdaptationListingHandler.AdaptationSkillList skillName, - @Param(aliases = "amount", defaultValue = "10") - int amount, - @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) - Player player + @Param(aliases = "skill") + AdaptationListingHandler.AdaptationSkillList skillName, + @Param(aliases = "amount", defaultValue = "10") + int amount, + @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) + Player player ) { if (!sender().hasPermission("adapt.cheatitem")) { @@ -128,9 +131,11 @@ public void experience( } if (skillName.equals("[all]")) { + Map experienceMap = new HashMap<>(); for (Skill skill : SkillRegistry.skills.sortV()) { - targetPlayer.getInventory().addItem(ExperienceOrb.with(skill.getName(), amount)); + experienceMap.put(skill.getName(), (double) amount); } + targetPlayer.getInventory().addItem(ExperienceOrb.with(experienceMap)); FConst.success("Giving all orbs").send(sender()); return; } @@ -150,12 +155,12 @@ public void experience( @Decree(description = "Give yourself a knowledge orb") public void knowledge( - @Param(aliases = "skill") - AdaptationListingHandler.AdaptationSkillList skillName, - @Param(aliases = "amount", defaultValue = "10") - int amount, - @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) - Player player + @Param(aliases = "skill") + AdaptationListingHandler.AdaptationSkillList skillName, + @Param(aliases = "amount", defaultValue = "10") + int amount, + @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) + Player player ) { if (!sender().hasPermission("adapt.cheatitem")) { sender().sendMessage("You lack the Permission 'adapt.cheatitem'"); @@ -173,9 +178,11 @@ public void knowledge( } if (skillName.equals("[all]")) { + Map knowledgeMap = new HashMap<>(); for (Skill skill : SkillRegistry.skills.sortV()) { - targetPlayer.getInventory().addItem(KnowledgeOrb.with(skill.getName(), amount)); + knowledgeMap.put(skill.getName(), amount); } + targetPlayer.getInventory().addItem(KnowledgeOrb.with(knowledgeMap)); FConst.success("Giving all orbs").send(sender()); return; } @@ -195,16 +202,16 @@ public void knowledge( @Decree(description = "Assign a skill, or UnAssign a skill as if you are learning / unlearning a skill.") public void determine( - @Param(aliases = "adaptationTarget") - AdaptationListingHandler.AdaptationProvider adaptationTarget, - @Param(aliases = "assign") - boolean assign, - @Param(aliases = "force") - boolean force, - @Param(aliases = "level") - int level, - @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) - Player player + @Param(aliases = "adaptationTarget") + AdaptationListingHandler.AdaptationProvider adaptationTarget, + @Param(aliases = "assign") + boolean assign, + @Param(aliases = "force") + boolean force, + @Param(aliases = "level") + int level, + @Param(aliases = "player", defaultValue = "---", customHandler = NullablePlayerHandler.class) + Player player ) { if (!sender().hasPermission("adapt.determine")) { diff --git a/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java b/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java index 4e9ca59f..6174e1b5 100644 --- a/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java +++ b/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java @@ -33,7 +33,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.HashMap; import java.util.List; +import java.util.Map; @AllArgsConstructor @Data @@ -52,6 +54,10 @@ public static ItemStack with(String skill, double xp) { return io.withData(new Data(skill, xp)); } + public static ItemStack with(Map experienceMap) { + return io.withData(new Data(experienceMap)); + } + @Override public Material getMaterial() { return Material.SNOWBALL; @@ -64,8 +70,11 @@ public Class getType() { @Override public void applyLore(Data data, List lore) { - Skill skill = Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(data.skill); - lore.add(C.WHITE + Localizer.dLocalize("snippets", "experienceorb", "contains") + " " + C.UNDERLINE + C.WHITE + Form.f(data.experience, 0) + " " + skill.getDisplayName() + C.GRAY + " " + Localizer.dLocalize("snippets", "experienceorb", "xp")); + for (Map.Entry entry : data.getExperienceMap().entrySet()) { + String skill = entry.getKey(); + double experience = entry.getValue(); + lore.add(C.WHITE + Localizer.dLocalize("snippets", "experienceorb", "contains") + " " + C.UNDERLINE + C.WHITE + Form.f(experience, 0) + " " + Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(skill).getDisplayName() + C.GRAY + " " + Localizer.dLocalize("snippets", "experienceorb", "xp")); + } lore.add(C.LIGHT_PURPLE + Localizer.dLocalize("snippets", "experienceorb", "rightclick") + " " + C.GRAY + Localizer.dLocalize("snippets", "experienceorb", "togainxp")); } @@ -73,17 +82,33 @@ public void applyLore(Data data, List lore) { public void applyMeta(Data data, ItemMeta meta) { meta.addEnchant(Enchantment.BINDING_CURSE, 10, true); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS); - meta.setDisplayName(Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(data.skill).getDisplayName() + " " + Localizer.dLocalize("snippets", "experienceorb", "xporb")); + meta.setDisplayName(Localizer.dLocalize("snippets", "experienceorb", "xporb")); } @AllArgsConstructor @lombok.Data public static class Data { - private String skill; - private double experience; + private Map experienceMap; + + public Data(String skill, double experience) { + this.experienceMap = new HashMap<>(); + this.experienceMap.put(skill, experience); + } + + public String getSkill() { + return experienceMap.keySet().iterator().next(); + } + + public double getExperience() { + return experienceMap.values().iterator().next(); + } public void apply(Player p) { - Adapt.instance.getAdaptServer().getPlayer(p).getSkillLine(skill).giveXPFresh(Adapt.instance.getAdaptServer().getPlayer(p).getNot(), experience); + for (Map.Entry entry : experienceMap.entrySet()) { + String skill = entry.getKey(); + double experience = entry.getValue(); + Adapt.instance.getAdaptServer().getPlayer(p).getSkillLine(skill).giveXPFresh(Adapt.instance.getAdaptServer().getPlayer(p).getNot(), experience); + } } } } diff --git a/src/main/java/com/volmit/adapt/content/item/KnowledgeOrb.java b/src/main/java/com/volmit/adapt/content/item/KnowledgeOrb.java index fb692894..e502d662 100644 --- a/src/main/java/com/volmit/adapt/content/item/KnowledgeOrb.java +++ b/src/main/java/com/volmit/adapt/content/item/KnowledgeOrb.java @@ -31,7 +31,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import java.util.HashMap; import java.util.List; +import java.util.Map; @AllArgsConstructor @Data @@ -66,6 +68,10 @@ public static ItemStack with(String skill, int knowledge) { return io.withData(new Data(skill, knowledge)); } + public static ItemStack with(Map knowledgeMap) { + return io.withData(new Data(knowledgeMap)); + } + @Override public Material getMaterial() { return Material.SNOWBALL; @@ -78,7 +84,11 @@ public Class getType() { @Override public void applyLore(Data data, List lore) { - lore.add(C.WHITE + Localizer.dLocalize("snippets", "knowledgeorb", "contains") + " " + C.UNDERLINE + C.WHITE + "" + data.knowledge + " " + Localizer.dLocalize("snippets", "knowledgeorb", "knowledge")); + for (Map.Entry entry : data.getKnowledgeMap().entrySet()) { + String skill = entry.getKey(); + int knowledge = entry.getValue(); + lore.add(C.WHITE + Localizer.dLocalize("snippets", "knowledgeorb", "contains") + " " + C.UNDERLINE + C.WHITE + "" + knowledge + " " + Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(skill).getDisplayName() + " " + Localizer.dLocalize("snippets", "knowledgeorb", "knowledge")); + } lore.add(C.LIGHT_PURPLE + Localizer.dLocalize("snippets", "knowledgeorb", "rightclick") + " " + C.GRAY + Localizer.dLocalize("snippets", "knowledgeorb", "togainknowledge")); } @@ -86,17 +96,33 @@ public void applyLore(Data data, List lore) { public void applyMeta(Data data, ItemMeta meta) { meta.addEnchant(Enchantment.BINDING_CURSE, 10, true); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS); - meta.setDisplayName(Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(data.skill).getDisplayName() + " " + Localizer.dLocalize("snippets", "knowledgeorb", "knowledgeorb")); + meta.setDisplayName(Localizer.dLocalize("snippets", "knowledgeorb", "knowledgeorb")); } @AllArgsConstructor @lombok.Data public static class Data { - private String skill; - private int knowledge; + private Map knowledgeMap; + + public Data(String skill, int knowledge) { + this.knowledgeMap = new HashMap<>(); + this.knowledgeMap.put(skill, knowledge); + } + + public String getSkill() { + return knowledgeMap.keySet().iterator().next(); + } + + public int getKnowledge() { + return knowledgeMap.values().iterator().next(); + } public void apply(Player p) { - Adapt.instance.getAdaptServer().getPlayer(p).getSkillLine(skill).giveKnowledge(knowledge); + for (Map.Entry entry : knowledgeMap.entrySet()) { + String skill = entry.getKey(); + int knowledge = entry.getValue(); + Adapt.instance.getAdaptServer().getPlayer(p).getSkillLine(skill).giveKnowledge(knowledge); + } } } } From f3b9c5a5470effa01a86231d7a97bc04e8aaff0d Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 3 Aug 2024 22:08:38 -0400 Subject: [PATCH 2/3] forse a cap --- src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java b/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java index 6174e1b5..f6d3915d 100644 --- a/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java +++ b/src/main/java/com/volmit/adapt/content/item/ExperienceOrb.java @@ -73,7 +73,7 @@ public void applyLore(Data data, List lore) { for (Map.Entry entry : data.getExperienceMap().entrySet()) { String skill = entry.getKey(); double experience = entry.getValue(); - lore.add(C.WHITE + Localizer.dLocalize("snippets", "experienceorb", "contains") + " " + C.UNDERLINE + C.WHITE + Form.f(experience, 0) + " " + Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(skill).getDisplayName() + C.GRAY + " " + Localizer.dLocalize("snippets", "experienceorb", "xp")); + lore.add(C.WHITE + Form.capitalize(Localizer.dLocalize("snippets", "experienceorb", "contains")) + " " + C.UNDERLINE + C.WHITE + Form.f(experience, 0) + " " + Adapt.instance.getAdaptServer().getSkillRegistry().getSkill(skill).getDisplayName() + C.GRAY + " " + Localizer.dLocalize("snippets", "experienceorb", "xp")); } lore.add(C.LIGHT_PURPLE + Localizer.dLocalize("snippets", "experienceorb", "rightclick") + " " + C.GRAY + Localizer.dLocalize("snippets", "experienceorb", "togainxp")); } From 6970cab68e43c77737238c775da3dce2af29590b Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Sat, 3 Aug 2024 22:35:26 -0400 Subject: [PATCH 3/3] New Skill ANyone? Rift Vissage, Prevents Enderman from attacking/aggroing on you if you have pearls in your inventory --- .../content/adaptation/rift/RiftVisage.java | 79 +++++++++++++++++++ .../volmit/adapt/content/skill/SkillRift.java | 1 + src/main/resources/en_US.json | 6 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/volmit/adapt/content/adaptation/rift/RiftVisage.java diff --git a/src/main/java/com/volmit/adapt/content/adaptation/rift/RiftVisage.java b/src/main/java/com/volmit/adapt/content/adaptation/rift/RiftVisage.java new file mode 100644 index 00000000..32fde09b --- /dev/null +++ b/src/main/java/com/volmit/adapt/content/adaptation/rift/RiftVisage.java @@ -0,0 +1,79 @@ +package com.volmit.adapt.content.adaptation.rift; + +import com.volmit.adapt.api.adaptation.SimpleAdaptation; +import com.volmit.adapt.util.C; +import com.volmit.adapt.util.Element; +import com.volmit.adapt.util.Localizer; +import lombok.NoArgsConstructor; +import org.bukkit.Material; +import org.bukkit.entity.Enderman; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.inventory.ItemStack; + +public class RiftVisage extends SimpleAdaptation { + public RiftVisage() { + super("rift-visage"); + registerConfiguration(Config.class); + setDescription(Localizer.dLocalize("rift", "visage", "description")); + setDisplayName(Localizer.dLocalize("rift", "visage", "name")); + setIcon(Material.POPPED_CHORUS_FRUIT); + setBaseCost(getConfig().baseCost); + setCostFactor(getConfig().costFactor); + setMaxLevel(getConfig().maxLevel); + setInitialCost(getConfig().initialCost); + setInterval(1000); + } + + @Override + public void addStats(int level, Element v) { + v.addLore(C.ITALIC + Localizer.dLocalize("rift", "visage", "lore1")); + } + + @EventHandler + public void onEntityTarget(EntityTargetEvent event) { + Entity entity = event.getEntity(); + if (entity instanceof Enderman) { + if (event.getTarget() instanceof Player player) { + if (hasAdaptation(player) && hasEnderPearl(player)) { + event.setCancelled(true); + } + } + } + } + + private boolean hasEnderPearl(Player player) { + for (ItemStack item : player.getInventory().getContents()) { + if (item != null && item.getType() == Material.ENDER_PEARL) { + return true; + } + } + return false; + } + + @Override + public void onTick() { + } + + @Override + public boolean isEnabled() { + return getConfig().enabled; + } + + @Override + public boolean isPermanent() { + return getConfig().permanent; + } + + @NoArgsConstructor + protected static class Config { + boolean permanent = true; + boolean enabled = true; + int baseCost = 8; + double costFactor = 0; + int maxLevel = 1; + int initialCost = 2; + } +} diff --git a/src/main/java/com/volmit/adapt/content/skill/SkillRift.java b/src/main/java/com/volmit/adapt/content/skill/SkillRift.java index 25818123..1fe669d7 100644 --- a/src/main/java/com/volmit/adapt/content/skill/SkillRift.java +++ b/src/main/java/com/volmit/adapt/content/skill/SkillRift.java @@ -55,6 +55,7 @@ public SkillRift() { registerAdaptation(new RiftGate()); registerAdaptation(new RiftBlink()); registerAdaptation(new RiftDescent()); + registerAdaptation(new RiftVisage()); lasttp = new HashMap<>(); } diff --git a/src/main/resources/en_US.json b/src/main/resources/en_US.json index 3525da68..c6a7a1d5 100644 --- a/src/main/resources/en_US.json +++ b/src/main/resources/en_US.json @@ -232,7 +232,6 @@ "title": "Legendary Miner", "description": "Break 5,000,000 Blocks" } - }, "items": { "boundenderperal": { @@ -1000,6 +999,11 @@ "description": "Gain Resistance when using Ender Items & Abilities", "lore1": "+ Passive: Provides resistance when you use rift abilities, or Ender Items", "lore2": "NOT Including Portable Enderchest, only things you can Consume" + }, + "visage": { + "name": "Rift Visage", + "description": "Prevents Endermen from becoming aggressive if you have Enderpearls in your inventory.", + "lore1": "Endermen will not become aggressive if you have Enderpearls in your inventory." } }, "seaborn": {