Repository navigation
Expand file tree
/
Copy pathautoload.php
More file actions
119 lines (99 loc) · 3.37 KB
/
Copy pathautoload.php
File metadata and controls
119 lines (99 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
class PluginCore{
public $HAL_PLUGINS;
function __construct(){
//Scan Plugins
$_files=scandir(__DIR__);
$HAL_PLUGINS=array();
foreach ($_files as $fle){
if(substr($fle,0,3)=="mod"){
require_once __DIR__."/".$fle;
$plug=substr(explode(".",$fle)[0],3);
$HAL_PLUGINS[$plug]=new $plug;
}
}
$this->HAL_PLUGINS=$HAL_PLUGINS;
}
function callPlugin($endpoint, ...$data){
$_endpoint=explode("::",$endpoint);
if(key_exists($_endpoint[0],$this->HAL_PLUGINS)){
$plug=$this->HAL_PLUGINS[$_endpoint[0]];
if(method_exists($plug,$_endpoint[1])) return $plug->{$_endpoint[1]}(...$data);
}
return null;
}
//===ESSENTIAL===
function preInit(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::preInit",$this,...$data);
}
}
function unload(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::unload",$this,...$data);
}
}
//===PLAYER===
function onPlayerNew(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onPlayerNew",$this,...$data);
}
}
function onPlayerActivate(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onPlayerActivate",$this,...$data);
}
}
function onPlayerLogin(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onPlayerLogin",$this,...$data);
}
}
function onPlayerBackup(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onPlayerBackup",$this,...$data);
}
}
function onPlayerScoreUpdate(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onPlayerScoreUpdate",$this,...$data);
}
}
//===LEVEL===
function onLevelUpload(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onLevelUpload",$this,...$data);
}
}
function onLevelUpdate(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onLevelUpdate",$this,...$data);
}
}
function onLevelDelete(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onLevelDelete",$this,...$data);
}
}
function onLevelRate(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onLevelRate",$this,...$data);
}
}
function onLevelReport(...$data){
foreach (array_keys($this->HAL_PLUGINS) as $plugin){
$this->callPlugin($plugin."::onLevelReport",$this,...$data);
}
}
// function unload(...$data){
// foreach (array_keys($this->HAL_PLUGINS) as $plugin){
// $this->callPlugin($plugin."::unload",$this,...$data);
// }
// }
}
//$plug=new PluginCore();
//var_dump($plug->HAL_PLUGINS);
//
//$plug->preInit();
//$plug->onLevelUpload(4,"hi halogen","DaniilKreyk","-");
//$plug->unload();