Overhaul Village API

@Cushaw_BlueMelon
- Add @Nullable
- Double won't be null, so a @NotNull is no need
- Format codes
- Add missing village API (Should not use implementation codes on API!)
- Brings the API to world and entity
This commit is contained in:
Sotr
2019-04-22 14:27:48 +08:00
parent 64238d53a4
commit 16801d98a0
11 changed files with 134 additions and 67 deletions

View File

@@ -0,0 +1,7 @@
package io.akarin.server.api.structure;
/**
* Represents a village structure
*/
public interface Village {
}

View File

@@ -33,6 +33,22 @@ import org.jetbrains.annotations.Nullable;
*/
public interface World extends PluginMessageRecipient, Metadatable {
// Akarin start
/**
* Get the nearest village of the location in range.
*
* @return The nearest village, null if there is no village in range.
*/
public io.akarin.server.api.structure.Village getNearestVillage(@NotNull Location location, double xRadius, double yRadius, double zRadius);
/**
* Get villages which are near by the location in range.
*
* @return All the villages in range, an empty list if there is no village in range.
*/
public List<io.akarin.server.api.structure.Village> getVillagesInRange(@NotNull Location location, double xRadius, double yRadius, double zRadius);
// Akarin end
// Paper start
/**
* @return The amount of Entities in this world

View File

@@ -652,4 +652,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable {
@NotNull
org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason();
// Paper end
// Akarin start
/**
* Get the nearest village of this entity in range.
*
* @return The nearest village, null if there is no village in range.
*/
@Nullable
public io.akarin.server.api.structure.Village getNearestVillage(double xRadius, double yRadius, double zRadius);
/**
* Get villages which are near by this entity in range.
*
* @return All the villages in range, an empty list if there is no village in range.
*/
@NotNull
public List<io.akarin.server.api.structure.Village> getVillagesInRange(double xRadius, double yRadius, double zRadius);
// Akarin end
}

View File

@@ -4,10 +4,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.server.Village;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.Merchant;
@@ -19,21 +17,6 @@ import org.jetbrains.annotations.Nullable;
*/
public interface Villager extends Ageable, NPC, InventoryHolder, Merchant {
/**
* Get the nearest village of this villager in range .
*
* @return The nearest village. null if there is no village in range.
*/
public Village getNearestVillage(@NotNull double xRadius,@NotNull double yRadius,@NotNull double zRadius);
/**
* Get villages which are near by this villager in range.
*
* @return All the villages in range. Empty List if there is no village in range.
*/
public List<Village> getVillagesInRange(@NotNull double xRadius, @NotNull double yRadius, @NotNull double zRadius);
/**
* Gets the current profession of this villager.
*