-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from luisBazanDev/development
Version 1.2.0
- Loading branch information
Showing
9 changed files
with
159 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/pe/bazan/luis/plugins/moneymobs/commands/BaseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/pe/bazan/luis/plugins/moneymobs/commands/CreditsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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==============================================")); | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
src/main/java/pe/bazan/luis/plugins/moneymobs/commands/MoneyMobsCmd.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/pe/bazan/luis/plugins/moneymobs/commands/ReloadCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
16
src/main/java/pe/bazan/luis/plugins/moneymobs/utils/MsgFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |