Skip to content

Commit

Permalink
Merge pull request #28 from SoSeDiK/New-Branch
Browse files Browse the repository at this point in the history
[WIP] A bunch of fixes and additions
  • Loading branch information
TheBusyBiscuit committed Sep 16, 2018
2 parents b1af049 + 3343eff commit 393fe10
Show file tree
Hide file tree
Showing 33 changed files with 1,034 additions and 831 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.mrCookieSlime</groupId>
<artifactId>ExoticGarden</artifactId>
<version>1.6.3</version>
<version>1.7.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down Expand Up @@ -60,12 +60,12 @@
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>CS-CoreLib</artifactId>
<version>v1.5.16</version>
<version>v1.5.18</version>
</dependency>
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>Slimefun4</artifactId>
<version>v4.1.12</version>
<version>v4.1.15</version>
</dependency>
</dependencies>
</project>
57 changes: 38 additions & 19 deletions src/me/mrCookieSlime/ExoticGarden/Berry.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,74 @@
import java.util.Arrays;
import java.util.List;

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;

public class Berry {

ItemStack item;
String name;
String id;
PlantData data;
PlantType type;
public Berry(String name, PlantType type, PlantData data) {
this.name = name;

public Berry(String id, PlantType type, PlantData data) {
this.id = id;
this.data = data;
this.type = type;
}
public Berry(ItemStack item, String name, PlantType type, PlantData data) {

public Berry(ItemStack item, String id, PlantType type, PlantData data) {
this.item = item;
this.name = name;
this.id = id;
this.data = data;
this.type = type;
}


/**
* Returns the identifier of this Berry.
*
* @return the identifier of this Berry
*
* @since 1.7.0
* @deprecated As of 1.7.0, renamed to {@link #getID()} for better name convenience.
*/
@Deprecated
public String getName() {
return this.name;
return this.id;
}


/**
* Returns the identifier of this Berry.
*
* @return the identifier of this Berry
*
* @since 1.7.0, rename of {@link #getName()}.
*/
public String getID() {
return this.id;
}

public ItemStack getItem() {
switch(type) {
case ORE_PLANT: return item;
default: return SlimefunItem.getByName(name).getItem();
default: return SlimefunItem.getByID(id).getItem();
}
}

public PlantData getData() {
return this.data;
}

public PlantType getType() {
return type;
}

public String toBush() {
switch(type) {
case ORE_PLANT: return this.name.replace("_ESSENCE", "_PLANT");
default: return this.name + "_BUSH";
case ORE_PLANT: return this.id.replace("_ESSENCE", "_PLANT");
default: return this.id + "_BUSH";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
import java.net.URLConnection;

import org.bukkit.plugin.Plugin;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;

public class CSCoreLibLoader {

Plugin plugin;
URL url;
URL download;
File file;

public CSCoreLibLoader(Plugin plugin) {
this.plugin = plugin;
try {
this.url = new URL("https://api.curseforge.com/servermods/files?projectIds=88802");
} catch (MalformedURLException e) {
}
} catch (MalformedURLException e) {}
}

public boolean load() {
if (plugin.getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) return true;
else {
System.err.println(" ");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
System.err.println(plugin.getName() + " could not be loaded.");
System.err.println("It appears that you have not installed CS-CoreLib");
System.err.println("It appears that you have not installed CS-CoreLib.");
System.err.println("Your Server will now try to download and install");
System.err.println("CS-CoreLib for you.");
System.err.println("You will be asked to restart your Server when it's finished.");
Expand All @@ -47,12 +47,8 @@ public boolean load() {
System.err.println(" ");
System.err.println("#################### - INFO - ####################");
System.err.println(" ");
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

@Override
public void run() {
if (connect()) install();
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (connect()) install();
}, 10L);
return false;
}
Expand Down Expand Up @@ -125,7 +121,7 @@ private void install() {
System.err.println(" ");
System.err.println("#################### - WARNING - ####################");
System.err.println(" ");
System.err.println("Failed to download CS-CoreLib");
System.err.println("Failed to download CS-CoreLib.");
System.err.println("Please download & install CS-CoreLib manually:");
System.err.println("https://dev.bukkit.org/projects/cs-corelib");
System.err.println(" ");
Expand Down
11 changes: 5 additions & 6 deletions src/me/mrCookieSlime/ExoticGarden/CustomFood.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package me.mrCookieSlime.ExoticGarden;

import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import me.mrCookieSlime.Slimefun.Objects.Category;

public class CustomFood extends EGPlant {

float food;

public CustomFood(Category category, ItemStack item, String name, ItemStack[] recipe, int food) {
super(category, item, name, RecipeType.ENHANCED_CRAFTING_TABLE, true, recipe);
super(category, item, name, Kitchen.KITCHEN, true, recipe);
this.food = food;
}

@Override
public void restoreHunger(Player p) {
int level = p.getFoodLevel() + (int) food;
Expand Down
8 changes: 4 additions & 4 deletions src/me/mrCookieSlime/ExoticGarden/EGPlant.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
public class EGPlant extends HandledBlock {

boolean edible;

public EGPlant(Category category, ItemStack item, String name, RecipeType recipeType, boolean edible, ItemStack[] recipe) {
super(category, item, name, recipeType, recipe);
this.edible = edible;
}

public boolean isEdible() {
return this.edible;
}

private static final int food = 2;

public void restoreHunger(Player p) {
int level = p.getFoodLevel() + (int) food;
p.setFoodLevel(level > 20 ? 20: level);
Expand Down

0 comments on commit 393fe10

Please sign in to comment.