-
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.
- Loading branch information
1 parent
b9bddf3
commit 73b41fd
Showing
12 changed files
with
380 additions
and
22 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
41 changes: 41 additions & 0 deletions
41
src/main/java/com/github/sarhatabaot/farmassistreboot/Crop.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,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()); | ||
} | ||
|
||
|
||
} |
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
110 changes: 110 additions & 0 deletions
110
src/main/java/com/github/sarhatabaot/farmassistreboot/FarmAssistReboot.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,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; | ||
} | ||
} |
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
Oops, something went wrong.