Skip to content

Commit

Permalink
Remove lombok
Browse files Browse the repository at this point in the history
  • Loading branch information
sarhatabaot committed Nov 19, 2024
1 parent b9bddf3 commit 73b41fd
Show file tree
Hide file tree
Showing 12 changed files with 380 additions and 22 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
plugins {
java
alias(libs.plugins.shadow)
alias(libs.plugins.lombok)
alias(libs.plugins.plugin.yml.bukkit)
}

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/github/sarhatabaot/farmassistreboot/Crop.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@


import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
import org.bukkit.Material;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Getter
public enum Crop {
WHEAT(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.WHEAT, XMaterial.WHEAT_SEEDS),
SUGAR_CANE(new XMaterial[]{XMaterial.GRASS_BLOCK, XMaterial.SAND, XMaterial.DIRT}, XMaterial.SUGAR_CANE, XMaterial.SUGAR_CANE),
Expand Down Expand Up @@ -37,5 +35,15 @@ public static List<Material> getCropList() {
return Arrays.stream(Crop.values()).map(crop -> crop.planted.parseMaterial()).collect(Collectors.toList());
}

public XMaterial[] getPlantedOn() {
return plantedOn;
}

public XMaterial getPlanted() {
return planted;
}

public XMaterial getSeed() {
return seed;
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/github/sarhatabaot/farmassistreboot/Crop.java~
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.github.sarhatabaot.farmassistreboot;


import com.cryptomorin.xseries.XMaterial;
import lombok.Getter;
import org.bukkit.Material;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Getter
public enum Crop {
WHEAT(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.WHEAT, XMaterial.WHEAT_SEEDS),
SUGAR_CANE(new XMaterial[]{XMaterial.GRASS_BLOCK, XMaterial.SAND, XMaterial.DIRT}, XMaterial.SUGAR_CANE, XMaterial.SUGAR_CANE),
NETHER_WART(new XMaterial[]{XMaterial.SOUL_SAND}, XMaterial.NETHER_WART, XMaterial.NETHER_WART),
COCOA(new XMaterial[]{XMaterial.JUNGLE_LOG, XMaterial.STRIPPED_JUNGLE_LOG, XMaterial.STRIPPED_JUNGLE_WOOD, XMaterial.JUNGLE_WOOD}, XMaterial.COCOA, XMaterial.COCOA_BEANS),
CARROTS(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.CARROTS, XMaterial.CARROT),
POTATOES(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.POTATOES, XMaterial.POTATO),
BEETROOTS(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.BEETROOTS, XMaterial.BEETROOT_SEEDS),
CACTUS(new XMaterial[]{XMaterial.SAND}, XMaterial.CACTUS, XMaterial.CACTUS),
TORCHFLOWER(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.TORCHFLOWER, XMaterial.TORCHFLOWER_SEEDS),
PITCHER_PLANT(new XMaterial[]{XMaterial.FARMLAND}, XMaterial.PITCHER_CROP, XMaterial.PITCHER_POD);

private final XMaterial[] plantedOn;
private final XMaterial planted;
private final XMaterial seed;


Crop(final XMaterial[] plantedOn, final XMaterial planted, final XMaterial seed) {
this.plantedOn = plantedOn;
this.planted = planted;
this.seed = seed;
}

public static List<Material> getCropList() {
return Arrays.stream(Crop.values()).map(crop -> crop.planted.parseMaterial()).collect(Collectors.toList());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.github.sarhatabaot.farmassistreboot.listeners.JoinListener;
import com.github.sarhatabaot.farmassistreboot.listeners.PlayerInteractionListener;
import com.github.sarhatabaot.farmassistreboot.tasks.SimpleUpdateCheckerTask;
import lombok.Getter;
import lombok.Setter;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
Expand All @@ -23,7 +21,6 @@
/**
* @author sarhatabaot
*/
@Getter @Setter
public class FarmAssistReboot extends JavaPlugin {
private MorePaperLib paperLib = new MorePaperLib(this);
private LanguageManager languageManager;
Expand Down Expand Up @@ -78,4 +75,44 @@ private void registerListeners(){
pluginManager.registerEvents(new BlockBreakListener(this),this);
pluginManager.registerEvents(new JoinListener(this),this);
}

public MorePaperLib getPaperLib() {
return paperLib;
}

public LanguageManager getLanguageManager() {
return languageManager;
}

public List<UUID> getDisabledPlayerList() {
return disabledPlayerList;
}

public FarmAssistConfig getAssistConfig() {
return assistConfig;
}

public boolean isGlobalEnabled() {
return globalEnabled;
}

public boolean doesNotNeedUpdate() {
return !needsUpdate;
}

public String getNewVersion() {
return newVersion;
}

public void setGlobalEnabled(boolean globalEnabled) {
this.globalEnabled = globalEnabled;
}

public void setNeedsUpdate(boolean needsUpdate) {
this.needsUpdate = needsUpdate;
}

public void setNewVersion(String newVersion) {
this.newVersion = newVersion;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.github.sarhatabaot.farmassistreboot;

import co.aikar.commands.PaperCommandManager;
import com.github.sarhatabaot.farmassistreboot.command.FarmAssistCommand;
import com.github.sarhatabaot.farmassistreboot.config.FarmAssistConfig;
import com.github.sarhatabaot.farmassistreboot.lang.LanguageManager;
import com.github.sarhatabaot.farmassistreboot.listeners.BlockBreakListener;
import com.github.sarhatabaot.farmassistreboot.listeners.JoinListener;
import com.github.sarhatabaot.farmassistreboot.listeners.PlayerInteractionListener;
import com.github.sarhatabaot.farmassistreboot.tasks.SimpleUpdateCheckerTask;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import space.arim.morepaperlib.MorePaperLib;

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

/**
* @author sarhatabaot
*/
public class FarmAssistReboot extends JavaPlugin {
private MorePaperLib paperLib = new MorePaperLib(this);
private LanguageManager languageManager;
private List<UUID> disabledPlayerList = new ArrayList<>();
private FarmAssistConfig assistConfig;

private boolean globalEnabled;

private boolean needsUpdate;
private String newVersion;

@Override
public void onEnable() {
saveDefaultConfig();
this.assistConfig = new FarmAssistConfig(this);
this.languageManager = new LanguageManager(this);

this.globalEnabled = true;

PaperCommandManager commandManager = new PaperCommandManager(this);
commandManager.registerCommand(new FarmAssistCommand(this));
commandManager.getCommandCompletions().registerCompletion("supported-lang", c -> languageManager.getSupportedLanguages());

registerListeners();
Util.init(this);
if (FarmAssistConfig.CHECK_FOR_UPDATES) {
this.paperLib.scheduling().asyncScheduler().run(new SimpleUpdateCheckerTask(this));
}

new Metrics(this,3885);
registerPapi();
}

public void debug(final Class<?> clazz,final String message) {
if(FarmAssistConfig.DEBUG) {
getLogger().info(() -> "DEBUG " + clazz.getSimpleName() + " " + message);
}
}

private void registerPapi() {
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new FarmAssistPlaceholderExpansion(this).register();
}
}

/**
* Register Listeners
*/
private void registerListeners(){
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new PlayerInteractionListener(this),this);
pluginManager.registerEvents(new BlockBreakListener(this),this);
pluginManager.registerEvents(new JoinListener(this),this);
}

public MorePaperLib getPaperLib() {
return paperLib;
}

public LanguageManager getLanguageManager() {
return languageManager;
}

public List<UUID> getDisabledPlayerList() {
return disabledPlayerList;
}

public FarmAssistConfig getAssistConfig() {
return assistConfig;
}

public boolean isGlobalEnabled() {
return globalEnabled;
}

public boolean doesNotNeedUpdate() {
return !needsUpdate;
}

public String getNewVersion() {
return newVersion;
}

public void setGlobalEnabled(boolean globalEnabled) {
this.globalEnabled = globalEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
import com.github.sarhatabaot.farmassistreboot.Util;
import com.github.sarhatabaot.farmassistreboot.messages.Commands;
import com.github.sarhatabaot.farmassistreboot.messages.InternalMessages;
import lombok.RequiredArgsConstructor;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

@RequiredArgsConstructor
@CommandAlias(Commands.BASE_COMMAND)
public class FarmAssistCommand extends BaseCommand {
private final FarmAssistReboot plugin;

public FarmAssistCommand(FarmAssistReboot plugin) {
this.plugin = plugin;
}

@Default
@Subcommand(Commands.TogglePlayer.SUB_COMMAND)
@CommandPermission(Commands.TogglePlayer.PERMISSION)
Expand Down Expand Up @@ -61,7 +63,7 @@ public void onInfo(final @NotNull CommandSender sender) {
@CommandPermission(Commands.Update.PERMISSION)
@Description(Commands.Update.DESCRIPTION)
public void onUpdate(final CommandSender sender) {
if (!plugin.isNeedsUpdate()) {
if (plugin.doesNotNeedUpdate()) {
Util.sendMessage(sender, String.format(plugin.getLanguageManager().getActiveLanguage().getUpdateLatestVersion(), plugin.getDescription().getVersion()));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import com.github.sarhatabaot.farmassistreboot.FarmAssistReboot;
import com.github.sarhatabaot.farmassistreboot.config.ConfigFile;
import lombok.Getter;

import java.io.File;

/**
* @author sarhatabaot
*/
@Getter
public class LanguageFile extends ConfigFile<FarmAssistReboot> {
private final String locale;
private String togglePlayerOn;
Expand Down Expand Up @@ -65,4 +63,59 @@ public void reloadConfig() {
initValues();
}

public String getLocale() {
return locale;
}

public String getTogglePlayerOn() {
return togglePlayerOn;
}

public String getTogglePlayerOff() {
return togglePlayerOff;
}

public String getToggleGlobalOn() {
return toggleGlobalOn;
}

public String getToggleGlobalOff() {
return toggleGlobalOff;
}

public String getInfoVersion() {
return infoVersion;
}

public String getInfoMaintainers() {
return infoMaintainers;
}

public String getUpdateLatestVersion() {
return updateLatestVersion;
}

public String getUpdateNew() {
return updateNew;
}

public String getUpdateGetNew() {
return updateGetNew;
}

public String getUpdateNewVersionFail() {
return updateNewVersionFail;
}

public String getLangUnsupported() {
return langUnsupported;
}

public String getLangChanged() {
return langChanged;
}

public String getPrefix() {
return prefix;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.github.sarhatabaot.farmassistreboot.FarmAssistReboot;
import com.github.sarhatabaot.farmassistreboot.config.FarmAssistConfig;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

Expand All @@ -21,9 +20,7 @@
public class LanguageManager {
private final FarmAssistReboot plugin;

@Getter
private final List<String> supportedLanguages;
@Getter
private LanguageFile activeLanguage;

public LanguageManager(final FarmAssistReboot plugin) {
Expand Down Expand Up @@ -89,4 +86,11 @@ public boolean isSupported(final String locale) {
return supportedLanguages.contains(locale);
}

public List<String> getSupportedLanguages() {
return supportedLanguages;
}

public LanguageFile getActiveLanguage() {
return activeLanguage;
}
}
Loading

0 comments on commit 73b41fd

Please sign in to comment.