Skip to content

Commit

Permalink
Update to 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotiny committed Mar 27, 2024
1 parent e035062 commit 30982e5
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 781 deletions.
4 changes: 2 additions & 2 deletions HanaLib.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
Expand Down
49 changes: 39 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<div>

[![](https://jitpack.io/v/Lotiny/HanaLib.svg)](https://jitpack.io/#Lotiny/HanaLib)
[![Discord](https://img.shields.io/discord/1061534844494028830.svg?color=lime&label=Discord)](https://discord.gg/qBqQYgRHaF)
[![Donation](https://img.shields.io/badge/Donation-PayPal-blue)](https://www.paypal.com/paypalme/Lotiny2825)

</div>
Expand All @@ -17,7 +16,7 @@
- Menu
- Command
- ConfigFile
- Scoreboard (Credit go to Assemble https://github.com/ThatKawaiiSam/Assemble)
- MongoDB
- and more!

---
Expand Down Expand Up @@ -62,15 +61,12 @@ import me.lotiny.libs.HanaLib;

import java.util.Arrays;

public class ExampleClass extends JavaPlugin {
public class MainClass extends JavaPlugin {

@Override
public void onEnable() {
// Init HanaLib
HanaLib hanaLib = new HanaLib(this);
// Register command handler.
hanaLib.registerCommandHandler();
// Register menu handler.
hanaLib.registerMenuHandler();

// Register commands.
registerCommands(hanaLib);
Expand All @@ -84,9 +80,7 @@ public class ExampleClass extends JavaPlugin {
new ExampleCommand4(),
// ...
new ExampleCommand99()
).forEach(command -> {
hanaLib.getCommandHandler().register(command);
});
).forEach(command -> hanaLib.getCommandHandler().register(command));
}
}
```
Expand Down Expand Up @@ -133,6 +127,9 @@ public class ExampleMenu extends Menu {
@Override
public void onClick(Player player, int slot, ClickType clickType) {
player.sendMessage(CC.GREEN + "CLICKED TEST ITEM!");

// Play Sound.CLICK to player.
playClickSound(player);
}
});

Expand Down Expand Up @@ -164,4 +161,36 @@ public class ExampleCommand extends HanaCommand {
player.playSound(player.getLocation(), Sound.CHEST_OPEN, 1, 1);
}
}
```

#### MongoDB

```java
import com.mongodb.client.MongoCollection;
import lombok.Getter;
import me.lotiny.libs.database.Mongo;
import me.lotiny.libs.database.MongoCredentials;
import me.lotiny.libs.utils.ServerUtil;
import me.lotiny.uhc.HanaUHC;
import org.bson.Document;
import org.bukkit.Bukkit;

@Getter
public class ExampleMongoDB extends Mongo {

private final MongoCollection<Document> collection;

public MongoManager() {
super(MongoCredentials.of(
"mongodb://localhost:27017",
"database_name"
));

// Connect to database.
connect();

// Set the collection.
this.collection = this.getDatabase().getCollection("collection_name");
}
}
```
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>me.lotiny</groupId>
<artifactId>HanaLib</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/me/lotiny/libs/HanaLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
import me.lotiny.libs.command.CommandHandler;
import me.lotiny.libs.hotbar.HotbarHandler;
import me.lotiny.libs.menu.MenuHandler;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/me/lotiny/libs/command/CommandErrorMessage.java

This file was deleted.

8 changes: 2 additions & 6 deletions src/main/java/me/lotiny/libs/command/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public boolean onCommand(CommandSender commandSender, org.bukkit.command.Command
HanaCommand cmd = commands.get(command.getName());

if (cmd.getCommand().inGameOnly() && commandSender instanceof ConsoleCommandSender) {
commandSender.sendMessage(CC.translate(CommandErrorMessage.ONLY_PLAYER.getMessage()));
commandSender.sendMessage(CC.RED + "Only player can execute this command.");
return true;
}

if (cmd.getCommand().permission() != null && !cmd.getCommand().permission().isEmpty() && !commandSender.hasPermission(cmd.getCommand().permission())) {
commandSender.sendMessage(CC.translate(CommandErrorMessage.NO_PERM.getMessage()));
commandSender.sendMessage(CC.RED + "No Permission.");
return true;
}

Expand All @@ -112,8 +112,4 @@ public List<String> onTabComplete(CommandSender commandSender, org.bukkit.comman

return toReturn;
}

public void setErrorMessage(CommandErrorMessage commandErrorMessage, String message) {
commandErrorMessage.setMessage(message);
}
}
45 changes: 44 additions & 1 deletion src/main/java/me/lotiny/libs/config/ConfigFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,50 @@ public ConfigFile(String name) {

// If the file does not exist in the data folder, attempt to save it from resources.
if (!this.file.exists()) {
HanaLib.getInstance().saveResource(name, false);
try {
HanaLib.getInstance().saveResource(name, false);
} catch (Exception ex) {
try {
this.file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}

try {
// Load the configuration from the file.
this.load(this.file);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}

/**
* Create a `ConfigFile` object with the specified name.
*
* @param path The path where configuration file.
* @param name The name of the configuration file.
*/
public ConfigFile(String path, String name) {
File folder = new File(HanaLib.getInstance().getDataFolder(), path);
if (!folder.exists()) {
folder.mkdir();
}

this.file = new File(folder, name);

// If the file does not exist in the data folder, attempt to save it from resources.
if (!this.file.exists()) {
try {
HanaLib.getInstance().saveResource(path + "/" + name, false);
} catch (Exception ex) {
try {
this.file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}

try {
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/me/lotiny/libs/hotbar/item/Hotbar.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package me.lotiny.libs.hotbar.item;

import me.lotiny.libs.HanaLib;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.PlayerInventory;
Expand All @@ -10,14 +8,6 @@

public abstract class Hotbar implements Listener {

public Hotbar() {
if (hasListeners()) {
Bukkit.getPluginManager().registerEvents(this, HanaLib.getInstance());
}
}

public abstract boolean hasListeners();

public abstract List<HotbarItem> getItems();

public void apply(Player player, boolean clearItems, boolean clearArmors) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lotiny/libs/menu/menu/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import lombok.Getter;
import lombok.Setter;
import me.lotiny.libs.chat.CC;
import me.lotiny.libs.utils.Tasks;
import me.lotiny.libs.menu.MenuHandler;
import me.lotiny.libs.menu.slots.Slot;
import me.lotiny.libs.utils.Tasks;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lotiny/libs/menu/menu/PaginatedMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import me.lotiny.libs.utils.ItemBuilder;
import me.lotiny.libs.menu.slots.Slot;
import me.lotiny.libs.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
Expand Down
105 changes: 0 additions & 105 deletions src/main/java/me/lotiny/libs/scoreboard/Assemble.java

This file was deleted.

Loading

0 comments on commit 30982e5

Please sign in to comment.