-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(event): add PlayerInteractActorEvent
- Loading branch information
1 parent
4319bda
commit c9a4611
Showing
3 changed files
with
68 additions
and
2 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
54 changes: 54 additions & 0 deletions
54
include/endstone/event/player/player_interact_actor_event.h
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,54 @@ | ||
// 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/event/player/player_event.h" | ||
|
||
namespace endstone { | ||
|
||
/** | ||
* @brief Represents an event that is called when a player right-clicks an actor. | ||
*/ | ||
class PlayerInteractActorEvent : public PlayerEvent { | ||
public: | ||
explicit PlayerInteractActorEvent(Player &player, Actor &actor) : PlayerEvent(player), actor_(actor) {} | ||
~PlayerInteractActorEvent() override = default; | ||
|
||
inline static const std::string NAME = "PlayerInteractActorEvent"; | ||
[[nodiscard]] std::string getEventName() const override | ||
{ | ||
return NAME; | ||
} | ||
|
||
[[nodiscard]] bool isCancellable() const override | ||
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @brief Gets the actor that was right-clicked by the player. | ||
* | ||
* @return actor right-clicked by player | ||
*/ | ||
[[nodiscard]] Actor &getActor() const | ||
{ | ||
return actor_; | ||
} | ||
|
||
private: | ||
Actor &actor_; | ||
}; | ||
|
||
} // namespace endstone |
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