Skip to content

Commit

Permalink
Experience, Heal and PotionEffect items!
Browse files Browse the repository at this point in the history
  • Loading branch information
assada committed Jan 10, 2022
1 parent aeea63b commit e2e9e20
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@
[![Packaing Jar And Upload](https://github.com/assada/ItemDatabaseLink/actions/workflows/maven.yml/badge.svg)](https://github.com/assada/ItemDatabaseLink/actions/workflows/maven.yml)

## Description
With IDL you can send some materials/items to players via database.
With IDL you can send some materials/items/potion effects to players via database.

Example:
Examples:
```sql
INSERT INTO minecraft.idl_items (uuid, type, value, qty, status) VALUES ('3630a9c7-1b18-3c4d-9cc9-462674d3795e', 'Item', 'DIAMOND', 64, 0)
```

Gives 64 diamonds for player with uuid 3630a9c7-1b18-3c4d-9cc9-462674d3795e
```sql
INSERT INTO minecraft.idl_items (uuid, type, value, qty, status) VALUES ('3630a9c7-1b18-3c4d-9cc9-462674d3795e', 'PotionEffect', 'SPEED', 999, 0)
```
Apply speed potion(for 99.9 seconds) for player with uuid 3630a9c7-1b18-3c4d-9cc9-462674d3795e

```sql
INSERT INTO minecraft.idl_items (uuid, type, value, qty, status) VALUES ('3630a9c7-1b18-3c4d-9cc9-462674d3795e', 'Experience', 'Experience', 10000, 0)
```
Add 10000 experience for player with uuid 3630a9c7-1b18-3c4d-9cc9-462674d3795e
```sql
INSERT INTO minecraft.idl_items (uuid, type, value, qty, status) VALUES ('3630a9c7-1b18-3c4d-9cc9-462674d3795e', 'Heal', 'Heal', 0, 0)
```
Full heal player with uuid 3630a9c7-1b18-3c4d-9cc9-462674d3795e

## Features
* Databases: MySQL (more in future)
* Databases: MySQL (more in future if requested)
* `/get` command for getting all new items to inventory (or dropping on ground if inventory is full)
* flexible configuration
* AuthMe integration
* AuthMe integration (DB requests after successful login)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dead.guru</groupId>
<artifactId>ItemDatabaseLink</artifactId>
<version>1.1-SNAPSHOT</version>
<version>1.2-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/idl/GetCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -42,6 +44,28 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
Bukkit.getLogger().warning("[ItemDatabaseLink] Item %s not found!".formatted(itemRecord.getValue()));
}
}
if (itemRecord.getType().equals("Experience")) {
player.giveExp(itemRecord.getQty());
gotIds.add(itemRecord.getId());
player.sendMessage(ChatColor.DARK_GREEN + "[" + config.getString("general.chatPrefix") + ChatColor.DARK_GREEN + "]" + ChatColor.GREEN + " Done! Experience increased!");
}
if (itemRecord.getType().equals("Heal")) {
player.setHealth(20.0);
player.setFoodLevel(20);
player.setFireTicks(0);
gotIds.add(itemRecord.getId());
player.sendMessage(ChatColor.DARK_GREEN + "[" + config.getString("general.chatPrefix") + ChatColor.DARK_GREEN + "]" + ChatColor.GREEN + " Done! You are completely healed and completely full!");
}
if (itemRecord.getType().equals("PotionEffect")) {
PotionEffectType effectType = PotionEffectType.getByName(itemRecord.getValue().toUpperCase());
if (effectType != null) {
player.addPotionEffect(new PotionEffect(effectType, itemRecord.getQty(), 1, true, true, true));
gotIds.add(itemRecord.getId());
player.sendMessage(ChatColor.DARK_GREEN + "[" + config.getString("general.chatPrefix") + ChatColor.DARK_GREEN + "]" + ChatColor.GREEN + " Done! Are you already feeling the effect?");
} else {
Bukkit.getLogger().warning("[ItemDatabaseLink] PotionEffect %s not found!".formatted(itemRecord.getValue()));
}
}
}
if (items.size() > 0) {
if (this.getFreeSlots(player) >= items.size()) {
Expand All @@ -66,7 +90,8 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
player.sendMessage(ChatColor.DARK_GREEN + "[" + config.getString("general.chatPrefix") + ChatColor.DARK_GREEN + "]" + ChatColor.RED + " Error! Please clear your inventory first.");
}
}

}
if(gotIds.size() > 0) {
this.checker.updateStatus(gotIds, 1); //TODO: Enum statuses?
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ItemDatabaseLink # the plugins name as it should appear in the plugin list /pl
version: 1.1 # the plugin's version
version: 1.2 # the plugin's version
author: Assada
main: idl.Main
api-version: 1.18 # the version of the API you want to use, required starting with 1.13
Expand Down

0 comments on commit e2e9e20

Please sign in to comment.