Inactive [GEN/INFO] EZCalc 1.5 - Do advanced math in-game! [1.1-R6]

Discussion in 'Inactive/Unsupported Plugins' started by TexasGamer, May 29, 2011.

  1. Offline

    TexasGamer

    EZCalc is now on BukkitDev! Click here to visit.
    EZCalc 1.5
    The most advanced calculator plugin available! Ease-of-use for newer players while allowing for more advanced operations. Variables are even saved after logging out.
    Commands (open)

    • Commands
      • calc <equation>
      • ans
      • setx <equation>
      • sety <equation>
      • setz <equation>
      • getx
      • gety
      • getz
      • clearvar
      • clearvar <name>
      • ezcalc <version|reload>
      • getdeaths
      • listvar
    • Permission Nodes
      • ezcalc.calc - all commands (except admin command)
      • ezcalc.admin - clearvar <name>
    Operators and Variables (open)

    All of the following work with any command that accepts an <equation> (i.e. /calc, /setx)
    • Operators: +, -, /, *, %, sqrt
    • Variables: x, y, z, ans, health, death, height, bubble, coordx, coordy, coordz
    • Constants: stack (64)
      • Custom:var1, var2, var3, var4, var5
        • No operators, variables, and constants
    • Other: You can use parenthesis and powers (^). Spacing doesn't affect output.
    Developer API (open)

    EZCalc has a very simple API that lets your plugin use EZCalc for calculations. In addition, you can see a user's variables. The API will be getting improvements along the way to make it more powerful and easy to use.
    • EZCalc API 0.1 (requires EZCalc 2+)
      • Read and write access to variables x, y, z
      • Calculate equations
      • Custom variables and constants (requires your plugin to handle replacing the variables before calculating)
      • Replace variables before calculating
      • More plugin information

    Download
    EZCalc 1.5 (older downloads) Need 1.1-R5+ support? Check out the preview!
    Requirements: Java 6+, recent Bukkit build
    [​IMG]

    Version history
    • 1.5
      • Addition: PermissionsBukkit (native Bukkit permissions) support
      • Addition: Square roots
        • sqrt
      • Addition:Coordinate variables
        • coordx, coordy, coordz
      • Removal: Permissions 3.x support
      • Removal: Auto updater and nightly builds
      • Tweak: Code optimization
      • Tweak:Permission nodes are now simpler
        • ezcalc.calc and ezcalc.admin
      • Compatibility: 1597*
    • 1.4
      • Addition: Ability to reload config file in-game
      • Addition: Ability to update in-game
      • Tweak: Updates are now only done via command (not at server start)
      • Tweak: Updater output is much more readable and suited for in-game
      • Tweak: Updates are now hosted on Dropbox (instead of my crappy server)
      • Compatibility: 1000-1597*
    Older Versions (open)

    • 1.3
      • Addition: Added a configuration file (config.yml)
        • Define custom constants
        • Choose update settings (see below!)
        • Thanks to Jayjay110 for his config file tutorial!
      • Addition: Automatic updates
        • Enable in config.yml
        • You can subscribe to a nightly channel for the latest features
        • Note that updates are downloaded to /plugins/AutoUpdater/EZCalc
        • Thanks to Adamki11s for his auto updater library!
      • Fix: Permissions nodes affect usage of variables (health, death) in /setx, /sety, etc.
      • Fix: Added /setz and /getz to the Help plugin registration
      • Tweak: Clean up onEnable() messages
      • Tweak: Moved EZCalc.jar to the /bin folder to help prevent unzipping issues
      • Compatibility: 1000*
    • 1.2
      • Addition: New variables including height, bubble, and stack
      • Addition: Variable z (similar to x and y)
      • Addition: Admins can now /clearvar <name>
        • ezcalc.admin
      • Addition: Help support
      • Addition:A readme is now included with the download
        • Credit to sk89q!
      • Tweak: /setx (and other variables) now take equations like /calc
      • Tweak: Restructured code to be more flexible and easy to read
      • Fix: Typos and incorrect error messages
      • Compatibility: 818-860*
    • 1.1.1
      • Fix: Variables now work without spacing (i.e. x(4+ans) will work now)
      • Compatibility: 818-860*
    • 1.1
      • Addition: /calc supports advanced equations with parenthesis, powers, etc.
        • Credit to Connor Mahaffey!
      • Addition: /listvar lists all variables and their values
        • ezcalc.variable
      • Tweak: /calc supports spacing, no spacing, or both!
      • Fix: Typos and code structure
      • Compatibility: 740-817*
    • 1.0
      • Initial release
      • Compatibility: 740-817*
    *Compatibility is only what I can guarantee and what I have tested that specific version with. The plugin doesn't heavily rely on the Bukkit API, so it shouldn't break often.

    Coming Soon (open)

    • Tons of new features and tweaks are coming soon in EZCalc 2. Stay tuned!
    Bugs? (open)
     
    KoryuObihiro and Connor Mahaffey like this.
  2. Offline

    Connor Mahaffey

    Don't know if you'd be interested, but a while back, I made a scientific calculator, which took a string and solved equations (returning a string). It could handle advanced math operations like square roots, powers, parenthesis, negatives, etc.

    Something like 5 ^ (3-1) / 5 would solve correctly.

    If you're interested we could swap code.
     
  3. Offline

    TexasGamer

    That does seem like something of interest to me. At the moment, the plugin just determines which operator to use based on the 2nd argument. I guess a separate command such as /scical <equaltion> would work. Let me know as I would like to talk to you about this.
     
    aquaspeed likes this.
  4. Offline

    Connor Mahaffey

    PM with information sent
     
  5. Offline

    TexasGamer

    Confirmed to work with the newly released build 816.

    EZCalc 1.1 (older downloads)
    Requirements: Java 6+, Bukkit build 740+

    Changes
    • 1.1
      • Addition: /calc supports advanced equations with parenthesis, powers, etc.
        • Credit to Connor Mahaffey!
      • Addition: /listvar lists all variables and their values
        • ezcalc.variable
      • Tweak: /calc supports spacing, no spacing, or both!
      • Fix: Typos and code structure
      • Compatibility: 740-817

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
    Connor Mahaffey likes this.
  6. Offline

    TexasGamer

    I managed to get in a minor bug fix along with compatibility with the latest 818 build. Note that older versions should still work on 818 and this version should work on older builds.

    EZCalc 1.1.1 (older downloads)
    Requirements: Java 6+, Bukkit build 818
    [​IMG]

    Changes
    • 1.1.1
      • Fix: Variables now work without spacing (i.e. x(4+ans) will work now)
      • Compatibility: 818
     
  7. Offline

    TexasGamer

    This new version is a very large update. I currently plan for one more update of similar size.

    EZCalc 1.2 (older downloads)
    Requirements: Java 6+, Bukkit build 818
    [​IMG]

    Changes
    • 1.2
      • Addition: New variables including height, bubble, and stack
      • Addition: Variable z (similar to x and y)
      • Addition: Admins can now /clearvar <name>
        • ezcalc.admin
      • Addition: Help support
      • Addition: A readme is now included with the download
        • Credit to sk89q!
      • Tweak: /setx (and other variables) now take equations like /calc
      • Tweak: Restructured code to be more flexible and easy to read
      • Fix: Typos and incorrect error messages
      • Compatibility: 818-860
     
  8. Offline

    KoryuObihiro

    @TexasGamer Love the plugin. Little tools like this are awesome!

    Although, on an unrelated note, I'm curious as to how you got those nice-looking Github links.
     
  9. Offline

    TexasGamer

    Thanks for the feedback! I'm glad you like it. :)

    As far as the GitHub link, it's just an image (http://i.imgur.com/NOZPK.png). To add the link, highlight the image (like text) and click the Insert/edit link button.
     
  10. Offline

    KoryuObihiro

    Gotcha. **was excited for some dynamically-generated Github links** :p
     
  11. Offline

    TexasGamer

    That would be nice. Luckily, the image/button fits well with the theme.
     
  12. Offline

    TexasGamer

    Version 1.3 is a major update that adds automatic updates (among other features). It is highly recommended that you update to this version.

    Download
    EZCalc 1.3 (older downloads)
    Requirements: Java 6+, Bukkit build 860
    [​IMG]

    Changes
    • 1.3
      • Addition: Added a configuration file (config.yml)
        • Define custom constants
        • Choose update settings (see below!)
        • Thanks to Jayjay110 for his config file tutorial!
      • Addition: Automatic updates
        • Enable in config.yml
        • You can subscribe to a nightly channel for the latest features
        • Note that updates are downloaded to /plugins/AutoUpdater/EZCalc
        • Thanks to Adamki11s for his auto updater library!
      • Fix: Permissions nodes affect usage of variables (health, death) in /setx, /sety, etc.
      • Fix: Added /setz and /getz to the Help plugin registration
      • Tweak: Clean up onEnable() messages
      • Tweak: Moved EZCalc.zip to the /bin folder to help prevent unzipping issues
      • Compatibility: 818-928*
     
  13. Offline

    TexasGamer

    This update fixes all of the annoyances of version 1.3. The next planned version will have support for the built-in "SuperPerms".

    EZCalc 1.4 (older downloads)
    Requirements: Java 6+, Bukkit build 1000
    [​IMG]

    Changes
    • 1.4
      • Addition: Ability to reload config file in-game
      • Addition: Ability to update in-game
      • Tweak: Updates are now only done via command (not at server start)
      • Tweak: Updater output is much more readable and suited for in-game
      • Tweak: Updates are now hosted on Dropbox (instead of my crappy server)
      • Compatibility: 1000*
     
  14. Offline

    wlwhs321

    i hate math !!!! lol
     
  15. Offline

    peng_bears

    Using permissions 3 at first i only added ezcalc.calc and excalc.ans but answer was not able to be used until I also added ezcalc.variable

    Also sometimes when someone dies it tells them "Something went wrong. Setting death count to 0" not a big deal but is there any way to just disable this doing anything with deaths all together? Maybe add a config for allowing or not different parts?

    Is there any way to just have the first two and have it function properly?

    Nice simple thing to have though for people trading, thanks.
     
  16. Offline

    TexasGamer

    • Ans permission node: ezcalc.ans only gives permission for the /ans command (not the usage of the variable). I'll fix this in the next version. (Also see the third point in this post.)
    • Something went wrong: The plugin does this to prevent NullPointExceptions (if you use the variable death and there's nothing defined). It doesn't affect the program.
    • Config: Possibly. I may just divide the commands up into different permission nodes (excalc.variable.x, etc.).
    Thanks for the feedback! :)
     
  17. Offline

    Wolvereness Bukkit Team Member

    I rewrote code in the ParseVariables java file. It seems to work fine, and it adds extra functionality while minimizing the code. I designed the code to be seamless transition, and I removed constants from permissions. It creates a setting called "variablelist", that stores all constants in a list of strings delimited by a comma. This lets servers add as many constants as they want, naming them however they want.
    Code:
    package main.java.com.texasgamer.EZCalc.Math;
    
    import main.java.com.texasgamer.EZCalc.EZCalc;
    import main.java.com.texasgamer.EZCalc.Hooks.Config;
    import main.java.com.texasgamer.EZCalc.Output.Error;
    
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class ParseVariables {
    	public static String replaceVariables(CommandSender sender,String var)
    	{
    		String[] vars = Config.readString("variablelist","var1,var2,var3,var4,var5").split(",");
    		// Custom variables
    		for(String v : vars)
    		{
    			if(var.indexOf(v) != -1)
    			{
    				var = var.replace(v,Config.readString("variables."+v,"0"));
    			}
    		}
    		if(var.indexOf("stack") != -1)
    		{
    			var = var.replace("stack","64");
    		}
    
    		if(var.indexOf("x") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("x",EZCalc.x.get(sender));
    			}
    		}
    		if(var.indexOf("y") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("y",EZCalc.y.get(sender));
    			}
    		}
    		if(var.indexOf("z") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("z",EZCalc.z.get(sender));
    			}
    		}
    		if(var.indexOf("ans") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("ans",Double.toString(EZCalc.ans.get(sender)));
    			}
    		}
    
    		if(var.indexOf("health") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("health",Integer.toString(((Player) sender).getHealth()));
    			}
    		}
    		if(var.indexOf("bubble") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var = var.replace("bubbles", "bubble");
    				var = var.replace("bubble",Integer.toString(((Player) sender).getRemainingAir()));
    			}
    		}
    		if(var.indexOf("air") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var= var.replace("air",Integer.toString(((Player) sender).getRemainingAir()));
    			}
    		}
    		if(var.indexOf("height") != -1)
    		{
    			if(EZCalc.usePermissions && !EZCalc.permissionHandler.has((Player) sender, "ezcalc.variable"))
    			{
    				Error.error("You don't have permission to use that variable!", sender);
    			} else {
    				var= var.replace("height",Double.toString(((Player) sender).getEyeHeight()));
    			}
    		}
    		return var;
    	}
    }
    
    The call to the 'default' values requires this added to the Config.java
    Code:
    
    	public static String readString(String root, String def){
    		Configuration config = load();
    		return config.getString(root,def);
    	}
     
  18. Offline

    TexasGamer

    Looks nice!

    Just to clarify the changes (let me know if I'm wrong or if I missed something):
    1. Constants no longer use the ezcalc.variable permission
    2. Code was streamlined
    3. The custom variables (from the config file) can have their own names
    4. Unlimited custom variables
    I'll try messing with it tomorrow and if it works out, I will apply the changes. If you know how to use GitHub you can fork the project and submit a pull request. If not, I can do it myself. :)
     
  19. Offline

    Wolvereness Bukkit Team Member

    Yes, and I corrected a logical issue when players use 'bubble' variable (for some reason you had it remove every instance of the character 's', which I assume was for 'bubbles').
     
  20. Offline

    peng_bears

    I like to see this collaboration.

    One more suggestion though... anyone attempted to add square root to this or the ability to call current x y z coordinates from the player using the command? I feel this could be useful to players trying to figure out things involving radii, particularly if you allow unlimited and named custom variables that are complex equations.
     
  21. Offline

    Connor Mahaffey

    Actually I wrote the math for the original equation solver for the program. It's able to do square roots but it's looking for this:

    One option would be to have the program replace sqrt(4) with 4. Then solve.
     
  22. Offline

    TexasGamer

    Correct. It might be a bit more difficult to make the change, but I'll look into it.

    I'll also look into getting the player coordinates to assign them to a variable. Something along /setx coordx. Let me know if this is what you were imagining.
     
  23. Offline

    Connor Mahaffey

    Actually wrote that wrong should be replace sqrt(4) with √(4)

    But I think you get the idea.
     
  24. Offline

    peng_bears

    that is pretty much it but it seems as thought it would be just as easy to call it as just coordx as opposed to setting x as it. the idea behind theses suggestions is i could set up a global alias where some command could be like doing sqrt(coordx^2+coordz^2) to return their distance from spawn without needing another plugin (already a few dozen on the server). Real simple math but nice for those players that don't even understand geometry.
     
  25. Offline

    TexasGamer

    As with the other variables (x, ans, etc.) they [xcoord, etc.] can be used in /setx, etc. and also in the main /calc command.

    As far as global aliases, that was the intent of the custom variables in the config file. I've done work (along with @Wolvereness) to allow for unlimited custom variables that can be named anything. The main issue is having more than just numbers for the cvars, but that shouldn't be too hard to fix.

    Also, Permissions 2.x/3.x support will be dropped in favor for BukkitPermissions. :)

    Update: I've added the coordinate variables (xcoord, ycoord, zcoord) along with sqrt. Bugs may exist, so please be patient. Download Snapshot
     
  26. Offline

    TexasGamer

    Work on removing Permissions 2.x/3.x support in favor of SuperPerms has begun.

    Current Progress
     
  27. Offline

    KoryuObihiro

    Easy:

    Code:
    player.hasPermission(string);
    Repeat where necessary. :p
     
  28. Offline

    TexasGamer

    Don't worry, I've already ported permissions for my other three plugins. I am just trying to break up the nodes into more specific sub nodes. Thanks anyways!
     
  29. Offline

    KoryuObihiro

    LOL, yeah. Bukkit's made Perms pretty easy. :p I wonder if anybody's ever coined the term "backseat programming" before.
     
  30. Offline

    TexasGamer

    Current plan with the official release of Minecraft:
    • Superperms support
      • Permissions 3.x support will be dropped!
      • Permissions nodes are subject to change
    • EZCalc API 0.1
    • Clean up calculation code
      • This is taking longer than expected and may be pushed back
    • ...plus stuff that is already complete
      • Square roots, coordinates, and more!
    Work will begin when Bukkit is updated to support the new version of Minecraft. I am glad to be back after a break and am excited to get working again!

    Update: I am on track for an update the week of the 18th of December.
     

Share This Page