#Modify plugin
122 messages ยท Page 1 of 1 (latest)
Do you know Java Spigot Development?
Create a new ClickListener in the listeners packet, and then check if the player is holding a tnt and is sitting in a plane
Or add it like this in the VehicleMovement.java that should be easier: https://github.com/GamerJoep/MinetopiaVehicles/blob/master/src/main/java/nl/mtvehicles/core/movement/VehicleMovement.java#L214
Did you use ChatGPT?
This is absolutely wrong
Do you want to to this in the Vehicle Movement class in a new class
Okay nevermind you need to create a new class
- Get a ClickListener
- Check if Item in MainHand is TNT an if player.getVehicle().getType().equals(VehicleType.AIRPLANE);
Spawn a tnt which falls down and remove one tnt from the players main hand
@EventHandler
public void onPlayerClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack mainHandItem = player.getInventory().getItemInMainHand();
// Check if the player is holding TNT in the main hand
if (mainHandItem.getType() == Material.TNT) {
// Check if the player is riding an airplane
if (player.getVehicle() != null && player.getVehicle().getType().equals(VehicleType.AIRPLANE) {
// Spawn TNT below the player
spawnFallingTNT(player);
}
}
}
private void spawnFallingTNT(Player player) {
// Get the player's location
Location playerLocation = player.getLocation();
// Decrease the Y-coordinate by 1 to place TNT one block below the player
playerLocation.setY(playerLocation.getY() - 1);
// Create a TNT entity
TNTPrimed tnt = player.getWorld().spawn(playerLocation, TNTPrimed.class);
// Set TNT velocity to zero to prevent it from moving in a specific direction
tnt.setVelocity(new Vector(0, 0, 0));
mainHandItem.setAmount(mainHandItem.getAmount() - 1);
}
You need to indend the Last Line right
Thats Not the vehicleMovement Variant. You need to create a new class in the listeners folder
I would strongly recommend you to use IntelliJ for Java development, it will tell you what you are missing
Do you use IntelliJ now?
You click on Open new Project, search for your new downloaded sourcecode of mtvehicles, and Open it
Actually, you should be able to open them in IntelliJ, in the src/Main/Java/ folder
there are librares i need?
You need to activate maven
Dont create It in the Events Folder, create It in the listeners folder
Is anything else in the code underlined in red?
@idle pond
What Is line 30?
Also please write: public class TntEvent implements Listener
Add a ) after AIRPLANE
Where it says the same thing only without the implements right now
Oh and sorry The vector needs to be 0.0, -1.0, 0.0
@idle pond
@idle pond
Oh, dont import the java.util Vector, import the org.bukkit.util.Vector; instead
And i Made an mistake in my If Statement give me a minute
if (player.getVehicle() != null){
String license = player.getVehicle().getCustomName().replace("MTVEHICLES_MAINSEAT_", "");
if(VehicleData.type.get(license).isAirplane()) {
// Spawn TNT below the player
spawnFallingTNT(player);
}
}
.
Kind of look at my code again
Delete the line over my code "if (player.getVehicle() != null && player.getVehicle().getType().equals(VehicleType.AIRPLANE) {"
Delete the NotNull
no problems right now?
nope but your not finished yet
Take a look at /infrastucture/modules/ListenersModule.java
Maybe you figure it out by yourself
Take a screenshot of IntelliJ
Klick on the big m to the right
klick on deploy in the newly opend menu
Send me the content of the pom.xml file
Is something underlined in the pom.xml?
scroll just a little bit down
there?
Search for 1.12.2
Why is the <dependency> underlined?
What happens when you auto fix it?
replace it?
yes
yes
Ok undo my things
Ok then use that one
Do the following:
add more dots like i did
you need exactly my amount of dots
11?
Can you show me what the info is at the bottom when you open the pom.xmk.
@idle pond
Can you Show me Line 171 and 176
In the pom.xml
Can you add the scope tag to both of them
Like in Line 169 i think
There is nothing wrong, Maven is just sometimes strange from device to device. I can theoretically send you the finished jar file all the time, but then you won't learn anything.
In 30 minutes
I did not test it
Oops i forgot to delete my original code to test the plugin
You need to enable it in the config.yml first
Download and put it in the plugins folder
start the server
open the config.yml in the MTVehicles folder
search for the airplane tnt option and set it to true
save the file
๐
reset?
@idle pond
Timer?
It uses the Tank timer
I dont have time to do that today
If I feel like it I'll do one and two (but with an entry in the config for the bomb reload duration). I won't do point three in the foreseeable future because that's several hours of work and I still have a life outside of plugin development.
I did not test it
Does the tnt fall down?
This Problem is not solveable