This commit is contained in:
BenceX100 2024-05-19 18:57:56 +02:00
parent 37f04944f9
commit bd508c1d5e
6 changed files with 261 additions and 248 deletions

21
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>com.artillexstudios</groupId> <groupId>com.artillexstudios</groupId>
<artifactId>AxTrade</artifactId> <artifactId>AxTrade</artifactId>
<version>1.0.0</version> <version>1.1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>AxTrade</name> <name>AxTrade</name>
@ -25,6 +25,9 @@
<configuration> <configuration>
<source>12</source> <source>12</source>
<target>12</target> <target>12</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -109,14 +112,14 @@
<dependency> <dependency>
<groupId>com.artillexstudios.axapi</groupId> <groupId>com.artillexstudios.axapi</groupId>
<artifactId>axapi</artifactId> <artifactId>axapi</artifactId>
<version>1.4.232</version> <version>1.4.234</version>
<scope>compile</scope> <scope>compile</scope>
<classifier>all</classifier> <classifier>all</classifier>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version> <version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -146,19 +149,19 @@
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId> <artifactId>adventure-text-minimessage</artifactId>
<version>4.16.0</version> <version>4.17.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-legacy</artifactId> <artifactId>adventure-text-serializer-legacy</artifactId>
<version>4.16.0</version> <version>4.17.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId> <artifactId>adventure-api</artifactId>
<version>4.16.0</version> <version>4.17.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
@ -240,12 +243,6 @@
<version>2.6.4</version> <version>2.6.4</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>de.rapha149.signgui</groupId>-->
<!-- <artifactId>signgui</artifactId>-->
<!-- <version>2.3.2</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.artillexstudios</groupId> <groupId>com.artillexstudios</groupId>
<artifactId>AxShulkers</artifactId> <artifactId>AxShulkers</artifactId>

View File

@ -11,7 +11,6 @@ import com.artillexstudios.axtrade.utils.SoundUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import revxrsal.commands.annotation.DefaultFor; import revxrsal.commands.annotation.DefaultFor;
import revxrsal.commands.annotation.Optional; import revxrsal.commands.annotation.Optional;
@ -29,6 +28,7 @@ import static com.artillexstudios.axtrade.AxTrade.HOOKS;
import static com.artillexstudios.axtrade.AxTrade.LANG; import static com.artillexstudios.axtrade.AxTrade.LANG;
import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS; import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS;
@CommandPermission(value = "axtrade.trade")
public class Commands implements OrphanCommand { public class Commands implements OrphanCommand {
public void help(@NotNull CommandSender sender) { public void help(@NotNull CommandSender sender) {
@ -79,7 +79,7 @@ public class Commands implements OrphanCommand {
} }
@Subcommand("reload") @Subcommand("reload")
@CommandPermission(value = "axtrade.admin", defaultAccess = PermissionDefault.OP) @CommandPermission(value = "axtrade.admin")
public void reload(@NotNull CommandSender sender) { public void reload(@NotNull CommandSender sender) {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#00FFDD[AxTrade] &#AAFFDDReloading configuration...")); Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#00FFDD[AxTrade] &#AAFFDDReloading configuration..."));
if (!CONFIG.reload()) { if (!CONFIG.reload()) {
@ -118,8 +118,12 @@ public class Commands implements OrphanCommand {
} }
@Subcommand("force") @Subcommand("force")
@CommandPermission(value = "axtrade.admin", defaultAccess = PermissionDefault.OP) @CommandPermission(value = "axtrade.admin")
public void force(@NotNull Player sender, Player other) { public void force(@NotNull Player sender, Player other) {
if (sender.equals(other)) {
MESSAGEUTILS.sendLang(sender, "request.cant-trade-self");
return;
}
Trades.addTrade(sender, other); Trades.addTrade(sender, other);
} }

View File

@ -9,11 +9,14 @@ import org.jetbrains.annotations.NotNull;
import java.util.WeakHashMap; import java.util.WeakHashMap;
import static com.artillexstudios.axtrade.AxTrade.CONFIG;
public class PlayerInteractEntityListener implements Listener { public class PlayerInteractEntityListener implements Listener {
private final WeakHashMap<Player, Long> cd = new WeakHashMap<>(); private final WeakHashMap<Player, Long> cd = new WeakHashMap<>();
@EventHandler (ignoreCancelled = true) @EventHandler (ignoreCancelled = true)
public void onClick(@NotNull PlayerInteractEntityEvent event) { public void onClick(@NotNull PlayerInteractEntityEvent event) {
if (!CONFIG.getBoolean("shift-click-send-request", true)) return;
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (cd.containsKey(player) && System.currentTimeMillis() - cd.get(player) < 100L) return; if (cd.containsKey(player) && System.currentTimeMillis() - cd.get(player) < 100L) return;

View File

@ -20,6 +20,9 @@ trade-request-expire-seconds: 60
# set to -1 to disable # set to -1 to disable
trade-max-distance: 10 trade-max-distance: 10
# should shift + right clicking on another player send them a trade request?
shift-click-send-request: true
number-formatting: number-formatting:
# modes: # modes:
# 0 - formatted (customizable, look at the formatted part) # 0 - formatted (customizable, look at the formatted part)
@ -48,4 +51,4 @@ blacklisted-items:
name-contains: "Banned item's name" name-contains: "Banned item's name"
# do not change this # do not change this
version: 1 version: 2

View File

@ -44,8 +44,8 @@ request:
sent-sender: "&#CCFFEEYou have successfully sent a trade request to &#00FFDD%player%&#CCFFEE!" sent-sender: "&#CCFFEEYou have successfully sent a trade request to &#00FFDD%player%&#CCFFEE!"
sent-receiver: | sent-receiver: |
&#CCFFEEYou have received a trade request from &#00FFDD%player%&#CCFFEE! &#CCFFEEYou have received a trade request from &#00FFDD%player%&#CCFFEE!
&#00FF00<click:run_command:'/trade accept %player%'>/trade accept %player%</click> &#00FF00/trade accept %player%
&#FF0000<click:run_command:'/trade deny %player%'>/trade deny %player%</click> &#FF0000/trade deny %player%
no-request: "&#CCFFEEYou don't have an active trade request from &#00FFDD%player%&#CCFFEE!" no-request: "&#CCFFEEYou don't have an active trade request from &#00FFDD%player%&#CCFFEE!"
deny-sender: "&#CCFFEEYou trade request was denied by &#00FFDD%player%&#CCFFEE!" deny-sender: "&#CCFFEEYou trade request was denied by &#00FFDD%player%&#CCFFEE!"
deny-receiver: "&#CCFFEEYou have successfully denied &#00FFDD%player%&#CCFFEE's trade request!" deny-receiver: "&#CCFFEEYou have successfully denied &#00FFDD%player%&#CCFFEE's trade request!"

View File

@ -4,6 +4,12 @@ main: com.artillexstudios.axtrade.AxTrade
api-version: '1.18' api-version: '1.18'
folia-supported: true folia-supported: true
permissions:
axtrade.admin:
default: op
axtrade.trade:
default: true
softdepend: softdepend:
- AxQuestBoard - AxQuestBoard
- CoinsEngine - CoinsEngine