In-Depth Description of SimpleCalculator
SimpleCalculator is a robust and lightweight Minecraft Spigot plugin designed to provide players with a high-performance calculator directly within the game. Compatible with Minecraft versions 1.21, 1.21.1, 1.21.3, and 1.21.5, this plugin allows users to perform mathematical calculations using simple commands, making it a versatile tool for educational purposes, in-game problem-solving, or just for fun. The plugin is built with efficiency in mind, leveraging the JavaScript ScriptEngine for complex calculations while offering a fallback mode for basic operations if the engine is unavailable.
Feature Highlights
- Commands: Supports three intuitive commands: /calculate, /calc, and /c, each performing the same calculation function but offering flexibility in command preference.
- Mathematical Operations: Handles core operations including addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^). Advanced functions like sin, cos, tan, and pow are also supported via the JavaScript engine.
- Tab Completion: Provides structured tab completion to guide users through the input format <number> <operator> <number>. For example, typing /c and pressing tab suggests numbers (e.g., "1"), then operators (e.g., "+"), and finally another number (e.g., "2").
- Customizable Configuration: Includes a config.yml file where administrators can customize settings such as:
- Message prefix and colors for errors, results, and operations.
- Decimal place formatting (enable/disable and set precision).
- Option to toggle the use of the JavaScript engine for calculations.
- Calculation timeout to prevent server lag from complex expressions.
- Permission System: Implements a permission node calculator.use (default: true) to control access to the calculator commands.
- Error Handling: Robust error handling with user-friendly messages for invalid expressions, division by zero, or syntax errors, along with server-side logging for debugging.
- Performance Optimization: Uses the JavaScript ScriptEngine for efficient calculation of complex expressions, with a fallback to basic parsing for environments where the engine is unavailable.
Important Information
- Dependencies: Requires a Spigot server running Minecraft 1.21 or a compatible version (1.21.1, 1.21.3, 1.21.5). The plugin uses the Spigot API and Java 17 for compilation.
- Limitations: Does not support sqrt or cbrt operations as they were explicitly removed per user request. Complex expressions beyond basic operations may require the JavaScript engine to be enabled.
- Usage Example: Typing /c 5 + 3 will return [Calculator] 5 + 3 = 8.00 (with default formatting). If the input is invalid, a clear error message is displayed, e.g., [Calculator] Invalid expression: Division by zero.
This plugin is ideal for server administrators looking to add a functional calculator to their Minecraft server, offering both simplicity for players and customization options for server owners.