Skip to content

Commit

Permalink
feat(command): add ProxiedCommandSender
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Sep 25, 2024
1 parent 11f671d commit 7c7ef21
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
43 changes: 43 additions & 0 deletions include/endstone/command/proxied_command_sender.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "endstone/command/command_sender.h"

namespace endstone {

/**
* @brief Interface for proxied command sender
*/
class ProxiedCommandSender : public CommandSender {
public:
~ProxiedCommandSender() override = default;

/**
* @brief Returns the CommandSender which triggered this proxied command.
*
* @return a shared pointer to the caller which triggered the command
*/
[[nodiscard]] virtual CommandSender &getCaller() const = 0;

/**
* @brief Returns the CommandSender which is being used to call the command.
*
* @return a shared pointer to the caller which the command is being run as
*/
[[nodiscard]] virtual CommandSender &getCallee() const = 0;
};

} // namespace endstone
17 changes: 17 additions & 0 deletions include/endstone/detail/command/proxied_command_sender.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "endstone/command/proxied_command_sender.h"
15 changes: 15 additions & 0 deletions src/endstone_core/command/proxied_command_sender.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2024, The Endstone Project. (https://endstone.dev) All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "endstone/detail/command/proxied_command_sender.h"

0 comments on commit 7c7ef21

Please sign in to comment.