Version 1.5.8:

* Added config option to disable VTL (leaving vanilla trading) in certain worlds
This commit is contained in:
PretzelJohn 2022-07-03 15:15:14 -04:00
parent 65a8bdf267
commit ccaefbbac7
6 changed files with 122 additions and 6 deletions

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pretzel.dev</groupId>
<artifactId>VillagerTradeLimiter</artifactId>
<version>1.5.8</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>de.tr7zw.changeme.nbtapi</pattern>
<shadedPattern>com.pretzel.dev.villagertradelimiter.nms</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>protobuf-java</artifactId>
<groupId>com.google.protobuf</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<java.version>1.8</java.version>
</properties>
</project>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.pretzel.dev</groupId>
<artifactId>VillagerTradeLimiter</artifactId>
<version>1.5.7</version>
<version>1.5.8</version>
<properties>
<java.version>1.8</java.version>

View File

@ -3,6 +3,7 @@ package com.pretzel.dev.villagertradelimiter.listeners;
import com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter;
import com.pretzel.dev.villagertradelimiter.data.Cooldown;
import com.pretzel.dev.villagertradelimiter.data.PlayerData;
import com.pretzel.dev.villagertradelimiter.lib.Util;
import com.pretzel.dev.villagertradelimiter.settings.Settings;
import com.pretzel.dev.villagertradelimiter.wrappers.*;
import org.bukkit.Material;
@ -13,6 +14,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -42,11 +44,15 @@ public class PlayerListener implements Listener {
final Player player = event.getPlayer();
final Villager villager = (Villager)event.getRightClicked();
//Skips when the villager is in a disabled world
if(instance.getCfg().getStringList("DisableWorlds").contains(villager.getWorld().getName())) return;
//Skips when player is holding an ignored item
Material heldItemType = player.getInventory().getItem(event.getHand()).getType();
for(String ignoredType : instance.getCfg().getStringList("IgnoreHeldItems")) {
if(heldItemType.equals(Material.matchMaterial(ignoredType))) {
return;
ItemStack heldItem = player.getInventory().getItem(event.getHand());
if(heldItem != null) {
Material heldItemType = heldItem.getType();
for(String ignoredType : instance.getCfg().getStringList("IgnoreHeldItems")) {
if(heldItemType.equals(Material.matchMaterial(ignoredType))) return;
}
}
if(settings.shouldSkipNPC(event.getPlayer()) || settings.shouldSkipNPC(villager)) return; //Skips NPCs
@ -90,6 +96,12 @@ public class PlayerListener implements Listener {
* @param other The other player to view trades for, or the player that has just begun trading
*/
public void see(final Villager villager, final Player player, final OfflinePlayer other) {
//Skips when the villager is in a disabled world
if(instance.getCfg().getStringList("DisableWorlds").contains(villager.getWorld().getName())) {
Util.sendMsg(instance.getLang("see.noworld"), player);
return;
}
//Wraps the villager and player into wrapper classes
final VillagerWrapper villagerWrapper = new VillagerWrapper(villager);
final PlayerWrapper otherWrapper = new PlayerWrapper(other);

View File

@ -19,6 +19,11 @@ database:
encoding: utf8
useSSL: false
# Add world names for worlds that you want to have unaltered, vanilla villager trading in. Set to [] to disable this feature.
DisableWorlds:
- world_nether
- world_the_end
# Ignore Citizens NPCs, and/or Shopkeepers NPCs if true
IgnoreCitizens: true
IgnoreShopkeepers: true

View File

@ -16,4 +16,5 @@ see:
success: "&aShowing the adjusted trades for &b{player}&a..."
noplayer: "&cInvalid player &b{player}&c! Please use a valid player's name."
novillager: "&cInvalid entity! Please look at the villager you want to check."
noworld: "&cVTL is disabled in this world!"

View File

@ -1,7 +1,7 @@
name: VillagerTradeLimiter
author: PretzelJohn
main: com.pretzel.dev.villagertradelimiter.VillagerTradeLimiter
version: 1.5.7
version: 1.5.8
api-version: 1.14
commands: