mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Basic Event types (extended from Bukkit)
This commit is contained in:
parent
7c12f6ce8a
commit
830530d868
56
src/event/BaseEvent.php
Normal file
56
src/event/BaseEvent.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class BaseEvent{
|
||||
const ALLOW = 0;
|
||||
const DENY = 1;
|
||||
const NORMAL = 2;
|
||||
const FORCE = 0x80000000;
|
||||
|
||||
protected $eventName = null;
|
||||
private $status = BaseEvent::NORMAL;
|
||||
|
||||
final public function getEventName(){
|
||||
return $this->eventName !== null ? get_class($this) : $this->eventName;
|
||||
}
|
||||
|
||||
final public function setPrioritySlot($slot){
|
||||
$this->prioritySlot = (int) $slot;
|
||||
}
|
||||
|
||||
final public function getPrioritySlot(){
|
||||
return (int) $this->prioritySlot;
|
||||
}
|
||||
|
||||
|
||||
public function isAllowed(){
|
||||
return $this->status === BaseEvent::ALLOW;
|
||||
}
|
||||
|
||||
public function setAllowed($forceAllow = false){
|
||||
$this->status = BaseEvent::ALLOW & ($forceAllow === true ? BaseEvent::FORCE : 0);
|
||||
}
|
||||
|
||||
public function isForced(){
|
||||
return ($this->status & BaseEvent::FORCE) > 0;
|
||||
}
|
||||
|
||||
}
|
30
src/event/CancellableEvent.php
Normal file
30
src/event/CancellableEvent.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class CancellableEvent extends BaseEvent{
|
||||
public function isCancelled(){
|
||||
return $this->status === BaseEvent::DENY;
|
||||
}
|
||||
|
||||
public function setCancelled($forceCancel = false){
|
||||
$this->status = BaseEvent::DENY & ($forceCancel === true ? BaseEvent::FORCE : 0);
|
||||
}
|
||||
}
|
52
src/event/EventPriority.php
Normal file
52
src/event/EventPriority.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class EventPriority{
|
||||
/**
|
||||
* Event call is of very low importance and should be ran first, to allow
|
||||
* other plugins to further customise the outcome
|
||||
*/
|
||||
const LOWEST = 5;
|
||||
/**
|
||||
* Event call is of low importance
|
||||
*/
|
||||
const LOW = 4;
|
||||
/**
|
||||
* Event call is neither important or unimportant, and may be ran normally
|
||||
*/
|
||||
const NORMAL = 3;
|
||||
/**
|
||||
* Event call is of high importance
|
||||
*/
|
||||
const HIGH = 2;
|
||||
/**
|
||||
* Event call is critical and must have the final say in what happens
|
||||
* to the event
|
||||
*/
|
||||
const HIGHEST = 1;
|
||||
/**
|
||||
* Event is listened to purely for monitoring the outcome of an event.
|
||||
*
|
||||
* No modifications to the event should be made under this priority
|
||||
*/
|
||||
const MONITOR = 0;
|
||||
|
||||
}
|
24
src/event/MalleableCancellableEvent.php
Normal file
24
src/event/MalleableCancellableEvent.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class MalleableCancellableEvent extends CancellableEvent{
|
||||
|
||||
}
|
24
src/event/MalleableEvent.php
Normal file
24
src/event/MalleableEvent.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class MalleableEvent extends BaseEvent{
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user