• 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

Addon Development Assistance

jedk1

New Member
Okay so I've been thinking lately... And well I can't think of anything new to make. SO, I've decided I want to start helping other addon devs with questions or bits of code they are stuck on. So if any addon dev has a question they think I might know the answer to (regarding the Project Korra API or Spigot API) just ask away. I will try and post snippets of code here that I think will be helpful to people too!
 

Simplicitee

Staff member
Plugin Developer
Verified Member
Okay so I've been thinking lately... And well I can't think of anything new to make. SO, I've decided I want to start helping other addon devs with questions or bits of code they are stuck on. So if any addon dev has a question they think I might know the answer to (regarding the Project Korra API or Spigot API) just ask away. I will try and post snippets of code here that I think will be helpful to people too!
Is mayonnaise an instrument? (if you don't watch SpongeBob this will make no sense)

Edit: I have an actual question, but gonna wait till I get home so I can look at my code.
 

Finn_Bueno_

Staff member
Plugin Developer
Verified Member
Is mayonnaise an instrument? (if you don't watch SpongeBob this will make no sense)

Edit: I have an actual question, but gonna wait till I get home so I can look at my code.
Code:
if(mayonnaise instanceof instrument){
return true;
}
 

Finn_Bueno_

Staff member
Plugin Developer
Verified Member
is it possible to check if a player is left clicking, while NOT targeting a block? If so, how? :)
 

jedk1

New Member
Yea.
I need to use for a move, and I want 1 for clicking on a block, and 1 for clicking in the air. ;) (I am already using right clicking and shifting, this is the only option)
you could for say use:
Code:
if(player.getTargetBlock((HashSet<Material>) null, 6).getType().equals(Material.AIR)){
   //Assuming the player's punch range is 6, this will check if the block the player is targeting with a 6 block range is an AIR block.
   //If it's AIR, then do something.
}
 

Finn_Bueno_

Staff member
Plugin Developer
Verified Member
you could for say use:
Code:
if(player.getTargetBlock((HashSet<Material>) null, 6).getType().equals(Material.AIR)){
   //Assuming the player's punch range is 6, this will check if the block the player is targeting with a 6 block range is an AIR block.
   //If it's AIR, then do something.
}
hmm, that could work! :)
Tnx! :)
 

jedk1

New Member
@White_Knight28 Heres how to get a material from a config option:

Okay so in your main class where you register everything:
Code:
config.addDefault("ExtraAbilities.jedk1.SomeSexyMove.Material", Material.STONE.name());
Then in your ability class:
Code:
private Material material = Material.getMaterial(ProjectKorra.plugin.getConfig().getString("ExtraAbilities.jedk1.SomeSexyMove.Material"));
This code will work, However it might throw an error if the material is null or doesn't exist. I haven't tested this but you could add a check somewhere before you use the material variable. Maybe something like:
Code:
if(material == null)
    material = Material.STONE;
This might work, or might not, as I said, I haven't tested it.
 
Top