📄
pasted-code-1787994946340.txt
txt
751 lines
▶
Create a complete Minecraft plugin called **GenCash** for **Paper 1.20.1**, written in **Java** using **JDK 21** and **Maven**.
The plugin should be fully functional, optimized, cleanly coded, and ready to compile and use on a production Minecraft server.
## 1. Main Concept
The plugin should work similarly to a **GenCash / farming generator system**.
Players mine special wheat crops using special hoes. Wheat does not give normal Minecraft drops. Instead, players have a chance to earn a custom currency called **VPLN**.
The entire system must be server-side and should not require players to install any mods.
---
# 2. Custom Farming Field
Add the command:
`/trawa`
When an admin uses `/trawa`, give them a **special farming block/field item**.
This item should be recognizable as the special GenCash farming field.
When the special field is placed, it creates the special farming area/block where the custom wheat can be planted.
The field should be protected from normal breaking and interaction unless the player is using the correct GenCash tools.
---
# 3. Special Seeds
Add:
`/nasionko`
This command gives the player a **special GenCash wheat seed**.
The seed should have a custom name and lore so players can clearly recognize it.
Example:
**GenCash Seed**
When an admin plants the special seed on the special farming field:
* The wheat should immediately grow to its maximum growth stage.
* It must use a custom GenCash wheat system.
* Breaking the wheat must NOT give normal wheat or seeds.
* After the wheat is harvested, it should automatically grow back after a short delay.
* The player should be able to repeatedly harvest the same crop.
The crop should effectively behave like an infinite generator.
---
# 4. GenCash Hoes
The main tool of the plugin is a set of special hoes.
There are **8 levels of hoes**:
* Hoe Level 1
* Hoe Level 2
* Hoe Level 3
* Hoe Level 4
* Hoe Level 5
* Hoe Level 6
* Hoe Level 7
* Hoe Level 8
Each hoe must have:
* A unique name
* A unique level
* Custom lore
* A unique persistent identifier using PersistentDataContainer
* A durability system or another suitable protection system if necessary
Players must NOT be able to harvest GenCash wheat using normal Minecraft tools.
GenCash wheat can ONLY be harvested using a valid GenCash hoe.
If a player tries to break it with:
* their hand
* a normal hoe
* a pickaxe
* an axe
* a shovel
* a sword
* any other normal item
the harvest must be cancelled.
The crop must remain intact.
---
# 5. Player Hoe
Add:
`/startmotyka`
This gives the player a **GenCash Hoe Level 1**.
Players can use this command to obtain their starter hoe.
The command should have an appropriate permission/cooldown system so players cannot abuse it if necessary.
---
# 6. Admin Hoe Command
Add:
`/adminmotyka `
Example:
`/adminmotyka 4 Steve`
This gives Steve a **GenCash Hoe Level 4**.
Valid levels:
`1-8`
If an invalid level is entered, show an error message.
Only admins or players with a dedicated permission such as:
`gencash.admin`
should be able to use this command.
Example:
`/adminmotyka 8 Steve`
should give Steve the Level 8 hoe.
---
# 7. VPLN Currency
Create a completely custom currency called:
**VPLN**
Do NOT depend on Vault for the actual currency system.
The plugin should store each player's VPLN balance internally.
Use a reliable storage system such as:
* YAML
* SQLite
* or another lightweight persistent database.
The balance must NOT reset after a server restart.
Use precise decimal values because VPLN can contain grosze.
For example:
* 0.01 VPLN
* 0.50 VPLN
* 1.00 VPLN
* 2.50 VPLN
---
# 8. VPLN Command
Add:
`/vpln`
When the player uses the command, display their current VPLN balance.
Example:
`Your VPLN balance: 125.50 VPLN`
Make the message customizable in the config.
---
# 9. VPLN Rewards From Hoes
When a player harvests GenCash wheat with a special hoe, they should have a **chance** to receive VPLN.
IMPORTANT:
The player must NOT receive VPLN every single time they harvest wheat.
There must be a configurable random chance.
The reward ranges are:
### Hoe Level 1
`0.01 - 0.05 VPLN`
Equivalent to:
`1-5 groszy`
### Hoe Level 2
`0.01 - 0.10 VPLN`
Equivalent to:
`1-10 groszy`
### Hoe Level 3
`0.01 - 0.15 VPLN`
Equivalent to:
`1-15 groszy`
### Hoe Level 4
`0.01 - 0.25 VPLN`
Equivalent to:
`1-25 groszy`
### Hoe Level 5
`0.10 - 0.50 VPLN`
Equivalent to:
`10-50 groszy`
### Hoe Level 6
`0.20 - 0.70 VPLN`
Equivalent to:
`20-70 groszy`
### Hoe Level 7
`0.50 - 1.50 VPLN`
Equivalent to:
`50 groszy - 1.50 zł`
### Hoe Level 8
`1.20 - 2.50 VPLN`
Equivalent to:
`1.20 zł - 2.50 zł`
The exact chance and reward ranges MUST be configurable in `config.yml`.
---
# 10. Reward Calculation
When the player successfully harvests the wheat:
1. Check whether the player is using a valid GenCash hoe.
2. Detect the hoe level.
3. Determine whether the player won a VPLN reward.
4. If they win, generate a random amount within the range for that hoe level.
5. Add the amount directly to the player's VPLN balance.
6. Do NOT drop physical items.
7. Do NOT drop wheat.
8. Do NOT drop seeds.
9. Do NOT drop money items.
The currency should be virtual only.
---
# 11. Reward Title
When a player receives VPLN from harvesting wheat, show a title.
Example:
Green title:
`You harvested 10 groszy`
White subtitle:
`Type /portfel to see how much you earned`
The title should support Minecraft color codes and MiniMessage if appropriate.
The exact wording must be configurable.
For example, if the player receives:
`0.10 VPLN`
the title should display:
**GREEN:** `You harvested 10 groszy`
**WHITE:** `Type /portfel to see how much you earned`
If the player receives `1.00 VPLN`, display:
`You harvested 1 zł`
Make the formatting intelligent so that grosze and zł are displayed naturally.
---
# 12. Special Brushes
Add another special tool type called:
**Brush**
There are 8 brushes:
* 3x3 Brush
* 4x4 Brush
* 5x5 Brush
* 6x6 Brush
* 7x7 Brush
* 8x8 Brush
The brush works similarly to a special hoe but harvests multiple wheat blocks at once.
The size determines the area harvested.
For example:
### 3x3 Brush
Harvest a 3x3 area of GenCash wheat.
### 4x4 Brush
Harvest a 4x4 area.
### 5x5 Brush
Harvest a 5x5 area.
Continue up to:
### 8x8 Brush
Harvest an 8x8 area.
The area should be calculated around the block the player interacts with.
Only valid GenCash wheat should be affected.
Do NOT allow brushes to destroy normal Minecraft blocks.
---
# 13. Brush Reward Levels
The brushes correspond to the same reward level as their size.
For example:
* 3x3 Brush = Hoe Level 3 rewards
* 4x4 Brush = Hoe Level 4 rewards
* 5x5 Brush = Hoe Level 5 rewards
* 6x6 Brush = Hoe Level 6 rewards
* 7x7 Brush = Hoe Level 7 rewards
* 8x8 Brush = Hoe Level 8 rewards
The reward for each harvested crop should use the corresponding level's reward configuration.
IMPORTANT:
The brush should NOT multiply the reward incorrectly or give one reward for the entire area unless configured.
Each harvested GenCash wheat block should independently have its own reward chance.
---
# 14. Admin Brush Command
Add:
`/dajbrusha `
Examples:
`/dajbrusha 3x3 Steve`
`/dajbrusha 5x5 Steve`
`/dajbrusha 8x8 Steve`
Valid brush sizes:
`3x3`
`4x4`
`5x5`
`6x6`
`7x7`
`8x8`
Only admins or players with:
`gencash.admin`
can use this command.
---
# 15. /podloz Command
Add:
`/podloz `
This command allows an admin to configure a specific GenCash block to give a fixed VPLN amount when harvested.
For example:
`/podloz 1`
means the configured block gives:
`1.00 VPLN`
Another example:
`/podloz 0.50`
means:
`0.50 VPLN`
The amount must be added directly to the player's VPLN balance.
The command should work only for admins.
If necessary, make the command work by having the admin look at the GenCash block and execute:
`/podloz 1`
This should set that block's reward to 1.00 VPLN.
Make sure this mechanic does NOT conflict with the normal random hoe rewards.
---
# 16. Anti-Abuse Protection
The plugin must prevent players from abusing the system.
Implement protections against:
* Breaking GenCash wheat with normal tools
* Breaking GenCash fields
* Breaking crops without permission
* Automatically farming crops using invalid methods
* Exploiting block updates
* Receiving duplicate rewards from the same harvest event
* Double rewards from brushes
* Multiple reward events being triggered for one block
* Breaking crops with pistons or other unintended mechanics
* Duplication exploits
A player should receive rewards only from a legitimate GenCash harvest.
---
# 17. Crop Regeneration
After GenCash wheat is harvested:
* The crop should disappear/reset.
* After a configurable delay, it should automatically become fully grown again.
* The regeneration delay must be configurable in `config.yml`.
Example:
`regeneration-delay: 2`
This means the wheat regenerates after 2 seconds.
---
# 18. Permissions
Create permissions such as:
`gencash.admin`
`gencash.start`
`gencash.vpln`
Configure command permissions properly.
Admins should be able to use all administrative commands.
---
# 19. Configuration
Create a detailed `config.yml`.
Everything important should be configurable, including:
* Messages
* Colors
* Reward chances
* Minimum rewards
* Maximum rewards
* Hoe levels
* Brush sizes
* Crop regeneration time
* VPLN formatting
* Admin permissions
* Title/subtitle messages
* Sounds
* Particle effects if used
Example configuration structure:
```yaml
currency:
name: "VPLN"
decimal-places: 2
rewards:
hoe-1:
chance: 10.0
min: 0.01
max: 0.05
hoe-2:
chance: 10.0
min: 0.01
max: 0.10
hoe-3:
chance: 8.0
min: 0.01
max: 0.15
hoe-4:
chance: 7.0
min: 0.01
max: 0.25
hoe-5:
chance: 6.0
min: 0.10
max: 0.50
hoe-6:
chance: 5.0
min: 0.20
max: 0.70
hoe-7:
chance: 4.0
min: 0.50
max: 1.50
hoe-8:
chance: 3.0
min: 1.20
max: 2.50
crop:
regeneration-delay: 2
messages:
reward-title: "&aWykopałeś %amount%"
reward-subtitle: "&fWpisz /portfel aby zobaczyć ile zarobiłeś"
```
Use `BigDecimal` or another safe method for currency calculations so floating-point errors do not cause incorrect balances.
---
# 20. Data Storage
Store VPLN balances persistently.
The data must survive:
* Server restart
* Server shutdown
* Plugin reload
* Player reconnect
Use UUIDs rather than player names as the primary player identifier.
---
# 21. Visual Effects
Make the plugin feel polished and similar to a modern GenCash server.
When a player successfully earns VPLN:
* Show the title
* Optionally play a short sound
* Optionally spawn subtle particles
* Do not spam effects on every harvest if the player did not receive a reward
All effects should be configurable.
---
# 22. Important Technical Requirements
Use:
* Paper 1.20.1
* Java 21
* Maven
* Bukkit/Paper API
* PersistentDataContainer for identifying custom items and blocks
* UUID-based player data
* Thread-safe and safe storage handling
* No unnecessary dependencies
Do NOT require client-side mods.
Avoid NMS unless absolutely necessary.
Make the plugin compatible specifically with **Paper 1.20.1**.
---
# 23. Commands Summary
The final plugin must contain:
### Player Commands
`/startmotyka`
Gives Level 1 GenCash Hoe.
`/vpln`
Shows the player's VPLN balance.
### Admin Commands
`/trawa`
Gives the special GenCash farming field.
`/nasionko`
Gives the special GenCash seed.
`/adminmotyka `
Gives a GenCash hoe from level 1 to 8.
`/dajbrusha `
Gives a brush from 3x3 to 8x8.
`/podloz `
Sets a fixed VPLN reward for the selected GenCash block.
---
# 24. Important Behavior Rules
The plugin MUST follow these rules:
* Normal wheat must behave normally.
* Only GenCash wheat is affected by the plugin.
* Normal tools cannot harvest GenCash wheat.
* GenCash wheat gives no normal Minecraft drops.
* GenCash wheat automatically regenerates.
* Players can repeatedly harvest the same GenCash crop.
* VPLN is virtual and never drops as an item.
* Rewards are random and do NOT happen every harvest.
* Hoe levels determine the reward range.
* Brush sizes correspond to reward levels.
* Admins can give higher-level tools.
* Players start with Level 1.
* VPLN balances persist permanently.
* Rewards must never duplicate.
* All important values must be configurable.
* The plugin must be optimized and not cause unnecessary server lag.
---
# 25. Final Deliverable
Provide the complete project structure and ALL required Java source files.
Include:
* Main plugin class
* Command classes
* Event listeners
* VPLN economy manager
* Player data/storage manager
* Hoe manager
* Brush manager
* GenCash crop manager
* Reward manager
* Configuration manager
* Utility classes
* plugin.yml
* config.yml
* pom.xml
The result must compile successfully without errors.
Do not provide pseudo-code.
Write real, complete Java code that can be compiled and placed directly into a Paper 1.20.1 server.
Before finishing, check the entire project for:
* Compilation errors
* Missing imports
* Missing classes
* Incorrect Bukkit/Paper API usage
* Command registration errors
* Permission errors
* Currency calculation errors
* Duplicate reward bugs
* Item identification bugs
* Block regeneration bugs
* Brush area calculation bugs
The final result should be a polished, production-ready **GenCash-style farming and VPLN economy plugin**.
Create the Maven/Paper project metadata and default configuration.
Implement persistent VPLN storage, configurable rewards, custom item identification, and formatting.
Implement field/crop placement, protected harvesting, regeneration, brushes, and anti-abuse listeners.
Add and register all player/admin commands with permissions.
Created the complete GenCash project with:
Maven configuration for Paper 1.20.1 and Java 21.
plugin.ymlwith all requested commands and permissions.Configurable VPLN rewards, regeneration, messages, sounds, and particles.
Persistent UUID-based VPLN storage in
players.yml.Custom GenCash fields, seeds, hoes, and 3x3–8x8 brushes using PersistentDataContainer identifiers.
Protected crops and fields with anti-piston, explosion, fluid, burn, and entity protections.
Configurable random rewards with intelligent grosze/zł formatting.
Crop regeneration after configurable delays.
Fixed per-crop rewards through
/podloz.All requested player and admin commands.
package com.gencash;
import com.gencash.command.AdminBrushCommand;
import com.gencash.command.AdminHoeCommand;
import com.gencash.command.FieldCommand;
import com.gencash.command.PodlozCommand;
import com.gencash.command.SeedCommand;
import com.gencash.command.StartHoeCommand;
import com.gencash.command.VplnCommand;
import com.gencash.config.GenCashConfig;
import com.gencash.economy.CurrencyManager;
import com.gencash.economy.PlayerDataManager;
import com.gencash.item.ItemManager;
import com.gencash.listener.GenCashListener;
import com.gencash.reward.RewardManager;
import com.gencash.world.CropManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public final class GenCashPlugin extends JavaPlugin {
private GenCashConfig genCashConfig;
private PlayerDataManager playerDataManager;
private CurrencyManager currencyManager;
private ItemManager itemManager;
private RewardManager rewardManager;
private CropManager cropManager;
@Override
public void onEnable() {
saveDefaultConfig();
genCashConfig = new GenCashConfig(this);
playerDataManager = new PlayerDataManager(this);
playerDataManager.load();
currencyManager = new CurrencyManager(playerDataManager, genCashConfig);
itemManager = new ItemManager(this, genCashConfig);
rewardManager = new RewardManager(genCashConfig, currencyManager);
cropManager = new CropManager(this, itemManager, rewardManager, genCashConfig);
cropManager.load();
Bukkit.getPluginManager().registerEvents(
new GenCashListener(cropManager, itemManager, genCashConfig), this);
registerCommands();
}
@Override
public void onDisable() {
if (cropManager != null) {
cropManager.save();
}
if (playerDataManager != null) {
playerDataManager.save();
}
}
private void registerCommands() {
getCommand("trawa").setExecutor(new FieldCommand(itemManager));
getCommand("nasionko").setExecutor(new SeedCommand(itemManager));
getCommand("startmotyka").setExecutor(new StartHoeCommand(itemManager, genCashConfig));
getCommand("adminmotyka").setExecutor(new AdminHoeCommand(itemManager, genCashConfig));
getCommand("dajbrusha").setExecutor(new AdminBrushCommand(itemManager, genCashConfig));
getCommand("podloz").setExecutor(new PodlozCommand(cropManager, genCashConfig));
getCommand("vpln").setExecutor(new VplnCommand(currencyManager, genCashConfig));
}
}