Added Head Shop
+ Integrates with ShopKeepers + On login, users with the `qol.head_shop` perm have their head added to the shop, if not already added + The shop id and the price to charge are both configurablepull/18/head
parent
f327f59d6c
commit
b6ffbf7168
12
pom.xml
12
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<groupId>xyz.etztech</groupId>
|
<groupId>xyz.etztech</groupId>
|
||||||
<artifactId>QoL</artifactId>
|
<artifactId>QoL</artifactId>
|
||||||
<!-- Version is used in plugin.yml -->
|
<!-- Version is used in plugin.yml -->
|
||||||
<version>1.15</version>
|
<version>1.16</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<!-- Plugin Information -->
|
<!-- Plugin Information -->
|
||||||
|
@ -62,6 +62,12 @@
|
||||||
<version>0.1-SNAPSHOT</version>
|
<version>0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.nisovin.shopkeepers</groupId>
|
||||||
|
<artifactId>ShopkeepersAPI</artifactId>
|
||||||
|
<version>2.13.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -97,6 +103,10 @@
|
||||||
<id>sonatype-snapshots</id>
|
<id>sonatype-snapshots</id>
|
||||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>shopkeepers-repo</id>
|
||||||
|
<url>https://nexus.lichtspiele.org/repository/releases/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package xyz.etztech.qol;
|
package xyz.etztech.qol;
|
||||||
|
|
||||||
|
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
|
||||||
|
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
|
||||||
import github.scarsz.discordsrv.DiscordSRV;
|
import github.scarsz.discordsrv.DiscordSRV;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -38,6 +40,7 @@ public class QoL extends JavaPlugin {
|
||||||
private MarkerSet playerMarkerSet = null;
|
private MarkerSet playerMarkerSet = null;
|
||||||
private boolean qolMarkerLayerShow = false;
|
private boolean qolMarkerLayerShow = false;
|
||||||
private String qolMarkerSetLabel = null;
|
private String qolMarkerSetLabel = null;
|
||||||
|
private ShopkeepersPlugin shopkeepersAPI = null;
|
||||||
|
|
||||||
public static FileConfiguration config;
|
public static FileConfiguration config;
|
||||||
private Logger log = Logger.getLogger( "Minecraft" );
|
private Logger log = Logger.getLogger( "Minecraft" );
|
||||||
|
@ -95,6 +98,13 @@ public class QoL extends JavaPlugin {
|
||||||
new DiscordSRVListener(this);
|
new DiscordSRVListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
shopkeepersAPI = ShopkeepersPlugin.getInstance();
|
||||||
|
log("Hooked in Shopkeepers for the Donor Shop");
|
||||||
|
}
|
||||||
|
catch (Exception ignored) {}
|
||||||
|
|
||||||
if( isEnabled() ) {
|
if( isEnabled() ) {
|
||||||
|
|
||||||
// Add listeners
|
// Add listeners
|
||||||
|
@ -346,5 +356,9 @@ public class QoL extends JavaPlugin {
|
||||||
public Spark getSpark() {
|
public Spark getSpark() {
|
||||||
return spark;
|
return spark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShopkeepersPlugin getShopkeepersAPI() {
|
||||||
|
return shopkeepersAPI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
package xyz.etztech.qol.listeners;
|
package xyz.etztech.qol.listeners;
|
||||||
|
|
||||||
|
import com.nisovin.shopkeepers.api.ShopkeepersAPI;
|
||||||
|
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
|
||||||
|
import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
|
||||||
|
import com.nisovin.shopkeepers.api.shopkeeper.ShopkeeperRegistry;
|
||||||
|
import com.nisovin.shopkeepers.api.shopkeeper.admin.regular.RegularAdminShopkeeper;
|
||||||
|
import com.nisovin.shopkeepers.api.shopkeeper.offers.PriceOffer;
|
||||||
|
import com.nisovin.shopkeepers.api.shopkeeper.offers.TradeOffer;
|
||||||
|
import com.nisovin.shopkeepers.api.shopobjects.ShopObject;
|
||||||
|
import com.nisovin.shopkeepers.api.storage.ShopkeeperStorage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
import org.dynmap.markers.Marker;
|
import org.dynmap.markers.Marker;
|
||||||
import xyz.etztech.qol.QoL;
|
import xyz.etztech.qol.QoL;
|
||||||
import xyz.etztech.qol.commands.CheckupCommand;
|
import xyz.etztech.qol.commands.CheckupCommand;
|
||||||
|
@ -58,7 +70,43 @@ public class JoinListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShopkeepersPlugin shopkeepersAPI = plugin.getShopkeepersAPI();
|
||||||
|
if (shopkeepersAPI != null && player.hasPermission("qol.head_shop")) {
|
||||||
|
int shopKeeperID = plugin.getConfig().getInt("head_shop.id", -1);
|
||||||
|
|
||||||
|
if (shopKeeperID != -1) {
|
||||||
|
ShopkeeperRegistry shopkeeperRegistry = shopkeepersAPI.getShopkeeperRegistry();
|
||||||
|
RegularAdminShopkeeper donorHeadShop = (RegularAdminShopkeeper) shopkeeperRegistry.getShopkeeperById(shopKeeperID);
|
||||||
|
|
||||||
|
if (donorHeadShop != null) {
|
||||||
|
|
||||||
|
boolean donorFound = false;
|
||||||
|
for (TradeOffer tradeOffer: donorHeadShop.getOffers()) {
|
||||||
|
if (tradeOffer.getResultItem().getItemMeta().getDisplayName().equals(player.getDisplayName())) {
|
||||||
|
donorFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!donorFound) {
|
||||||
|
int diamondPrice = plugin.getConfig().getInt("head_shop.price", 2);
|
||||||
|
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
|
||||||
|
SkullMeta skullMeta = (SkullMeta) playerHead.getItemMeta();
|
||||||
|
|
||||||
|
skullMeta.setOwningPlayer(player);
|
||||||
|
skullMeta.setDisplayName(player.getDisplayName());
|
||||||
|
playerHead.setItemMeta(skullMeta);
|
||||||
|
|
||||||
|
TradeOffer donorHeadTrade = TradeOffer.create(playerHead, new ItemStack(Material.DIAMOND, diamondPrice), null);
|
||||||
|
donorHeadShop.addOffer(donorHeadTrade);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
CheckupCommand.join(player);
|
CheckupCommand.join(player);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,3 +116,11 @@ dynmap:
|
||||||
defaults:
|
defaults:
|
||||||
map: "surface"
|
map: "surface"
|
||||||
zoom: 5
|
zoom: 5
|
||||||
|
|
||||||
|
# Shopkeepers Player Head Shop
|
||||||
|
head_shop:
|
||||||
|
# Shopkeeper Shop ID, set to -1 to disable
|
||||||
|
id: -1
|
||||||
|
# Diamond price of a head in the shop, default is 2 diamonds
|
||||||
|
price: 2
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ description: ${description}
|
||||||
author: ${author}
|
author: ${author}
|
||||||
website: ${url}
|
website: ${url}
|
||||||
main: ${mainClass}
|
main: ${mainClass}
|
||||||
softdepend: [spark, dynmap, DiscordSRV]
|
softdepend: [spark, dynmap, DiscordSRV, Shopkeepers]
|
||||||
|
api-version: 1.13
|
||||||
commands:
|
commands:
|
||||||
qol:
|
qol:
|
||||||
description: Base command
|
description: Base command
|
||||||
|
@ -132,3 +133,6 @@ permissions:
|
||||||
qol.discordignore:
|
qol.discordignore:
|
||||||
description: Ability to use the use the discordignore command
|
description: Ability to use the use the discordignore command
|
||||||
default: op
|
default: op
|
||||||
|
qol.head_shop:
|
||||||
|
description: Controls if a player's head should be added to the head shop
|
||||||
|
default: op
|
||||||
|
|
Loading…
Reference in New Issue