Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import net.buycraft.plugin.BuyCraftAPI;
import net.buycraft.plugin.IBuycraftPlatform;
import net.buycraft.plugin.UuidUtil;
import net.buycraft.plugin.bukkit.events.BuycraftPurchaseEvent;
import net.buycraft.plugin.data.QueuedPlayer;
import net.buycraft.plugin.data.responses.ServerInformation;
import net.buycraft.plugin.execution.placeholder.PlaceholderManager;
import net.buycraft.plugin.execution.strategy.CommandExecutor;
import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.buycraft.plugin.platform.PlatformInformation;
import net.buycraft.plugin.platform.PlatformType;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -38,7 +40,14 @@ public PlaceholderManager getPlaceholderManager() {
}

@Override
public void dispatchCommand(String command) {
public void dispatchCommand(String command, ToRunQueuedCommand queuedCommand) {

BuycraftPurchaseEvent event = new BuycraftPurchaseEvent(command, queuedCommand);

Bukkit.getPluginManager().callEvent(event);

if (event.isCancelled()) return;

plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package net.buycraft.plugin.bukkit.events;

import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class BuycraftPurchaseEvent extends Event implements Cancellable {

private static final HandlerList HANDLERS = new HandlerList();

private boolean cancelled;
private final String command;
private final ToRunQueuedCommand queuedCommand;

public BuycraftPurchaseEvent(String command, ToRunQueuedCommand queuedCommand) {
this.command = command;
this.queuedCommand = queuedCommand;
}

public ToRunQueuedCommand getQueuedCommand() {
return this.queuedCommand;
}

public String getCommand() {
return this.command;
}

@Override
public HandlerList getHandlers() {
return HANDLERS;
}

public static HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public boolean isCancelled() {
return this.cancelled;
}

@Override
public void setCancelled(boolean status) {
this.cancelled = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import net.buycraft.plugin.BuyCraftAPI;
import net.buycraft.plugin.IBuycraftPlatform;
import net.buycraft.plugin.UuidUtil;
import net.buycraft.plugin.bungeecord.events.BuycraftPurchaseEvent;
import net.buycraft.plugin.data.QueuedPlayer;
import net.buycraft.plugin.data.responses.ServerInformation;
import net.buycraft.plugin.execution.placeholder.PlaceholderManager;
import net.buycraft.plugin.execution.strategy.CommandExecutor;
import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.buycraft.plugin.platform.NoBlocking;
import net.buycraft.plugin.platform.PlatformInformation;
import net.buycraft.plugin.platform.PlatformType;
Expand Down Expand Up @@ -34,7 +36,12 @@ public PlaceholderManager getPlaceholderManager() {
}

@Override
public void dispatchCommand(String command) {
public void dispatchCommand(String command, ToRunQueuedCommand queuedCommand) {

BuycraftPurchaseEvent event = plugin.getProxy().getPluginManager().callEvent(new BuycraftPurchaseEvent(command, queuedCommand));

if (event.isCancelled()) return;

plugin.getProxy().getPluginManager().dispatchCommand(plugin.getProxy().getConsole(), command);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.buycraft.plugin.bungeecord.events;

import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.md_5.bungee.api.plugin.Event;

public class BuycraftPurchaseEvent extends Event {

private boolean cancelled;
private final String command;
private final ToRunQueuedCommand queuedCommand;

public BuycraftPurchaseEvent(String command, ToRunQueuedCommand queuedCommand) {
this.command = command;
this.queuedCommand = queuedCommand;
}

public ToRunQueuedCommand getQueuedCommand() {
return this.queuedCommand;
}

public String getCommand() {
return this.command;
}

public boolean isCancelled() {
return this.cancelled;
}

public void setCancelled(boolean status) {
this.cancelled = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.buycraft.plugin.data.responses.ServerInformation;
import net.buycraft.plugin.execution.placeholder.PlaceholderManager;
import net.buycraft.plugin.execution.strategy.CommandExecutor;
import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.buycraft.plugin.platform.PlatformInformation;

import java.util.concurrent.TimeUnit;
Expand All @@ -29,7 +30,7 @@ public interface IBuycraftPlatform {
*
* @param command the command to execute
*/
void dispatchCommand(String command);
void dispatchCommand(String command, ToRunQueuedCommand queuedCommand);

/**
* Executes a task to be scheduled as soon as possible asynchronously.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void run() {
String finalCommand = platform.getPlaceholderManager().doReplace(command.getPlayer(), command.getCommand());
platform.log(Level.INFO, String.format("Dispatching command '%s' for player '%s'.", finalCommand, command.getPlayer().getName()));
try {
platform.dispatchCommand(finalCommand);

platform.dispatchCommand(finalCommand, command);
completedCommandsTask.add(command.getCommand().getId());
} catch (Exception e) {
platform.log(Level.SEVERE, String.format("Could not dispatch command '%s' for player '%s'. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.buycraft.plugin.data.QueuedPlayer;
import net.buycraft.plugin.data.responses.ServerInformation;
import net.buycraft.plugin.execution.DuePlayerFetcher;
import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.buycraft.plugin.platform.NoBlocking;
import net.buycraft.plugin.platform.standalone.StandaloneBuycraftPlatform;
import okhttp3.OkHttpClient;
Expand Down Expand Up @@ -64,7 +65,7 @@ private class Platform extends StandaloneBuycraftPlatform {
}

@Override
public void dispatchCommand(String command) {
public void dispatchCommand(String command, ToRunQueuedCommand queuedCommand) {
dispatcher.dispatchCommand(command);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.buycraft.plugin.data.responses.ServerInformation;
import net.buycraft.plugin.execution.placeholder.PlaceholderManager;
import net.buycraft.plugin.execution.strategy.CommandExecutor;
import net.buycraft.plugin.execution.strategy.ToRunQueuedCommand;
import net.buycraft.plugin.platform.PlatformInformation;

import java.util.HashMap;
Expand All @@ -27,7 +28,7 @@ public PlaceholderManager getPlaceholderManager() {
}

@Override
public void dispatchCommand(String command) {
public void dispatchCommand(String command, ToRunQueuedCommand queuedCommand) {
}

@Override
Expand Down
92 changes: 0 additions & 92 deletions nukkit/pom.xml

This file was deleted.

This file was deleted.

Loading