Skip to content

Commit

Permalink
Merge pull request #1 from luisBazanDev/development
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
luisBazanDev committed Aug 11, 2023
2 parents a724254 + ebdf2bd commit 2a8bc8b
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 75 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# Money Mobs
Money mobs is a minecraft plugin for the player to earn money when killing a mobs, it also simplifies many of the options currently existing.

**Suport server:** https://discord.gg/UhBaxpFv6f

## Licence [MIT](./LICENSE.md)

## Permissions
- `moneymobs.command.moneymobs` - For use /moneymobs command
- `moneymobs.command.moneymobs.credits` - For use /moneymobs credits
- `moneymobs.command.moneymobs` - For use /moneymobs
- `moneymobs.command.moneymobs.info` - For use /moneymobs info
- `moneymobs.command.moneymobs.about` - For use /moneymobs about
- `moneymobs.command.moneymobs.reload` - Reaload config of the plugin
- `moneymobs.drops` - If player don't have this permission, the system don't worked

## Commands
- `/moneymobs` - Display info of the mobs.
- `/moneymobs credits` - Display credits of the plugin.
- `/moneymobs info` - Display info of the mobs.
- `/moneymobs about` - Display about of the plugin.
- `/moneymobs reload` - Reload config of the plugin.

## Default Config
Expand Down
8 changes: 1 addition & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>pe.bazan.luis.plugins</groupId>
<artifactId>MoneyMobs</artifactId>
<version>1.0.1</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>MoneyMobs</name>
Expand Down Expand Up @@ -81,11 +81,5 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core</artifactId>
<version>8.4.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
25 changes: 20 additions & 5 deletions src/main/java/pe/bazan/luis/plugins/moneymobs/MoneyMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import net.milkbowl.vault.economy.Economy;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import pe.bazan.luis.plugins.moneymobs.commands.MoneyMobsCmd;
import pe.bazan.luis.plugins.moneymobs.commands.BaseCommand;
import pe.bazan.luis.plugins.moneymobs.utils.MsgFormat;

