#Modify plugin

122 messages ยท Page 1 of 1 (latest)

lyric crow
#

Modify plugin

idle pond
#

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

#

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

#
  1. Get a ClickListener
#
  1. 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

idle pond
#

@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

idle pond
#

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

idle pond
#

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

lyric crow
#

there are librares i need?

idle pond
#

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?

lyric crow
#

@idle pond

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

lyric crow
#

@idle pond

lyric crow
#

@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

idle pond
#

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);
}
}

lyric crow
#

like that?

#

@idle pond

idle pond
#

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

lyric crow
#

no problems right now?

idle pond
#

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

lyric crow
#

there?

idle pond
#

Search for 1.12.2

#

Why is the <dependency> underlined?

#

What happens when you auto fix it?

lyric crow
#

hmm

#

fixed

idle pond
#

I found the error wait a minute

lyric crow
#

replace it?

idle pond
#

yes

lyric crow
#

ok

#

i did it

#

start "deploy"?
@idle pond

idle pond
#

yes

lyric crow
#

brrruh

idle pond
#

Ok undo my things

lyric crow
#

o

#

i have it

idle pond
#

Ok then use that one

#

Do the following:

#

add more dots like i did

#

you need exactly my amount of dots

lyric crow
#

11?

idle pond
#

11 on the first one and 12 on the second one

#

deploy then

lyric crow
idle pond
#

Click on that little m with a circle on it

lyric crow
idle pond
#

Can you show me what the info is at the bottom when you open the pom.xmk.

lyric crow
#

@idle pond

lyric crow
#

@idle pond

idle pond
#

Can you Show me Line 171 and 176

lyric crow
idle pond
lyric crow
idle pond
#

Where are the dots

#

.

lyric crow
idle pond
#

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

idle pond
idle pond
#

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
#

What should change?

lyric crow
#

@idle pond

idle pond
idle pond
idle pond
#

Timer?

idle pond
#

It uses the Tank timer

idle pond
#

I dont have time to do that today

idle pond
#

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.

idle pond
idle pond
#

Does the tnt fall down?

idle pond
#

This Problem is not solveable