本文整理汇总了PHP中Server::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getInstance方法的具体用法?PHP Server::getInstance怎么用?PHP Server::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setClassLoader
public function setClassLoader(\ClassLoader $loader = null)
{
if ($loader === null) {
$loader = Server::getInstance()->getLoader();
}
$this->classLoader = $loader;
}
示例2: broadcast
public static function broadcast(Player $player, $achievementId)
{
if (isset(Achievement::$list[$achievementId])) {
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::RED . Achievement::$list[$achievementId]["name"]]);
if (Server::getInstance()->getConfigString("announce-player-achievements", true) === true) {
Server::getInstance()->broadcastMessage($translation);
} else {
$player->sendMessage($translation);
}
return true;
}
return false;
}
示例3: findMappingFilter
/**
* @param $pattern
* @return Filter
*/
public function findMappingFilter($pattern)
{
$direct_mapping = Server::getInstance()->getAppConfig("filter_direct_mappings");
if (array_key_exists($pattern, $direct_mapping)) {
$filter = new $direct_mapping[$pattern]();
if ($filter instanceof Filter) {
return $filter;
} else {
return false;
}
} else {
return false;
}
}
示例4: getServerInstance
/**
* Returns server instance.
*
* @return \Jyxo\Rpc\Server
*/
protected function getServerInstance()
{
return Server::getInstance();
}
示例5:
<?php
require_once './oktopus/Oktopus/Engine.php';
Oktopus\Engine::start('/tmp/');
Oktopus\Engine::autoloader()->addPath('./Engine', true, true);
Server::getInstance()->stop();
示例6: EditServer
public static function EditServer($serverid)
{
$xtpl = self::$xtpl;
$xtpl->assign('SERVERSCURR', 'current');
$xtpl->assign('SSERVERMANAGECURR', 'current');
$server = Server::getInstance();
$sg = ServerGroups::getInstance();
$sm = ServerModule::getInstance();
if (!$serverid || !is_numeric($serverid)) {
$xtpl->parse('main.editserver.gwerror');
} else {
$serverdata = $server->FetchData($serverid);
$xtpl->assign('Status' . $serverdata['status'], 'selected="selected"');
$sgdata = $sg->FetchData($serverdata['servergroupid']);
$sm->id = $sgdata['moduleid'];
$sa = unserialize($serverdata['accessdata']);
$op_array = $sm->getOperateArray();
if (is_array($op_array) && count($op_array) > 0) {
for ($i = 0; $i < count($op_array); $i++) {
//for($n=0;$n<count($sa);$n++){
if (@array_key_exists($op_array[$i]['name'], @$sa)) {
$op_array[$i]['value'] = $sa[$op_array[$i]['name']];
}
//}
$xtpl->assign('INPUT', $op_array[$i]);
$xtpl->parse('main.editserver.server.inputtext');
}
}
$xtpl->assign('SRV', $serverdata);
$xtpl->parse('main.editserver.server');
}
$xtpl->parse('main.editserver');
$xtpl->parse('main');
$xtpl->out('main');
}
示例7: start
public static function start($pId)
{
session_name($pId . '__' . Server::getInstance()->getServerDate());
session_start();
}
示例8: onRun
public function onRun($currentTick)
{
Server::getInstance()->broadcastMessage("");
}
示例9: getServerInstance
/**
* Returns server instance.
*
* @return \Jyxo\Rpc\Server
*/
protected function getServerInstance() : \Jyxo\Rpc\Server
{
return Server::getInstance();
}
示例10: date
<?php
/**
* Created by JetBrains PhpStorm.
* User: juliens
* Date: 14/06/11
* Time: 20:21
* To change this template use File | Settings | File Templates.
*/
require_once './oktopus/Oktopus/Engine.php';
Oktopus\Engine::start('/tmp/');
Oktopus\Engine::autoloader()->addPath('./Engine', true, true);
if (Server::getInstance()->isRunning()) {
echo "Le serveur est démarré depuis " . date("d/m/Y H:i:s", Server::getInstance()->getServerDate()) . "<br />";
echo "<h1>Applications : </h1><ul>";
Server::getInstance()->loadConfig();
$apps = Server::getInstance()->getConfig("AppList");
if (is_array($apps)) {
foreach ($apps as $app) {
echo "<li>{$app}<a href=\"./phar.php?app={$app}\">phar</a></li>";
}
echo "</ul>";
}
} else {
echo "Le serveur n'est pas démarré";
}
示例11: microtime
<?php
$timer = microtime(true);
require_once './oktopus/Oktopus/Engine.php';
Oktopus\Engine::start('/tmp/');
Oktopus\Engine::autoloader()->addPath('./Engine', true, true);
//Server::getInstance()->start();
Server::getInstance()->load();
$timer = microtime(true) - $timer;
//echo "[ $timer ]";
//var_dump(Server::getInstance()->getServerDate());
示例12: getChunkCacheFromData
/**
*
* @param
* $chunkX
* @param
* $chunkZ
* @param
* $payload
*
* @return DataPacket
*/
public static function getChunkCacheFromData($chunkX, $chunkZ, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS)
{
$pk = new FullChunkDataPacket();
$pk->chunkX = $chunkX;
$pk->chunkZ = $chunkZ;
$pk->order = $ordering;
$pk->data = $payload;
$pk->encode();
$batch = new BatchPacket();
$batch->payload = zlib_encode(Binary::writeInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel);
$batch->encode();
$batch->isEncoded = true;
return $batch;
}
示例13: __construct
public function __construct(bool $useJson = false)
{
$this->registerBrewingStand();
if ($useJson) {
// load recipes from src/pocketmine/recipes.json
$recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []);
MainLogger::getLogger()->info("Loading recipes...");
foreach ($recipes->getAll() as $recipe) {
switch ($recipe["Type"]) {
case 0:
// TODO: handle multiple result items
if (count($recipe["Result"]) == 1) {
$first = $recipe["Result"][0];
$result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]));
foreach ($recipe["Ingredients"] as $ingredient) {
$result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"]));
}
$this->registerRecipe($result);
}
break;
case 1:
// TODO: handle multiple result items
if (count($recipe["Result"]) == 1) {
$first = $recipe["Result"][0];
$result = new ShapedRecipeFromJson(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]);
$shape = array_chunk($recipe["Ingredients"], $recipe["Width"]);
foreach ($shape as $y => $row) {
foreach ($row as $x => $ingredient) {
$result->addIngredient($x, $y, Item::get($ingredient["ID"], $ingredient["Damage"] < 0 ? null : $ingredient["Damage"], $ingredient["Count"]));
}
}
$this->registerRecipe($result);
}
break;
case 2:
$result = $recipe["Result"];
$resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
$this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], null, 1)));
break;
case 3:
$result = $recipe["Result"];
$resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]);
$this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1)));
break;
default:
break;
}
}
} else {
$this->registerFurnace();
$this->registerDyes();
$this->registerIngots();
$this->registerTools();
$this->registerWeapons();
$this->registerArmor();
$this->registerFood();
$this->registerBrewingStand();
$this->registerRecipe((new ShapedRecipe(Item::get(Item::CLAY_BLOCK, 0, 1), "XX ", "XX ", " "))->setIngredient("X", Item::get(Item::CLAY, 0, 4)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WORKBENCH, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::GLOWSTONE_BLOCK, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::GLOWSTONE_DUST, 0, 4)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::LIT_PUMPKIN, 0, 1), "X ", "Y "))->setIngredient("X", Item::get(Item::PUMPKIN, 0, 1))->setIngredient("Y", Item::get(Item::TORCH, 0, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::SNOW_BLOCK, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::SNOWBALL)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::STICK, 0, 4), "X ", "X "))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::OAK, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::SPRUCE, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::BIRCH, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4), "X"))->setIngredient("X", Item::get(Item::WOOD, Wood::JUNGLE, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4), "X"))->setIngredient("X", Item::get(Item::WOOD2, Wood2::ACACIA, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4), "X"))->setIngredient("X", Item::get(Item::WOOD2, Wood2::DARK_OAK, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::WOOL, 0, 1), "XX", "XX"))->setIngredient("X", Item::get(Item::STRING, 0, 4)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), "C ", "S"))->setIngredient("C", Item::get(Item::COAL, null, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1)));
$this->registerRecipe((new ShapedRecipe(Item::get(Item::SUGAR, 0, 1), "S"))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 1)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::SNOW_LAYER, 0, 6), "XXX"))->setIngredient("X", Item::get(Item::SNOW_BLOCK, 0, 3)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::BED, 0, 1), "WWW", "PPP", " "))->setIngredient("W", Item::get(Item::WOOL, null, 3))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 3)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::CHEST, 0, 1), "PPP", "P P", "PPP"))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 8)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::ENCHANTMENT_TABLE, 0, 1), " B ", "DOD", "OOO"))->setIngredient("D", Item::get(Item::DIAMOND, 0, 2))->setIngredient("O", Item::get(Item::OBSIDIAN, 0, 4))->setIngredient("B", Item::get(Item::BOOK, 0, 1)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, 0, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::ACACIA, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::DARK_OAK, 3), "PSP", "PSP", " "))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_SPRUCE, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_BIRCH, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_JUNGLE, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_DARK_OAK, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_ACACIA, 0, 1), "SPS", "SPS", " "))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 2)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::FURNACE, 0, 1), "CCC", "C C", "CCC"))->setIngredient("C", Item::get(Item::COBBLESTONE, 0, 8)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::GLASS_PANE, 0, 16), "GGG", "GGG", " "))->setIngredient("G", Item::get(Item::GLASS, 0, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::LADDER, 0, 2), "S S", "SSS", "S S"))->setIngredient("S", Item::get(Item::STICK, 0, 7)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::TRAPDOOR, 0, 2), "PPP", "PPP", " "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::BIRCH_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::SPRUCE_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::JUNGLE_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::ACACIA_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::DARK_OAK_DOOR, 0, 3), "PP ", "PP ", "PP "))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::IRON_DOOR, 0, 1), "II ", "II ", "II "))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 6)));
$this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOAT, 0, 1), "PSP", "PPP", " "))->setIngredient("S", Item::get(Item::WOODEN_SHOVEL, 0, 1))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 5)));
//.........这里部分代码省略.........
示例14:
<pre>
<?php
require_once './oktopus/Oktopus/Engine.php';
Oktopus\Engine::start('/tmp/');
Oktopus\Engine::autoloader()->addPath('./Engine', true, true);
Server::getInstance()->stop();
Server::getInstance()->start();
?>
</pre>
示例15: catch
Page::message();
}
Page::Presets();
break;
case 'updateservergroup':
$sg = ServerGroups::getInstance();
try {
$sg->BatchUpdate($_POST, $_POST['groupid']);
} catch (Exception $e) {
Page::$messages[] = array('type' => 'attention', nl2br("Fatal error catched: " . $e));
Page::message();
}
Page::ManageServerGroups();
break;
case 'delserver':
$server = Server::getInstance();
try {
$server->Delete($_REQUEST['id']);
} catch (Exception $e) {
Page::$messages[] = array('type' => 'attention', nl2br("Fatal error catched: " . $e));
Page::message();
}
Page::Servers();
break;
case 'delservergroup':
$sg = ServerGroups::getInstance();
try {
$sg->Delete($_REQUEST['id']);
} catch (Exception $e) {
Page::$messages[] = array('type' => 'attention', nl2br("Fatal error catched: " . $e));
Page::message();