Ok I have to ask a basic question.

  • I have several routines I either wrote or modified from the old JAVA game that I ran on a server several years ago and gone by. I am trying to pick it back up again and for the life of me cannot get a simple one to run even though it shows no errors and compiles just fine. What is confusing to me is it seems to look fine but will not run Do we still need to @Override


    Most of this came from Red's example in the new API discussions


    public class Angriffsignrework extends Plugin implements Listener {


    @Override

    public void onEnable(){

    registerEventListener(this);

    }


    @EventMethod

    public void onObjectInteraction(PlayerObjectInteractionEvent event){


    // getID();

    Objects.ObjectDefinition def = event.getObjectDefinition();

    //Check if the object we're using is a sign

    if(def.type == Objects.Type.Sign){

    } else {

    //The sign id is stored as "object info", so we can use it to get the sign object

    Sign sign = World.getSign(event.getGlobalID());

    //Always a good idea to check if sign isn't null...

    if(sign != null){

    if(sign.getText().contains("<test>")){

    Server.broadcastTextMessage("Entered if");

    //Get the player who triggered the event

    Player player = event.getPlayer();

    //Send the player a text message

    player.sendTextMessage("Your Name is: " + player.getName());

    //Cancel the event, so the player cannot edit the sign (optional)

    event.setCancelled(true);

    }

    } }

    }

    @Override

    public void onDisable() {

    }

    }

  • It is a test script and it is just detecting a sign and capturing and telling the player his name The Red Example was a healing sign. So it just gave 100 healing but that is harder to test because you always have to be injured.

  • hope this can help.

  • Hmm ok I will study that. Seems a little different. My simple routine was to not react to a sign that had other text. But interestingly the erroneous plugin will stop all plugins from working which I do not remember occurring in the Java version.


    So do you or do you not have to use the override?

  • Hmm ok I will study that. Seems a little different. My simple routine was to not react to a sign that had other text. But interestingly the erroneous plugin will stop all plugins from working which I do not remember occurring in the Java version.


    So do you or do you not have to use the override?

    if your referring to the onEneable() and onDisable() yes they have to be overridden.

  • if your referring to the onEneable() and onDisable() yes they have to be overridden.

    Good at least something is the same. These things are usually something simple like a syntax error. But it is frustrating to get restarted in this fun brain exercise.


    I get a warning that String signText = sign.getText(); is never read.

    Edited 2 times, last by angriff: Added warning comment. ().

  • Hey James1bow, I want to truly thank you. I finally go it to work. Not exactly sure what fixed it (except the big else to nowhere mistake) as I did several things but I took your basic outline and with a slight modification got my (essentially a hello world type exercise) routine to work. It is one of the aspects of this community that I have always loved.


    Now to get the more complicated routines converted.:wacko::drooling:

  • We call them 'methods' in Java ;)

    Well I did not make my living programming. I only started playing with Java when I picked up Rising World after I retired from 50 years of engineering and engineering management. Programmers built their routines to my specifications and from my feedback input on how the machines should behave in practical application. I had Fortran with WatFor and WatFiv in undergrad College run on punch cards on a main frame that had a one week turnaround for output. I did take one PLC class years later in post grad. Forgive me for messing up the vernacular as we always called them computer routines or applications. But hey I guess if I can learn to make the JAVA thingie do what I want, I can call it a 'method' in here so I won't get laughed at near the water cooler. Thanks for the heads up :wat::saint:

  • Hehe no that's fine, and it's always great to learn, and after what you've just said I'm assuming that you're playing with Java in order to learn new stuff. :nerd::thumbup:


    Yes, I said we "We call them 'methods' in Java " but that wasn't just me being silly/facetious. There are are Methods, Subroutines, Procedures and Functions (afaik) in programming. And they are not the same thing.


    Knowing the terminology will help you Google. For example,


    "What's the most efficient method to iterate a 3D array in Java" will yeild better results than a "What's the most efficient subroutine to iterate a 3D array in Java".


    🖖

  • 3Darray? Hell, I had to look up API the other day when I realized that I used it in a sentence and did not know exactly the full acronym meaning. Sort of like saying "Do we know what they are doing in the GOM on this issue?" to someone that was not raised in the oil business; (Gulf of Mexico). Sometimes you can understand and execute the mechanics but fail the final exam because you failed to study nor understand the definitions.


    One of my biggest issue right now is figuring out exactly which API package to import to get my code to stop flagging me in NetBeans.



    Communication requires only that two people understand the meaning of all the spoken or written words or come to a similar understanding through head nods, facial expressions, hand movements and more recently emojis :D.

  • One of my biggest issue right now is figuring out exactly which API package to import to get my code to stop flagging me in NetBeans.


    Take this bit of code in Netbeans, I have not imported the Player class yet.



    If you click on the class declaration (in this example, the Player class (underlined in red)), hold down the Alt Key and press Enter you will see the following options pop up.



    The top 'fix' is always the "Add import for X" (if it exists).


    The Alt + Enter menu is a fantastic tool you should get used to using.


    Hope that helps.

  • Ya I have been looking at that and thanks for the pointers. My screen is a bit different. Mostly it is in getting the correct command/method within the API, I find starting at package then going to class then seeing the methods I can use. Right now I am making a simple "method" and getting that I have to declare it abstract and not override plugin. It compiled but we will see, I am sure it will generate a crash on the server. I will let you know. ... It didnt like that. It did not crash but stopped my other plugins from working. It also did not execute. Back to the staring contest with the screen. :dizzy:

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!