• Hello Guest! Did you know that ProjectKorra has an official Discord server? A lot of discussion about the official server, development process, and community discussion happens over there. Feel free to join now by clicking the link below.

    Join the Discord Server

[Coding Tutorial] Potion Effects

SenpaiBlaze

Verified Member
Ok, assuming you have read @Coolade 's tutorial, here we go. We want to set up our info class. Here is what it should look like with notes. (my first time trying to teach, I'm not that good. This was a quick-wrote tutorial) Please note that copying code doest NOT help you at ALL

Coolades Notes Left In There!
/*
* This registers the ability with the AbilityModule class. It is important
* that the string is EXACTLY how you want the ability to appear in-game.
*/
public IgniteInformation() {
super("BLAH");
}

/*
* This returns the Description that will be seen when someone does /bending
* help [YourAbilityName]
*/
public String getDescription() {
return "BLAAAH";
}

/*
* This returns the name of the Author of the Ability. Use your own username
* if it is your own project. This will be used for debugging.
*/
public String getAuthor() {
return "BLAH";
}

/*
* Much like the getAuthor(), mainly used for Debugging. Also allows you to
* sort of set a release pattern for your ability.
*/
public String getVersion() {
return "v1.0";
}

/*
* Returns the element as a string. It is important you use the Element
* class here. If you do not specify an element, the ability will NOT load
* properly.
*/
public String getElement() {
return Element.ELEMENT.toString();
}

/*
* This just checks whether or not it is a sneak ability. Reason is, some
* other abilities wont work if you are sneaking, so this is our simple
* check for it.
*/
public boolean isShiftAbility() {
return true;
}

/*
* This method is ran each and every time the ability loads. So if you need
* to register any events, schedule any tasks, this is where you do it.
*/
public void onThisLoad() {
ProjectKorra.plugin.getServer().getPluginManager()
.registerEvents(new IgniteListener(), ProjectKorra.plugin);
}

/*
* Stops any progressing Bending.
*/
public void stop() {

}
Next the basic listener:
//Bukkit Knows when your sneaking it activates this stuff (kinda)
@SuppressWarnings("unused")
@EventHandler
public void onSneak(PlayerToggleSneakEvent event) {
final Player player = event.getPlayer();
BendingPlayer bPlayer = Methods.getBendingPlayer(player.getName());

//Do you have the ability bound?

String ability = Methods.getBoundAbility(player);
if(ability == null || !ability.equalsIgnoreCase("Meditate"))
return;
//Can you bend it (the element)

if(!Methods.canBend(player.getName(), "Meditate"))
return;
//is the area world guarded/faction protected?

if(Methods.isRegionProtectedFromBuild(player, "Meditate", player.getLocation()))
return;


Cooldown:
First we need to register the cooldown:

if (bPlayer.isOnCooldown("Electrocute"))
return;
//Adds CoolDown

Next, we define the time.
//Ex. 2*1000l = 2 Seconds, In This Case We Want 2 Minutes, 5 Seconds
bPlayer.addCooldown("Electrocute", 30*1000L);
Adding Potion Effects to To Targets
//Living Entity target states that we are adding it to a target you click, which is a living entity
//The time 100, the strength 1. 100 = 5 seconds. Rest is self explanitory
((LivingEntity) target).addPotionEffect(new PotionEffect(PotionEffectType.WITHER,
100, 1));
Adding Potion Effects To YourSelf
//Self explainitory player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration*100, 2));
In ifSneaking Method
//Add Before Potion Effect to know they need to sneak to get this
if(!player.isSneaking());
final int duration = 1;
De
v Vocab:
Entity: A mob/player
if(BLAH): If the player is doing so ; activate whats
below
!player. : checks if the play is doing BLAH

DEVS : if i missed anything, let me know
 
Top