public final class MoneyMobs extends JavaPlugin {
private Economy econ;
private MobsManager mobsManager;
private static MoneyMobs instance;

@Override
public void onEnable() {
Expand All @@ -16,14 +18,23 @@ public void onEnable() {
saveDefaultConfig();
this.mobsManager = new MobsManager(this);
new MobKilledByPlayer(this);
new MoneyMobsCmd(this);
setupEconomy();
if (!setupEconomy()) {
getLogger().info(MsgFormat.error("You don't have a economy provider, please install a economy plugin and retry :)"));
getServer().getPluginManager().disablePlugin(this);
return;
}
loadCommand();
getLogger().info("Plugin Enabled");
instance = this;
}

@Override
public void onDisable() {
// Plugin shutdown logic
getLogger().info(MsgFormat.error("Plugin disabled."));
}

private void loadCommand() {
getCommand("moneymobs").setExecutor(new BaseCommand());
}

private boolean setupEconomy() {
Expand All @@ -32,7 +43,7 @@ private boolean setupEconomy() {
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
getLogger().info("Don't provider");
getLogger().info("Don't have a economy provider");
return false;
}
econ = rsp.getProvider();
Expand All @@ -46,4 +57,8 @@ public MobsManager getMobsManager() {
public Economy getEcon() {
return econ;
}

public static MoneyMobs getInstance() {
return instance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package pe.bazan.luis.plugins.moneymobs.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import pe.bazan.luis.plugins.moneymobs.MobsManager;
import pe.bazan.luis.plugins.moneymobs.utils.MsgFormat;

import java.util.ArrayList;
import java.util.List;

public class BaseCommand implements CommandExecutor, TabCompleter {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1) {
baseCommand(sender, args);
return false;
}
switch (args[0].toLowerCase()) {
case "about":
if (!sender.hasPermission("moneymobs.command.moneymobs.about"))
return noPermissions(sender);
CreditsCommand.run(sender, args);
break;
case "reload":
if (!sender.hasPermission("moneymobs.command.moneymobs.reload"))
return noPermissions(sender);
ReloadCommand.run(sender, args);
break;
case "info":
if (!sender.hasPermission("moneymobs.command.moneymobs.info"))
return noPermissions(sender);
baseCommand(sender, args);
break;
default:
baseCommand(sender, args);
break;
}
return false;
}

private boolean noPermissions(CommandSender sender) {
sender.sendMessage(MsgFormat.format("You don't have permissions."));
return false;
}

private boolean baseCommand(CommandSender sender, String[] args) {
sender.sendMessage(MsgFormat.format("&m=================&6&l Money Mobs &f&m================="));
MobsManager.getMobs().forEach((k, v) -> {
sender.sendMessage(MsgFormat.format(String.format(
"&e%s: &cmin: %s$ &amax: %s$",
k,
v.getMin(),
v.getMax()
)));
});
sender.sendMessage(MsgFormat.format("&m=============================================="));
return false;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
List<String> result = new ArrayList<>();
if (args.length == 1) {
String search = args[0];
String[] commands = new String[]{"about", "reload", "info"};
for (String cmd : commands) {
if (cmd.startsWith(search)) {
result.add(cmd);
}
}
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package pe.bazan.luis.plugins.moneymobs.commands;

import org.bukkit.command.CommandSender;
import pe.bazan.luis.plugins.moneymobs.MoneyMobs;
import pe.bazan.luis.plugins.moneymobs.utils.MsgFormat;

public class CreditsCommand {
public static void run(CommandSender sender, String[] args) {
sender.sendMessage(MsgFormat.format("&f&m=================&6&l Money Mobs &f&m================="));
sender.sendMessage(MsgFormat.format(String.format("&f&lVersion: %s", MoneyMobs.getInstance().getDescription().getVersion())));
sender.sendMessage(MsgFormat.format(String.format("&f&lAuthors: %s", MoneyMobs.getInstance().getDescription().getAuthors())));
sender.sendMessage(MsgFormat.format("&0&lGit&f&lHub&7: https://github.com/luisBazanDev/MoneyMobs"));
sender.sendMessage(MsgFormat.format("&f&m=============================================="));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pe.bazan.luis.plugins.moneymobs.commands;

import org.bukkit.command.CommandSender;
import pe.bazan.luis.plugins.moneymobs.MoneyMobs;
import pe.bazan.luis.plugins.moneymobs.utils.MsgFormat;

public class ReloadCommand {
public static void run(CommandSender sender, String[] args) {
sender.sendMessage(MsgFormat.format("&aReloading..."));
MoneyMobs.getInstance().reloadConfig();
MoneyMobs.getInstance().getMobsManager().registerMobs();
sender.sendMessage(MsgFormat.format("&aReload successfully."));
}
}
16 changes: 16 additions & 0 deletions src/main/java/pe/bazan/luis/plugins/moneymobs/utils/MsgFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pe.bazan.luis.plugins.moneymobs.utils;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.ChatColor;

public class MsgFormat {
public static String format(String txt) {
return ChatColor.translateAlternateColorCodes('&', txt);
}

public static String error(String txt) {
return Component.text(txt).color(TextColor.color(0xFF0000)).content();
}
}
11 changes: 8 additions & 3 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
name: MoneyMobs
description: Plugin for the player to earn money when killing a mob
authors: [ 'Luis Bazán' ]
version: '${project.version}'
main: pe.bazan.luis.plugins.moneymobs.MoneyMobs
api-version: 1.19
prefix: MoneyMobs
depend:
- Vault
- CommandAPI
softdepend:
- EconomyPlus
authors: [ 'Luis Bazán' ]
description: Plugin for the player to earn money when killing a mob
commands:
moneymobs:
aliases:
- moneym
description: "Main command of the plugin."
permission: moneymobs.command.moneymobs

0 comments on commit 2a8bc8b

Please sign in to comment.