Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sarhatabaot committed Mar 3, 2024
1 parent 0ad1011 commit 79fd057
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
5 changes: 1 addition & 4 deletions src/main/java/me/tychsen/enchantgui/EnchantGUIPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class EnchantGUIPlugin extends JavaPlugin {
private static Set<UUID> toggleRightClickPlayers = new HashSet<>();

private EShopConfig config;
@Getter
private LocalizationManager lm;

@Getter
Expand Down Expand Up @@ -94,9 +95,5 @@ public EShopConfig getMainConfig() {
return config;
}

public LocalizationManager getLm() {
return lm;
}


}
80 changes: 42 additions & 38 deletions src/main/java/me/tychsen/enchantgui/commands/ShopCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,55 @@
@CommandPermission(EShopPermissionSys.USE)
@Description("Command for the EnchantGUI plugin.")
public class ShopCommand extends BaseCommand {
private final String prefix;
private final ShopMenu shopMenu;
private final String prefix;
private final ShopMenu shopMenu;

private final LocalizationManager lm = EnchantGUIPlugin.getInstance().getLm();
private final LocalizationManager lm = EnchantGUIPlugin.getInstance().getLm();

public ShopCommand() {
this.prefix = lm.getLanguageString("prefix");
this.shopMenu = new ShopMenu(new Enchants());
}
public ShopCommand() {
this.prefix = lm.getLanguageString("prefix");
this.shopMenu = new ShopMenu(new Enchants());
}


@Default
public void onGui(final Player player){
shopMenu.showMainMenu(player);
}
@Default
public void onGui(final Player player) {
shopMenu.showMainMenu(player);
}

@Subcommand("toggle")
@CommandPermission(EShopPermissionSys.TOGGLE)
public void onToggle(final Player player){
if(!EnchantGUIPlugin.getInstance().getMainConfig().getBoolean("right-click-enchanting-table")){
tell(player,lm.getLanguageString("disabled-feature"));
return;
}
@Subcommand("toggle")
@CommandPermission(EShopPermissionSys.TOGGLE)
public void onToggle(final Player player) {
if (!EnchantGUIPlugin.getInstance().getMainConfig().getBoolean("right-click-enchanting-table")) {
tell(player, lm.getLanguageString("disabled-feature"));
return;
}

if(EnchantGUIPlugin.getToggleRightClickPlayers().contains(player.getUniqueId())){
EnchantGUIPlugin.getToggleRightClickPlayers().remove(player.getUniqueId());
tell(player,lm.getLanguageString("toggle-on"));
}
else {
EnchantGUIPlugin.getToggleRightClickPlayers().add(player.getUniqueId());
tell(player,lm.getLanguageString("toggle-off"));
}
}
if (EnchantGUIPlugin.getToggleRightClickPlayers().contains(player.getUniqueId())) {
EnchantGUIPlugin.getToggleRightClickPlayers().remove(player.getUniqueId());
tell(player, lm.getLanguageString("toggle-on"));
} else {
EnchantGUIPlugin.getToggleRightClickPlayers().add(player.getUniqueId());
tell(player, lm.getLanguageString("toggle-off"));
}
}


@Subcommand("reload")
@CommandPermission(EShopPermissionSys.RELOAD)
public void onReload(final CommandSender player){
EnchantGUIPlugin.getInstance().onReload();
EnchantGUIPlugin.getInstance().getLm().reload(player);
this.shopMenu.reload();
EnchantGUIPlugin.getInstance().getLogger().info(() -> "%s %s using: %s".formatted(getName(), EnchantGUIPlugin.getInstance().getDescription().getVersion(), EnchantGUIPlugin.getInstance().getMainConfig().getPaymentStrategy().name()));
}
@Subcommand("reload")
@CommandPermission(EShopPermissionSys.RELOAD)
public void onReload(final CommandSender player) {
EnchantGUIPlugin.getInstance().onReload();
EnchantGUIPlugin.getInstance().getLm().reload(player);
this.shopMenu.reload();
EnchantGUIPlugin.getInstance()
.getLogger()
.info(() -> "%s %s using: %s".formatted(getName(),
EnchantGUIPlugin.getInstance().getDescription().getVersion(),
EnchantGUIPlugin.getInstance().getMainConfig().getPaymentStrategy().name()
));
}

private void tell(final Player player, final String message){
ChatUtil.sendMessage(player,String.format("%s %s",prefix,message));
}
private void tell(final Player player, final String message) {
ChatUtil.sendMessage(player, String.format("%s %s", prefix, message));
}
}
4 changes: 2 additions & 2 deletions src/main/java/me/tychsen/enchantgui/economy/VaultPayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public boolean withdraw(@NotNull final Player player, final double amount) {

private boolean setupEconomy() {
if (plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
plugin.getLogger().severe("could not find vault");
plugin.getLogger().severe("Could not find vault");
return false;
}

RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
plugin.getLogger().severe("could not find Economy.class, missing economy plugin, install EssentialsX or something else.");
plugin.getLogger().severe("Could not find Economy.class, missing economy plugin, install EssentialsX or something else.");
return false;
}

Expand Down

0 comments on commit 79fd057

Please sign in to comment.