caliog / Rolecraft

Bukkit plugin which offers a ton of rpg features
GNU General Public License v3.0
4 stars 5 forks source link

How do i make new spells? #8

Closed Mrs-Feathers closed 6 years ago

Mrs-Feathers commented 6 years ago

Hello! As per your wiki, the spells section, i have followed the tutorial to make Flamethrower spell as well as another "push" which creates knock back for entities around you.

`package org.caliog.SpellCollection;

import java.util.Iterator; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.caliog.Rolecraft.Entities.EntityManager; import org.caliog.Rolecraft.Entities.Player.RolecraftPlayer; import org.caliog.Rolecraft.Spells.Spell;

public class Push extends Spell { public Push(RolecraftPlayer player) { super(player, "Push"); }

public boolean execute() {
    if (!super.execute()) {
        return false;
    } else {
        int w = Math.round((float)this.getPower() / 60.0F * 12.0F);
        Iterator var3 = this.getPlayer().getPlayer().getNearbyEntities((double)w, (double)w, (double)w).iterator();

        while(var3.hasNext()) {
            Entity entity = (Entity)var3.next();
            if (EntityManager.getMob(entity.getUniqueId()) != null && entity instanceof LivingEntity) {
                ((LivingEntity)entity).setVelocity(((LivingEntity)entity).getLocation().getDirection().multiply(this.getPower() * -1.5));
            }
        }

        return true;
    }
}

} `

i have also a spells.info with

org.caliog.SpellCollection.Flamethrower org.caliog.SpellCollection.Push

in it.. Now, i only want these two spells, so i compile them into a .jar called SpellCollection.jar as your tutorial says. i put it in the plugins/Rolecraft/Spells folder.. however when i reboot the server, it is replaced by the original SpellCollection.jar... how can i have my own spellcollection.jar be used by Rolecraft and not be overwritten?

Mrs-Feathers commented 6 years ago

Update: I made a spell collection with everything all together in it, your original spells [updated ones from the SpellCollection.jar as the ones from this github are outdated] screen shot 2018-05-22 at 16 55 52 and then spell.info with

screen shot 2018-05-22 at 17 02 14

in it. I try to compile this as SpellCollection.jar and replace it and start the server.. it still overwrites the original.. :(

do i need to name it something else? do i need to edit the config.yml make it not overwrite?

Mrs-Feathers commented 6 years ago

https://www.dropbox.com/s/n0n0wl360pczcef/SpellCollection.jar?dl=0

I've uploaded my .jar here in case you want to open it with an IDE and look at the code inside or use it to test with your server. I hope to get this working soon!

caliog commented 6 years ago

Well seems like Rolecraft overwrites it by "accident". Will be fixed in the next update. But you can manipulate the Rolecraft.jar to fix it right now. Open Rolecraft.jar in some "explorer" (I use WinRAR) and go to org.caliog.Rolecraft.XMechanics.Resource There you can find a "SpellCollection.jar" which you can simply overwrite with your own file. Now it will copy it in the spells folder if you reboot.

But again this is not the way its meant to be. Will be fixed soon.

As you have noticed I rebuild Spells (https://github.com/caliog/Rolecraft/blob/master/src/org/caliog/Rolecraft/Spells/Spell.java) a little bit, so there is a high chance that things may not work as you want it and I would be really grateful if you tell me about it, so I can fix things.

Thank you very much

Mrs-Feathers commented 6 years ago

danke sehr!!! i don't know why i didn't think of doing that, but thank you. i know its not meant to be like this, but at least now i can test my new spells!

and yes, i saw classes change.. i saw getPower was made final.. and i saw its using the .yml config files, so i kinda rewrote the spells to work with the new system you have going.

Mrs-Feathers commented 6 years ago

i also have a weird question. for one of the spells i was thinking of @overriding a listener.. the one you have in Xmechanics.Listeners.DamageListener.. you have the entityTargetPlayer listener set up.. how would i be able to use that to lets say..... write a spell that summons a skeleton, but the skeleton doesn't target the player who casts the spell. i realize though, the spell would have to have a time limit with activate() and once the "spell" is over, the skeleton would turn on the user. but that sounds like it would balance itself out. lol. but would be a cool spell for a "necromancer".. but if thats not something that's possible, i guess i could just summon the skeleton without doing anything like that. the spell caster would just have to watch his own back.

caliog commented 6 years ago

You could add something like this after you spawned the skeletons:

    Bukkit.getPluginManager().registerEvents(new Listener() {

        @EventHandler(priority = EventPriority.HIGHEST)
        public void targetEvent(EntityTargetEvent event) {
            // check if entity is your skeleton
            event.setCancelled(true);
        }
    }, Manager.plugin);

You could unregister the listener again if the spell is no longer active.

Mrs-Feathers commented 6 years ago

ah ok. that makes complete sense..i'm just a bit new to writing plugins so i wasn't sure you could just "register something out of the blue" after you've initiated the plugin and all that. thanks so much!

caliog commented 6 years ago

Is it working as you expected it ? If you search for any help or ideas just let me know

Mrs-Feathers commented 6 years ago

so far i’m still working on how to get power to be able to cast and test things in the first place ^^;; i have RC weapons.. I’ve leveled up a bit.. used skillstars and i know how to cast spells. i know how classes work.. but all the spells say 0/somenumber Power and when i cast them using the right and left as they say, it just goes to random text like it didn’t understand.. which makes me assume i need some kind of power? i’m probably missing something super simple..

On May 28, 2018, at 08:29, Caliog notifications@github.com wrote:

Is it working as you expected it ? If you search for any help or ideas just let me know

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/caliog/Rolecraft/issues/8#issuecomment-392514328, or mute the thread https://github.com/notifications/unsubscribe-auth/ABqmdhGWwT754qhGXYWfhOIesDCdi46jks5t2-2kgaJpZM4UJYDK.

caliog commented 6 years ago

Its described here. You should have a spellbook (if not there is a command), if you open it you can power up your spells and then you can use them. I should do a info message if people try to use spells with 0 power.