-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
35 changed files
with
286 additions
and
160 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
13 changes: 13 additions & 0 deletions
13
Allay-API/src/main/java/org/allaymc/api/loottable/Rolls.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,13 @@ | ||
package org.allaymc.api.loottable; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface Rolls { | ||
/** | ||
* Get the number of rolls | ||
* | ||
* @return the number of rolls | ||
*/ | ||
int getRolls(); | ||
} |
17 changes: 17 additions & 0 deletions
17
Allay-API/src/main/java/org/allaymc/api/loottable/condition/Condition.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,17 @@ | ||
package org.allaymc.api.loottable.condition; | ||
|
||
import org.allaymc.api.loottable.context.Context; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface Condition<CONTEXT_TYPE extends Context> { | ||
/** | ||
* Tests the condition with the given context. | ||
* | ||
* @param context The context to test the condition with. | ||
* | ||
* @return {@code true} if the condition passes, {@code false} otherwise. | ||
*/ | ||
boolean test(CONTEXT_TYPE context); | ||
} |
19 changes: 19 additions & 0 deletions
19
Allay-API/src/main/java/org/allaymc/api/loottable/condition/ConditionDeserializer.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,19 @@ | ||
package org.allaymc.api.loottable.condition; | ||
|
||
import com.google.gson.JsonObject; | ||
import org.allaymc.api.loottable.context.Context; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface ConditionDeserializer<CONTEXT_TYPE extends Context> { | ||
|
||
/** | ||
* Deserializes a {@link JsonObject} into a {@link Condition} object. | ||
* | ||
* @param json The {@link JsonObject} to deserialize. | ||
* | ||
* @return The deserialized {@link Condition} object. | ||
*/ | ||
Condition<CONTEXT_TYPE> deserialize(JsonObject json); | ||
} |
23 changes: 23 additions & 0 deletions
23
Allay-API/src/main/java/org/allaymc/api/loottable/condition/Conditions.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,23 @@ | ||
package org.allaymc.api.loottable.condition; | ||
|
||
import org.allaymc.api.loottable.context.Context; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public record Conditions<CONTEXT_TYPE extends Context>( | ||
List<Condition<CONTEXT_TYPE>> conditions | ||
) { | ||
/** | ||
* Tests the conditions with the given context. | ||
* | ||
* @param context The context to test the conditions with. | ||
* | ||
* @return {@code true} if the conditions pass, {@code false} otherwise. | ||
*/ | ||
public boolean test(CONTEXT_TYPE context) { | ||
return conditions.stream().allMatch(condition -> condition.test(context)); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ymc/server/loottable/context/Context.java → ...llaymc/api/loottable/context/Context.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
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
53 changes: 53 additions & 0 deletions
53
Allay-API/src/main/java/org/allaymc/api/loottable/entry/Entry.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,53 @@ | ||
package org.allaymc.api.loottable.entry; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.loottable.condition.Conditions; | ||
import org.allaymc.api.loottable.context.Context; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface Entry<CONTEXT_TYPE extends Context> { | ||
/** | ||
* Loot method that returns a set of ItemStack objects. | ||
* | ||
* @param context The context to loot with. | ||
* | ||
* @return A set of ItemStack objects. | ||
*/ | ||
Set<ItemStack> loot(CONTEXT_TYPE context); | ||
|
||
/** | ||
* Tests the entry's conditions with the given context. | ||
* | ||
* @param context The context to test the conditions with. | ||
* | ||
* @return {@code true} if the conditions pass, {@code false} otherwise. | ||
*/ | ||
default boolean test(CONTEXT_TYPE context) { | ||
return getConditions().test(context); | ||
} | ||
|
||
/** | ||
* Returns the name of the entry. | ||
* | ||
* @return The name of the entry. | ||
*/ | ||
String getName(); | ||
|
||
/** | ||
* Returns the weight of the entry. | ||
* | ||
* @return The weight of the entry. | ||
*/ | ||
int getWeight(); | ||
|
||
/** | ||
* Returns the conditions of the entry. | ||
* | ||
* @return The conditions of the entry. | ||
*/ | ||
Conditions<CONTEXT_TYPE> getConditions(); | ||
} |
20 changes: 20 additions & 0 deletions
20
Allay-API/src/main/java/org/allaymc/api/loottable/entry/EntryDeserializer.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,20 @@ | ||
package org.allaymc.api.loottable.entry; | ||
|
||
import com.google.gson.JsonObject; | ||
import org.allaymc.api.loottable.LootTableType; | ||
import org.allaymc.api.loottable.context.Context; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface EntryDeserializer<CONTEXT_TYPE extends Context> { | ||
/** | ||
* Deserializes an {@link Entry} from a {@link JsonObject}. | ||
* | ||
* @param json The {@link JsonObject} to deserialize from. | ||
* @param lootTableType The {@link LootTableType} of the loot table. | ||
* | ||
* @return A new {@link Entry} instance. | ||
*/ | ||
Entry<CONTEXT_TYPE> deserialize(JsonObject json, LootTableType<CONTEXT_TYPE> lootTableType); | ||
} |
15 changes: 15 additions & 0 deletions
15
Allay-API/src/main/java/org/allaymc/api/loottable/function/Function.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 org.allaymc.api.loottable.function; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface Function { | ||
/** | ||
* Applies this function to the given ItemStack. | ||
* | ||
* @param itemStack The ItemStack to apply the function to. | ||
*/ | ||
void apply(ItemStack itemStack); | ||
} |
17 changes: 17 additions & 0 deletions
17
Allay-API/src/main/java/org/allaymc/api/loottable/function/FunctionDeserializer.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,17 @@ | ||
package org.allaymc.api.loottable.function; | ||
|
||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface FunctionDeserializer { | ||
/** | ||
* Deserializes a {@code JsonObject} into a {@code Function} object. | ||
* | ||
* @param json The JsonObject to deserialize. | ||
* | ||
* @return The deserialized {@code Function} object. | ||
*/ | ||
Function deserialize(JsonObject json); | ||
} |
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
3 changes: 2 additions & 1 deletion
3
Allay-Server/src/main/java/org/allaymc/server/loottable/LootTable.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
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
8 changes: 0 additions & 8 deletions
8
Allay-Server/src/main/java/org/allaymc/server/loottable/Rolls.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.