[INACTIVE][MECH/FUN] LightningCake v1 - Spawn a Cake where a lightning strucks [766]

Discussion in 'Inactive/Unsupported Plugins' started by Naga, May 12, 2011.

  1. Offline

    Naga

    inactive/deleted
     
    Who's awesome? likes this.
  2. Offline

    SirHedgehog

    Haha, random but also brilliant.
     
  3. Offline

    PassivePicasso

    I like it, this would be cool because you could track lightning strikes with this too!
     
  4. Offline

    fregaPT I steal plugins as my own

    Are you up to develop a plugin with me ?
    I have posted plugin also
    And I want people in my level developing with me !
     
  5. Offline

    Naga

    What are you up to develop?
    I'm just starting with this
     
  6. Offline

    fregaPT I steal plugins as my own

    Me too
    Let's talk etc ..
     
  7. Offline

    TrainYourBrain

    OMG, I am juste laughing my ass off :D . Where did you find a such idea ! It's so great :)
    Just keep on !! I really like it !
     
  8. Offline

    Naga

    Was a request :p
    I'm not very creative by myself, give me stupid ideas and I will code it :>
     
  9. Offline

    fregaPT I steal plugins as my own

    Sure
    But, don't you become partner with me ?
     
  10. Offline

    TrainYourBrain

    I don't know if you've done it but here is a little improvement :

    Use a configuration file to manually set the object that appear when lightning happen.
     
  11. Offline

    Naga

    I was about to do that, but I suck at understanding how to use a yaml config.
    I will release a new version tomorrow I think
     
  12. Offline

    TrainYourBrain

    You can also use a json file instead of a yml ;)
     
  13. Offline

    Naga

    wouldnt that be pain for users to edit?
    {"config1":"value","config2":"value"}
     
  14. Offline

    TrainYourBrain

    I don't think so, if you use understandable variables.
    Look at the config.json file from Vampire plugin :

    Code:
    "jumpMaterials": [
        "RED_ROSE"
      ],
      "jumpDeltaSpeed": 3.0,
      "jumpBloodCost": 3.0,
      "jumpMessageNotEnoughBlood": "Not enough blood to jump.",
      "regenStartDelayMilliseconds": 8000,
      "regenHealthPerSecond": 0.25,
      "regenBloodPerHealth": 2.5,
      "regenStartMessage": "Your wounds start to close. This drains blood over time.",
      "combatDamageDealtFactor": 1.5,
      "combatDamageReceivedFactor": 0.7,
      "combatDamageReceivedWoodFactor": 3.5,
    I think it's quiet understandable :)
     
  15. Offline

    Naga

    Ah, that seems ok, thanks for showing.
    I will try it tomorrow :)
     
  16. Offline

    lycano

    @Naga: using a config.yml file is not that hard if you know how ^^

    If you only need one config.yml file and store simple stuff in it you can use the following.
    Note: Brakets with pseudo or pseudocode-Tags are not really there you have to implement this
    by yourself ^^

    For further details lookup http://javadoc.lukegb.com/Bukkit/ and search for Configuration or JavaPlugin or browse the forum to see codeexamples on their github. Btw if you didnt already do that SamplePlugin is always a good starting point for small plugins. You only have to change the namespace and maven values ^^

    adapt your main plugin class like this
    Code:
    public Class YourPlugin extends JavaPlugin {
        public Configuration config;
        public SpawnManager spawnManager;
        public int spawnItemId;
        ...
        @Override
        public void onEnable() {
            /** this will load an existing plugins/<pluginsdir>/config.yml
             *  if no file was found it will return an empty Configuration
             */
            this.config = this.getConfiguration();
            loadConfiguration();
    
            // your spawnManager here {pseudo}
            spawnManager = new SpawnManager(this);
    
            {pseudocode start}
            {pseudo seperate file SpawnManager.java}
            private YourPlugin plugin;
    
            public SpawnManager(YourPlugin plugin) {
                this.plugin = plugin;
            }
    
            public void setSpawnItem(Int id) {
                {pseudo spawnItem(Location loc, Int id)}
            }
            {pseudocode end}
        }
        @Override
        public void onDisable() {
            /** save configuration onDisable() for debugging;
             *
             *  comment it out if you have created your config.yml file as this will
             *  prevent you from editing the config.yml from outside.
             *  For a correct implementation you would need a command
             *  that uses Configuration::setProperty() to apply changes
             *  and a reload command that can reload the config ingame
             */
             config.save();
    
             // Quick&Dirty without extra commands
             // loadConfiguration();
             // config.save();
         }
    
        public void loadConfiguration() {
            config.load(); // loads config
    
            this.spawnItemId = config.getInt("settings.spawn-item-id", 92); // if not found set default to 92 = cake
        }
    }
    
    If you like you can use as many config files with different names as you want but that is another story and can be looked up by examination of existing plugins (or by javadoc)

    Regards, Lycano
     
  17. Offline

    Naga

    Reading simple stuff issnt the problem (thanks for the example btw.) but my problem is to read such things:

    Code:
    messages:
        -player: Playername1
         msg: blah
         enabled: false
        -player: Playername2
         msg: blah2
         enabled: false
    But I think I will use the json for now.
     
  18. Offline

    lycano

    Well, it is up to you what format you use. In your case you could simply rely on flatfile format as you will have only a hand full of options available at first.

    Means
    Code:
    spawnItemId=92
    with yaml
    Code:
    settings:
        spawn-item-id: 92
    
    Personally i prefer yaml because of its clean tree structure. For me json is not that good for saving config options for plugins as long as it has no other need e.g. using it for javascript ajax calls. And .. its not that fast readable for humans. So much double quotes and brakets .. uurg ^^

    last-mentioned: yaml is already there ^^
     
  19. Offline

    Naga

    The point for me is to do something like:


    for (node n : getAllNodes("player")) {
    n.getString("msg");
    n.getBoolean("enabled);
    }

    just to get all players, the simple data issnt really a problem ;)
     
  20. Offline

    lycano

    Well, its just a different way of implementation ;) you can do the same with Configuration but with lesser code.

    You should take a look at ConfigurationNode

    About the for loop: Without background information its hard to tell what you want to do but if you want to get a List of a Node then its a simple getNodeList(String path) in your case getNodeList("player") thats all. Now you have a NodeList that can be iterated (for filtering) or directly accessed through its member methods.
     
  21. Offline

    Rurikar22

    On our server we have events where TheCakeBandit attacks the players and spawns lots of Cakes and such.

    This just seemed like the logical next step!
     
  22. Offline

    Who's awesome?

    You're awesome!
     
  23. Offline

    Gratlofatic

    Could you make it so it adds to the block and not take the block away? I have a lightning plugin with a goldsword and I love spamming it. It would be better if it added the cake to the air block above where it strikes.

    If that made sense, THANKS! :D
     
  24. Offline

    webmilio

    Well, as the modder of the plugin, I can help y'a ! It's REALLY easy ! Go to your plugins folder, go to NagaLightningCake, then open config.yml. The 'plugin.bPos' is the Y axe modifier. So the value -1 replace the block because the output of the event is not the block that have been striken, but above it. So just set it to '0' (zero). :) Hope it helped.

    P.S.: Sorry if I bragged a little :confused:.
    Coming with a new Beta update where you can change the properties with commands (such as /lightningcake (from the client) or lightningcake (from the server) to disable the plugin.)

    Done ! New jars and source at http://bukkit.webmilio.webege.com/NagaLightningCake !!
    The new commands are (for server-side just remove the slash '/'):
    • /lightningcake : disable/enable the plugin in game !
    • /lightningcakeset <block_id> : set the block with <block_id> that appears when the lightning strike.
    • /lightningcakebpos <bPos> : set the bPos <bPos> value.
    There are still errors: when you do a command it returns the way you need to write it event if you got it right. Don't worry, just relly on the blue or green text that will appear (in the client) or in the console (all white).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 16, 2016
  25. Offline

    Gratlofatic

    Haha, awesome. Good luck with it in the future and thanks for the guide! :D
     
  26. Offline

    MonsieurApple

    Considered inactive.
     
  27. Offline

    webmilio

    IF ANYONE IS STILL LOOKING AT THIS THREAD, THE NEW ONE (unofficial) is HERE...
     

Share This Page