-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
316 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/artillexstudios/axtrade/api/events/AxTradeAbortEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.artillexstudios.axtrade.api.events; | ||
|
||
import com.artillexstudios.axtrade.trade.Trade; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AxTradeAbortEvent extends Event { | ||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
private final Trade trade; | ||
|
||
public AxTradeAbortEvent(Trade trade) { | ||
this.trade = trade; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
public Trade getTrade() { | ||
return trade; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/artillexstudios/axtrade/api/events/AxTradeCompleteEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.artillexstudios.axtrade.api.events; | ||
|
||
import com.artillexstudios.axtrade.trade.Trade; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AxTradeCompleteEvent extends Event implements Cancellable { | ||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
private final Trade trade; | ||
private boolean isCancelled = false; | ||
|
||
public AxTradeCompleteEvent(Trade trade) { | ||
this.trade = trade; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return isCancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean isCancelled) { | ||
this.isCancelled = isCancelled; | ||
} | ||
|
||
public Trade getTrade() { | ||
return trade; | ||
} | ||
} |
48 changes: 0 additions & 48 deletions
48
src/main/java/com/artillexstudios/axtrade/api/events/AxTradeCompletedEvent.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 6 additions & 12 deletions
18
src/main/java/com/artillexstudios/axtrade/listeners/EntityInteractListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,31 @@ | ||
package com.artillexstudios.axtrade.listeners; | ||
|
||
import com.artillexstudios.axapi.utils.Cooldown; | ||
import com.artillexstudios.axtrade.request.Requests; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEntityEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.HashMap; | ||
|
||
import static com.artillexstudios.axtrade.AxTrade.CONFIG; | ||
|
||
public class EntityInteractListener implements Listener { | ||
private static final HashMap<Player, Long> cd = new HashMap<>(); | ||
private static final Cooldown<Player> cooldown = new Cooldown<>(); | ||
|
||
@EventHandler (ignoreCancelled = true) | ||
public void onInteract(@NotNull PlayerInteractEntityEvent event) { | ||
if (!CONFIG.getBoolean("shift-click-send-request", true)) return; | ||
|
||
final Player player = event.getPlayer(); | ||
if (!player.hasPermission("axtrade.trade")) return; | ||
|
||
if (cd.containsKey(player) && System.currentTimeMillis() - cd.get(player) < 100L) return; | ||
|
||
if (cooldown.hasCooldown(player)) return; | ||
if (!player.isSneaking()) return; | ||
if (!(event.getRightClicked() instanceof Player sendTo)) return; | ||
|
||
cd.put(player, System.currentTimeMillis()); | ||
if (!sendTo.isOnline()) return; | ||
|
||
cooldown.addCooldown(player, 100L); | ||
Requests.addRequest(player, sendTo); | ||
} | ||
|
||
public static void onQuit(Player player) { | ||
cd.remove(player); | ||
event.setCancelled(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.