Skip to content

Commit

Permalink
Shopkeeper update for snapshot v2.1.1 (#207)
Browse files Browse the repository at this point in the history
* Updated to latest (snapshot v2.1.1) shopkeeper changes:

It is now possible to directly get the entity from the shop object.

* Removed empty line.

* Reverted: Using 'Shopkeepers' as dependency again.

* Updated shopkeeper dependency to release 2.2.0.

Added repository containing shopkeepers releases.

* Don't attempt to resolve snapshots from release repository, and releases
from snapshot repository.
  • Loading branch information
blablubbabc authored and mcmonkey4eva committed Jun 30, 2018
1 parent dee6314 commit 8bbf433
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 38 deletions.
14 changes: 12 additions & 2 deletions bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>shopkeepers</id>
<id>shopkeepers-releases</id>
<url>http://nexus3.cube-nation.de/repository/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>shopkeepers-snapshots</id>
<url>http://nexus3.cube-nation.de/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<!--
<repository>
Expand Down Expand Up @@ -311,7 +321,7 @@
<dependency>
<groupId>com.nisovin.shopkeepers</groupId>
<artifactId>Shopkeepers</artifactId>
<version>2.0.1-SNAPSHOT</version>
<version>2.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.nisovin.shopkeepers.api.shopkeeper.TradingRecipe;
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
import com.nisovin.shopkeepers.api.shopobjects.ShopObject;
import com.nisovin.shopkeepers.api.shopobjects.entity.EntityShopObject;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizencore.objects.Element;
Expand All @@ -17,8 +17,6 @@
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.tags.core.EscapeTags;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -68,38 +66,6 @@ public static ShopKeeper fromEntity(dEntity entity) {
return new ShopKeeper(ShopkeepersAPI.getShopkeeperRegistry().getShopkeeperByEntity(entity.getBukkitEntity()));
}

public static Entity getEntity(Shopkeeper keeper) {
try {
ShopObject obj = keeper.getShopObject();
if (obj == null) {
return null;
}
String id = obj.getId();
if (id == null) {
return null;
}
if (obj == ShopkeepersAPI.getDefaultShopObjectTypes().getCitizensShopObjectType()) { // For lack of equals() or is*() API options...
if (id.startsWith("NPC-")) { // For lack of getInternalRepresentation API options...
int idNum = Integer.parseInt(id.substring("NPC-".length()));
NPC npc = CitizensAPI.getNPCRegistry().getById(idNum); // This is entirely wrong - NPCs are not guaranteed unique on their integer ID. But it's all we have.
if (npc.isSpawned()) {
return npc.getEntity();
}
return null;
}
}
if (id.startsWith("entity")) {
UUID uuid = UUID.fromString(id.substring("entity".length()));
return dEntity.getEntityForID(uuid);
}
}
catch (Exception ex) {
dB.echoError("Failed while searching entity for Shopkeeper: " + keeper);
dB.echoError(ex);
}
return null;
}

public ShopKeeper(Shopkeeper shopkeeper) {
if (shopkeeper != null) {
this.shopkeeper = shopkeeper;
Expand All @@ -121,7 +87,10 @@ public dEntity getDenizenEntity() {
}

public Entity getBukkitEntity() {
return getEntity(shopkeeper);
if (shopkeeper.getShopObject() instanceof EntityShopObject) {
return ((EntityShopObject) shopkeeper.getShopObject()).getEntity();
}
return null;
}

@Override
Expand Down

0 comments on commit 8bbf433

Please sign in to comment.