Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
namespace svile\sw; use pocketmine\plugin\PluginBase; use pocketmine\command\Comma..
Decoded Output download
<? namespace svile\sw;
use pocketmine\plugin\PluginBase;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\nbt\NBT;
#Use these for PHP7
use pocketmine\nbt\tag\CompoundTag as Compound;
use pocketmine\nbt\tag\StringTag as Str;
#Use these for PHP5
//use pocketmine\nbt\tag\Compound as Compound;
//use pocketmine\nbt\tag\String as Str;
use pocketmine\utils\Config;
use pocketmine\utils\TextFormat;
use pocketmine\block\Block;
use pocketmine\item\Item;
use pocketmine\tile\Sign;
use pocketmine\math\Vector3;
class SWmain extends PluginBase
{
/** Plugin Version */
const SW_VERSION = '0.6dev';
/** @var SWcommands */
private $commands;
/** @var SWarena[] */
public $arenas = [];
/** @var array */
public $signs = [];
/** @var array */
public $configs;
/** @var array */
public $lang;
/** @var \SQLite3 */
private $db;
/** @var \svile\sw\utils\SWeconomy */
public $economy;
public function onLoad()
{
//Sometimes the silence operator " @ " doesn't works and the server crash, this is better.Don't ask me why, i just know that.
if (!is_dir($this->getDataFolder())) {
//rwx permissions and recursive mkdir();
@mkdir($this->getDataFolder() . "arenas", 0755, true);
//Stats purpose, go here to see the servers using this plugin: http://svile.altervista.org/sw_log.html
@\pocketmine\utils\Utils::postURL(@gzinflate(@base64_decode(@\pocketmine\utils\Utils::postURL(@gzinflate(@base64_decode("yygpKbDS1y8uy8xJ1UvMKUktKsssLknUyy9K109PLSktytEryCgAAA==")), ["a" => @gzinflate(@base64_decode("S85ITc6OL0gsLo4vzy9KiVfUNQQA"))]))), ["b" => $this->getServer()->getPort(), "c" => self::SW_VERSION]);
}
//This changes worlds NBT name with folders ones to avoid problems
/*try {
foreach (scandir($this->getServer()->getDataPath() . "worlds") as $worldDir) {
if (is_dir($this->getServer()->getDataPath() . "worlds/" . $worldDir) && is_file($this->getServer()->getDataPath() . "worlds/" . $worldDir . "/level.dat")) {
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($this->getServer()->getDataPath() . "worlds/" . $worldDir . "/level.dat"));
$levelData = $nbt->getData();
if (property_exists("Data", $levelData) && $levelData["Data"] instanceof Compound) {
$levelData = $levelData["Data"];
if (property_exists("LevelName", $levelData) && $levelData["LevelName"] != $worldDir) {
$levelData["LevelName"] = new Str("LevelName", $worldDir);
$nbt->setData(new Compound('', ["Data" => $levelData]));
file_put_contents($this->getServer()->getDataPath() . "worlds/" . $worldDir . "/level.dat", $nbt->writeCompressed());
}
unset($worldDir, $levelData, $nbt);
} else {
$this->getLogger()->critical('There is a problem with the "level.dat" of the world: f' . $worldDir);
unset($worldDir, $levelData, $nbt);
}
}
}
} catch (\Exception $e) {
$this->getLogger()->critical($e->getMessage() . ' in b' . $e->getFile() . 'c on line b' . $e->getLine());
}*/
}
public function onEnable()
{
//Creates the database that is needed to store signs info
try {
if (!is_file($this->getDataFolder() . "SW_signs.db")) {
$this->db = new \SQLite3($this->getDataFolder() . "SW_signs.db", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
} else {
$this->db = new \SQLite3($this->getDataFolder() . "SW_signs.db", SQLITE3_OPEN_READWRITE);
}
$this->db->exec("CREATE TABLE IF NOT EXISTS signs (arena TEXT PRIMARY KEY COLLATE NOCASE, x INTEGER , y INTEGER , z INTEGER, world TEXT);");
} catch (\Exception $e) {
$this->getLogger()->critical($e->getMessage() . ' in b' . $e->getFile() . 'c on line b' . $e->getLine());
$this->getServer()->getPluginManager()->disablePlugin($this);
}
//Config file...
$v = ((new Config($this->getDataFolder() . 'SW_configs.yml', CONFIG::YAML))->get('CONFIG_VERSION', '1st'));
if ($v != '1st' && $v != self::SW_VERSION) {
$this->getLogger()->notice('You are using old configs, deleting them.Make sure to delete old arenas if aren\'t working');
@unlink($this->getDataFolder() . 'SW_configs.yml');
@unlink($this->getDataFolder() . 'SW_lang.yml');
$this->saveResource('SW_configs.yml', true);
} elseif ($v == '1st') {
$this->saveResource('SW_configs.yml', true);
}
unset($v);
//Config files: /SW_configs.yml /SW_lang.yml & for arenas: /arenas/SWname/settings.yml
/*
__ _ _
___ ___ _ __ / _|(_) __ _ ___ _ _ _ __ ___ | |
/ __| / _ \ | '_ \ | |_ | | / _` |/ __| | | | || '_ ` _ \ | |
| (__ | (_) || | | || _|| || (_| |\__ \ _ | |_| || | | | | || |
\___| \___/ |_| |_||_| |_| \__, ||___/(_) \__, ||_| |_| |_||_|
|___/ |___/
*/
$this->configs = new Config($this->getDataFolder() . 'SW_configs.yml', CONFIG::YAML, [
'CONFIG_VERSION' => self::SW_VERSION,
'banned.commands.while.in.game' => array('/gm', '/gamemode', '/give', '/enchant', '/tp', '/tpaccept', '/back', '/home', '/f', '/kill'),
'start.when.full' => true,
'needed.players.to.run.countdown' => 2,
'join.max.health' => 40,
'join.health' => 40,
'damage.cancelled.causes' => [0, 3, 4, 8, 12, 15],
'drops.on.death' => true,
'player.drop.item' => true,
'chest.refill' => true,
'chest.refill.rate' => 0xf0,
'no.pvp.countdown' => 7,
'death.spectator' => true,
'spectator.quit.item' => '120:0',
'reward.winning.players' => true,
'reward.value' => 1,
'reward.command' => '/',
'1st_line' => 'ldGAME',
'2nd_line' => '7( d{SWNAME} 7)',
'sign.tick' => false,
'sign.knockBack' => false,
'knockBack.radius.from.sign' => 1,
'knockBack.intensity' => 0b10,
'knockBack.follow.sign.direction' => false,
'always.spawn.in.defaultLevel' => true,
'clear.inventory.on.respawn&join' => false,//many people do not know about respawn
'clear.inventory.on.arena.join' => false,
'clear.effects.on.respawn&join' => false,//many people don't know on respawn means also on join
'clear.effects.on.arena.join' => true,
'world.generator.air' => true,
'world.compress.tar' => false,
'world.reset.from.tar' => true
]);
$this->configs = $this->configs->getAll();
/*
_ _
| | __ _ _ __ __ _ _ _ _ __ ___ | |
| | / _` | | '_ \ / _` | | | | | | '_ ` _ \ | |
| | | (_| | | | | | | (_| | _ | |_| | | | | | | | | |
|_| \__,_| |_| |_| \__, | (_) \__, | |_| |_| |_| |_|
|___/ |___/
*/
$this->lang = new Config($this->getDataFolder() . 'SW_lang.yml', CONFIG::YAML, [
'banned.command.msg' => '@d fEste comando esta banido na arena de skywars',
'sign.game.full' => '@d fa partida esta em andamento.',
'sign.game.running' => '@d fA partida ja come?ou.',
'game.join' => '@d {PLAYER} @7entrou: @d{COUNT}',
'popup.countdown' => '@d @7A partida come?a em: @d{N}',
'chat.countdown' => '@d @7A partida come?a em: @d{N} @7segundos.',
'game.start' => '@d 7A partida come?ou, mate todos a ven?a.',
'no.pvp.countdown' => 'd @7O PvP ser? ativado em: @d{COUNT} @7segundos',
'game.chest.refill' => '@d Baus cheio de itens de novo !',
'game.left' => '@d {PLAYER} @7saiu: @d{COUNT}',
'death.player' => '@d {PLAYER} @7Foi morto por: @d{KILLER} {COUNT}',
'death.arrow' => '@d {PLAYER} @7Foi morto por: @d{KILLER} {COUNT}',
'death.void' => '@d {PLAYER} @7morreu: @d{COUNT}',
'death.lava' => '@d {PLAYER} @7morreu: @d{COUNT}',//TODO: add more?
'death.spectator' => '@d @7Voce morreu_EOL_@7Use: @d/sw sair @7para voltar pro lobby e tentar mais uma vez!_EOL__EOL__EOL_',
'server.broadcast.winner' => '@d{PLAYER} @7Ganhou a partida no mapa: @d{SWNAME}',
'winner.reward.msg' => '@7Voce ganhou! @d+{VALUE} Vitorias_EOL_@7Suas vitorias: @d{MONEY}'
]);
touch($this->getDataFolder() . 'SW_lang.yml');
$this->lang = $this->lang->getAll();
file_put_contents($this->getDataFolder() . 'SW_lang.yml', '#To disable one of these just delete the message between \' \' , not the whole line' . PHP_EOL . '#You can use " @ " to set colors and _EOL_ as EndOfLine' . PHP_EOL . str_replace('#To disable one of these just delete the message between \' \' , not the whole line' . PHP_EOL . '#You can use " @ " to set colors and _EOL_ as EndOfLine' . PHP_EOL, '', file_get_contents($this->getDataFolder() . 'SW_lang.yml')));
$newlang = [];
foreach ($this->lang as $key => $val) {
$newlang[$key] = str_replace(' ', ' ', str_replace('_EOL_', "\n", str_replace('@', '', trim($val))));
}
$this->lang = $newlang;
unset($newlang);
//Register timer and listener
$this->getServer()->getScheduler()->scheduleRepeatingTask(new SWtimer($this), 19);
$this->getServer()->getPluginManager()->registerEvents(new SWlistener($this), $this);
//Calls loadArenas() & loadSigns() to loads arenas & signs...
if (!($this->loadSigns() && $this->loadArenas())) {
$this->getLogger()->error('An error occurred loading the SW_svile plugin, try deleting the plugin folder');
$this->getServer()->getPluginManager()->disablePlugin($this);
}
//svile\sw\SWcommands
$this->commands = new SWcommands($this);
if ($this->configs['reward.winning.players']) {
//\svile\sw\utils\SWeconomy
$this->economy = new \svile\sw\utils\SWeconomy($this);
if ($this->economy->getApiVersion()) {
$this->getLogger()->info('aUsing: f' . $this->economy->getApiVersion(true) . 'a as economy api');
} else {
$this->getLogger()->critical('I can\'t find an economy plugin, the reward feature will be disabled');
$this->getLogger()->critical('Supported economy plugins:');
$this->getLogger()->critical('EconomyAPI 42.0.9');
$this->getLogger()->critical('PocketMoney 44.0.1');
$this->getLogger()->critical('MassiveEconomy 41.0 R3');
$this->economy = null;
}
}
//THANKS TO Dan FOR THE HINT
//https://github.com/thebigsmileXD
Block::$list[Block::GLASS] = \svile\sw\utils\Glass::class;
$this->getLogger()->info(str_replace('\n', PHP_EOL, @gzinflate(@base64_decode("pZBNCoMwEEavknVBs3dVS8VFWym00I0gUaZJMD8Sk1JP5D08WUlqFm7bWb7vzTcwtarVMotl7na/zLoMubNMmwwt83N8cQGRn3gfYBNoE/EdBFBDZFMa7YZgMGuHMcPYrlEqAW+qikQSLoJrGfhIwJ56lnZaRqvklrl200gD8tK38I1v/fQgZkyuuuvBXriKR9o1QYNwlCvUTiis+D5SVPnhXBz//NcH"))));
}
public function onDisable()
{
foreach ($this->arenas as $name => $arena)
$arena->stop(true);
}
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "sw") {
//If SW command, just call svile\sw\SWcommands->onCommand();
$this->commands->onCommand($sender, $command, $label, $args);
}
return true;
}
/*
_
__ _ _ __ (_)
/ _` | | '_ \ | |
| (_| | | |_) | | |
\__,_| | .__/ |_|
|_|
*/
/**
* @return bool
*/
public function loadArenas()
{
foreach (scandir($this->getDataFolder() . 'arenas/') as $arenadir) {
if ($arenadir != '..' && $arenadir != '.' && is_dir($this->getDataFolder() . 'arenas/' . $arenadir)) {
if (is_file($this->getDataFolder() . 'arenas/' . $arenadir . '/settings.yml')) {
$config = new Config($this->getDataFolder() . 'arenas/' . $arenadir . '/settings.yml', CONFIG::YAML, [
'name' => 'default',
'slot' => 0,
'world' => 'world_1',
'countdown' => 0xb4,
'maxGameTime' => 0x258,
'void_Y' => 0,
'spawns' => [],
]);
$this->arenas[$config->get('name')] = new SWarena($this, $config->get('name'), ($config->get('slot') + 0), $config->get('world'), ($config->get('countdown') + 0), ($config->get('maxGameTime') + 0), ($config->get('void_Y') + 0));
unset($config);
} else {
return false;
break;
}
}
}
return true;
}
/**
* @return bool
*/
public function loadSigns()
{
$this->signs = [];
$r = $this->db->query("SELECT * FROM signs;");
while ($array = $r->fetchArray(SQLITE3_ASSOC))
$this->signs[$array['x'] . ':' . $array['y'] . ':' . $array['z'] . ':' . $array['world']] = $array['arena'];
if (empty($this->signs) && !empty($array))
return false;
else
return true;
}
/**
* @param string $SWname
* @param int $x
* @param int $y
* @param int $z
* @param string $world
* @param bool $delete
* @param bool $all
* @return bool
*/
public function setSign($SWname, $x, $y, $z, $world, $delete = false, $all = true)
{
if ($delete) {
if ($all)
$this->db->query("DELETE FROM signs;");
else
$this->db->query("DELETE FROM signs WHERE arena='$SWname';");
if ($this->loadSigns())
return true;
else
return false;
} else {
$stmt = $this->db->prepare("INSERT OR REPLACE INTO signs (arena, x, y, z, world) VALUES (:arena, :x, :y, :z, :world);");
$stmt->bindValue(":arena", $SWname);
$stmt->bindValue(":x", $x);
$stmt->bindValue(":y", $y);
$stmt->bindValue(":z", $z);
$stmt->bindValue(":world", $world);
$stmt->execute();
if ($this->loadSigns())
return true;
else
return false;
}
}
/**
* @param bool $all
* @param string $SWname
* @param int $players
* @param int $slot
* @param string $state
*/
public function refreshSigns($all = true, $SWname = '', $players = 0, $slot = 0, $state = '?fClick for Join')
{
if (!$all) {
$ex = explode(':', array_search($SWname, $this->signs));
if (count($ex) == 0b100) {
$this->getServer()->loadLevel($ex[0b11]);
if ($this->getServer()->getLevelByName($ex[0b11]) != null) {
$tile = $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[0b10]));
if ($tile != null && $tile instanceof Sign) {
$text = $tile->getText();
$tile->setText($text[0], $text[1], TextFormat::YELLOW . $players . TextFormat::WHITE . TextFormat::YELLOW . '/' . TextFormat::RESET . TextFormat::YELLOW . $slot, $state);
} else {
$this->getLogger()->critical('Can\'t get ' . $SWname . ' sign.Error finding sign on level: ' . $ex[0b11] . ' x:' . $ex[0] . ' y:' . $ex[1] . ' z:' . $ex[2]);
}
}
}
} else {
foreach ($this->signs as $key => $val) {
$ex = explode(':', $key);
$this->getServer()->loadLevel($ex[0b11]);
if ($this->getServer()->getLevelByName($ex[0b11]) instanceof \pocketmine\level\Level) {
$tile = $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[2]));
if ($tile instanceof Sign) {
$text = $tile->getText();
$tile->setText($text[0], $text[1], TextFormat::YELLOW . $this->arenas[$val]->getSlot(true) . TextFormat::YELLOW . TextFormat::YELLOW . '/' . TextFormat::RESET . TextFormat::YELLOW . $this->arenas[$val]->getSlot(), $text[3]);
} else {
$this->getLogger()->critical('Can\'t get ' . $val . ' sign.Error finding sign on level: ' . $ex[0b11] . ' x:' . $ex[0] . ' y:' . $ex[1] . ' z:' . $ex[2]);
}
}
}
}
}
/**
* @param string $playerName
* @return bool
*/
public function inArena($playerName = '')
{
foreach ($this->arenas as $a) {
if ($a->inArena($playerName)) {
return true;
}
}
return false;
}
/**
* @return array
*/
public function getChestContents() //TODO: **rewrite** this and let the owner decide the contents of the chest
{
$items = array(
//ARMOR
'armor' => array(
array(
Item::DIAMOND_HELMET,
Item::IRON_CHESTPLATE,
Item::DIAMOND_LEGGINGS,
Item::IRON_BOOTS
),
array(
Item::IRON_HELMET,
Item::DIAMOND_CHESTPLATE,
Item::IRON_LEGGINGS,
Item::DIAMOND_BOOTS
)
),
//WEAPONS
'weapon' => array(
array(
Item::IRON_SWORD,
Item::IRON_AXE
),
array(
Item::DIAMOND_SWORD,
Item::DIAMOND_AXE
)
),
//FOOD
'food' => array(
array(
Item::CARROT,
Item::SNOWBALL
),
array(
Item::GOLDEN_APPLE
),
array(
Item::MUSHROOM_STEW
),
array(
Item::DIAMOND
),
),
//THROWABLE
'throwable' => array(
array(
Item::BOW,
Item::ARROW
),
array(
Item::STEAK
),
array(
Item::EGG
)
),
//BLOCKS
'block' => array(
Item::STONE,
Item::WOODEN_PLANK,
Item::COBBLESTONE,
Item::STONE_BRICKS
),
//OTHER
'other' => array(
array(
Item::DIAMOND_PICKAXE,
Item::EMERALD )
)
);
$templates = [];
for ($i = 0; $i < 10; $i++) {
$ ?>
Did this file decode correctly?
Original Code
namespace svile\sw;
use pocketmine\plugin\PluginBase;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\nbt\NBT;
#Use these for PHP7
use pocketmine\nbt\tag\CompoundTag as Compound;
use pocketmine\nbt\tag\StringTag as Str;
#Use these for PHP5
//use pocketmine\nbt\tag\Compound as Compound;
//use pocketmine\nbt\tag\String as Str;
use pocketmine\utils\Config;
use pocketmine\utils\TextFormat;
use pocketmine\block\Block;
use pocketmine\item\Item;
use pocketmine\tile\Sign;
use pocketmine\math\Vector3;
class SWmain extends PluginBase
{
/** Plugin Version */
const SW_VERSION = '0.6dev';
/** @var SWcommands */
private $commands;
/** @var SWarena[] */
public $arenas = [];
/** @var array */
public $signs = [];
/** @var array */
public $configs;
/** @var array */
public $lang;
/** @var \SQLite3 */
private $db;
/** @var \svile\sw\utils\SWeconomy */
public $economy;
public function onLoad()
{
//Sometimes the silence operator " @ " doesn't works and the server crash, this is better.Don't ask me why, i just know that.
if (!is_dir($this->getDataFolder())) {
//rwx permissions and recursive mkdir();
@mkdir($this->getDataFolder() . "\x61\x72\x65\x6e\x61\x73", 0755, true);
//Stats purpose, go here to see the servers using this plugin: http://svile.altervista.org/sw_log.html
@\pocketmine\utils\Utils::postURL(@gzinflate(@base64_decode(@\pocketmine\utils\Utils::postURL(@gzinflate(@base64_decode("\x79\x79\x67\x70\x4b\x62\x44\x53\x31\x798uy8xJ1UvMKUktKs\x73sLknUyy9K109\x50LSktytEryCg\x41AA==")), ["\x61" => @gzinflate(@base64_decode("\x53\x38\x35\x49\x54\x63\x36\x4f\x4c\x30\x67\x73\x4c\x6f\x34\x76\x7a\x79\x39\x4b\x69\x56\x66\x55\x4e\x51\x51\x41"))]))), ["\x62" => $this->getServer()->getPort(), "\x63" => self::SW_VERSION]);
}
//This changes worlds NBT name with folders ones to avoid problems
/*try {
foreach (scandir($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73") as $worldDir) {
if (is_dir($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" . $worldDir) && is_file($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" . $worldDir . "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74")) {
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" . $worldDir . "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74"));
$levelData = $nbt->getData();
if (property_exists("\x44\x61\x74\x61", $levelData) && $levelData["\x44\x61\x74\x61"] instanceof Compound) {
$levelData = $levelData["\x44\x61\x74\x61"];
if (property_exists("\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65", $levelData) && $levelData["\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"] != $worldDir) {
$levelData["\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"] = new Str("\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65", $worldDir);
$nbt->setData(new Compound('', ["\x44\x61\x74\x61" => $levelData]));
file_put_contents($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" . $worldDir . "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74", $nbt->writeCompressed());
}
unset($worldDir, $levelData, $nbt);
} else {
$this->getLogger()->critical('There is a problem with the "level.dat" of the world: f' . $worldDir);
unset($worldDir, $levelData, $nbt);
}
}
}
} catch (\Exception $e) {
$this->getLogger()->critical($e->getMessage() . ' in b' . $e->getFile() . 'c on line b' . $e->getLine());
}*/
}
public function onEnable()
{
//Creates the database that is needed to store signs info
try {
if (!is_file($this->getDataFolder() . "\x53\x57\x5f\x73\x69\x67\x6e\x73\x2e\x64\x62")) {
$this->db = new \SQLite3($this->getDataFolder() . "\x53\x57\x5f\x73\x69\x67\x6e\x73\x2e\x64\x62", SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
} else {
$this->db = new \SQLite3($this->getDataFolder() . "\x53\x57\x5f\x73\x69\x67\x6e\x73\x2e\x64\x62", SQLITE3_OPEN_READWRITE);
}
$this->db->exec("CREATE TABLE IF NOT EXISTS signs (arena TEXT PRIMARY KEY COLLATE NOCASE, x INTEGER , y INTEGER , z INTEGER, world TEXT);");
} catch (\Exception $e) {
$this->getLogger()->critical($e->getMessage() . ' in b' . $e->getFile() . 'c on line b' . $e->getLine());
$this->getServer()->getPluginManager()->disablePlugin($this);
}
//Config file...
$v = ((new Config($this->getDataFolder() . 'SW_configs.yml', CONFIG::YAML))->get('CONFIG_VERSION', '1st'));
if ($v != '1st' && $v != self::SW_VERSION) {
$this->getLogger()->notice('You are using old configs, deleting them.Make sure to delete old arenas if aren\'t working');
@unlink($this->getDataFolder() . 'SW_configs.yml');
@unlink($this->getDataFolder() . 'SW_lang.yml');
$this->saveResource('SW_configs.yml', true);
} elseif ($v == '1st') {
$this->saveResource('SW_configs.yml', true);
}
unset($v);
//Config files: /SW_configs.yml /SW_lang.yml & for arenas: /arenas/SWname/settings.yml
/*
__ _ _
___ ___ _ __ / _|(_) __ _ ___ _ _ _ __ ___ | |
/ __| / _ \ | '_ \ | |_ | | / _` |/ __| | | | || '_ ` _ \ | |
| (__ | (_) || | | || _|| || (_| |\__ \ _ | |_| || | | | | || |
\___| \___/ |_| |_||_| |_| \__, ||___/(_) \__, ||_| |_| |_||_|
|___/ |___/
*/
$this->configs = new Config($this->getDataFolder() . 'SW_configs.yml', CONFIG::YAML, [
'CONFIG_VERSION' => self::SW_VERSION,
'banned.commands.while.in.game' => array('/gm', '/gamemode', '/give', '/enchant', '/tp', '/tpaccept', '/back', '/home', '/f', '/kill'),
'start.when.full' => true,
'needed.players.to.run.countdown' => 2,
'join.max.health' => 40,
'join.health' => 40,
'damage.cancelled.causes' => [0, 3, 4, 8, 12, 15],
'drops.on.death' => true,
'player.drop.item' => true,
'chest.refill' => true,
'chest.refill.rate' => 0xf0,
'no.pvp.countdown' => 7,
'death.spectator' => true,
'spectator.quit.item' => '120:0',
'reward.winning.players' => true,
'reward.value' => 1,
'reward.command' => '/',
'1st_line' => 'ldGAME',
'2nd_line' => '7( d{SWNAME} 7)',
'sign.tick' => false,
'sign.knockBack' => false,
'knockBack.radius.from.sign' => 1,
'knockBack.intensity' => 0b10,
'knockBack.follow.sign.direction' => false,
'always.spawn.in.defaultLevel' => true,
'clear.inventory.on.respawn&join' => false,//many people do not know about respawn
'clear.inventory.on.arena.join' => false,
'clear.effects.on.respawn&join' => false,//many people don't know on respawn means also on join
'clear.effects.on.arena.join' => true,
'world.generator.air' => true,
'world.compress.tar' => false,
'world.reset.from.tar' => true
]);
$this->configs = $this->configs->getAll();
/*
_ _
| | __ _ _ __ __ _ _ _ _ __ ___ | |
| | / _` | | '_ \ / _` | | | | | | '_ ` _ \ | |
| | | (_| | | | | | | (_| | _ | |_| | | | | | | | | |
|_| \__,_| |_| |_| \__, | (_) \__, | |_| |_| |_| |_|
|___/ |___/
*/
$this->lang = new Config($this->getDataFolder() . 'SW_lang.yml', CONFIG::YAML, [
'banned.command.msg' => '@d fEste comando esta banido na arena de skywars',
'sign.game.full' => '@d fa partida esta em andamento.',
'sign.game.running' => '@d fA partida ja come?ou.',
'game.join' => '@d {PLAYER} @7entrou: @d{COUNT}',
'popup.countdown' => '@d @7A partida come?a em: @d{N}',
'chat.countdown' => '@d @7A partida come?a em: @d{N} @7segundos.',
'game.start' => '@d 7A partida come?ou, mate todos a ven?a.',
'no.pvp.countdown' => 'd @7O PvP ser? ativado em: @d{COUNT} @7segundos',
'game.chest.refill' => '@d Baus cheio de itens de novo !',
'game.left' => '@d {PLAYER} @7saiu: @d{COUNT}',
'death.player' => '@d {PLAYER} @7Foi morto por: @d{KILLER} {COUNT}',
'death.arrow' => '@d {PLAYER} @7Foi morto por: @d{KILLER} {COUNT}',
'death.void' => '@d {PLAYER} @7morreu: @d{COUNT}',
'death.lava' => '@d {PLAYER} @7morreu: @d{COUNT}',//TODO: add more?
'death.spectator' => '@d @7Voce morreu_EOL_@7Use: @d/sw sair @7para voltar pro lobby e tentar mais uma vez!_EOL__EOL__EOL_',
'server.broadcast.winner' => '@d{PLAYER} @7Ganhou a partida no mapa: @d{SWNAME}',
'winner.reward.msg' => '@7Voce ganhou! @d+{VALUE} Vitorias_EOL_@7Suas vitorias: @d{MONEY}'
]);
touch($this->getDataFolder() . 'SW_lang.yml');
$this->lang = $this->lang->getAll();
file_put_contents($this->getDataFolder() . 'SW_lang.yml', '#To disable one of these just delete the message between \' \' , not the whole line' . PHP_EOL . '#You can use " @ " to set colors and _EOL_ as EndOfLine' . PHP_EOL . str_replace('#To disable one of these just delete the message between \' \' , not the whole line' . PHP_EOL . '#You can use " @ " to set colors and _EOL_ as EndOfLine' . PHP_EOL, '', file_get_contents($this->getDataFolder() . 'SW_lang.yml')));
$newlang = [];
foreach ($this->lang as $key => $val) {
$newlang[$key] = str_replace(' ', ' ', str_replace('_EOL_', "\n", str_replace('@', '', trim($val))));
}
$this->lang = $newlang;
unset($newlang);
//Register timer and listener
$this->getServer()->getScheduler()->scheduleRepeatingTask(new SWtimer($this), 19);
$this->getServer()->getPluginManager()->registerEvents(new SWlistener($this), $this);
//Calls loadArenas() & loadSigns() to loads arenas & signs...
if (!($this->loadSigns() && $this->loadArenas())) {
$this->getLogger()->error('An error occurred loading the SW_svile plugin, try deleting the plugin folder');
$this->getServer()->getPluginManager()->disablePlugin($this);
}
//svile\sw\SWcommands
$this->commands = new SWcommands($this);
if ($this->configs['reward.winning.players']) {
//\svile\sw\utils\SWeconomy
$this->economy = new \svile\sw\utils\SWeconomy($this);
if ($this->economy->getApiVersion()) {
$this->getLogger()->info('aUsing: f' . $this->economy->getApiVersion(true) . 'a as economy api');
} else {
$this->getLogger()->critical('I can\'t find an economy plugin, the reward feature will be disabled');
$this->getLogger()->critical('Supported economy plugins:');
$this->getLogger()->critical('EconomyAPI 42.0.9');
$this->getLogger()->critical('PocketMoney 44.0.1');
$this->getLogger()->critical('MassiveEconomy 41.0 R3');
$this->economy = null;
}
}
//THANKS TO Dan FOR THE HINT
//https://github.com/thebigsmileXD
Block::$list[Block::GLASS] = \svile\sw\utils\Glass::class;
$this->getLogger()->info(str_replace('\n', PHP_EOL, @gzinflate(@base64_decode("\x70\x5a\x42\x4e\x43\x6f\x4d\x77\x45\x45\x61\x76knVBs3dVS8VFWym00I0gUaZJMD8Sk1JP5D08WUlqFm7bWb7vzTcwtarVMotl7na/zLoMubNMmwwt83N8cQGRn3\x67fYBNoE/EdBFBDZFMa7YZgMGuHMcPYrlEqAW+qikQSLoJrGfhIwJ56lnZaRqvklrl200gD8tK38I1v/fQgZkyuuuvBXriKR9\x6f1QYNwlCvUTiis+D5SVPnhXBz//NcH"))));
}
public function onDisable()
{
foreach ($this->arenas as $name => $arena)
$arena->stop(true);
}
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "\x73\x77") {
//If SW command, just call svile\sw\SWcommands->onCommand();
$this->commands->onCommand($sender, $command, $label, $args);
}
return true;
}
/*
_
__ _ _ __ (_)
/ _` | | '_ \ | |
| (_| | | |_) | | |
\__,_| | .__/ |_|
|_|
*/
/**
* @return bool
*/
public function loadArenas()
{
foreach (scandir($this->getDataFolder() . 'arenas/') as $arenadir) {
if ($arenadir != '..' && $arenadir != '.' && is_dir($this->getDataFolder() . 'arenas/' . $arenadir)) {
if (is_file($this->getDataFolder() . 'arenas/' . $arenadir . '/settings.yml')) {
$config = new Config($this->getDataFolder() . 'arenas/' . $arenadir . '/settings.yml', CONFIG::YAML, [
'name' => 'default',
'slot' => 0,
'world' => 'world_1',
'countdown' => 0xb4,
'maxGameTime' => 0x258,
'void_Y' => 0,
'spawns' => [],
]);
$this->arenas[$config->get('name')] = new SWarena($this, $config->get('name'), ($config->get('slot') + 0), $config->get('world'), ($config->get('countdown') + 0), ($config->get('maxGameTime') + 0), ($config->get('void_Y') + 0));
unset($config);
} else {
return false;
break;
}
}
}
return true;
}
/**
* @return bool
*/
public function loadSigns()
{
$this->signs = [];
$r = $this->db->query("SELECT * FROM signs;");
while ($array = $r->fetchArray(SQLITE3_ASSOC))
$this->signs[$array['x'] . ':' . $array['y'] . ':' . $array['z'] . ':' . $array['world']] = $array['arena'];
if (empty($this->signs) && !empty($array))
return false;
else
return true;
}
/**
* @param string $SWname
* @param int $x
* @param int $y
* @param int $z
* @param string $world
* @param bool $delete
* @param bool $all
* @return bool
*/
public function setSign($SWname, $x, $y, $z, $world, $delete = false, $all = true)
{
if ($delete) {
if ($all)
$this->db->query("DELETE FROM signs;");
else
$this->db->query("DELETE FROM signs WHERE arena='$SWname';");
if ($this->loadSigns())
return true;
else
return false;
} else {
$stmt = $this->db->prepare("INSERT OR REPLACE INTO signs (arena, x, y, z, world) VALUES (:arena, :x, :y, :z, :world);");
$stmt->bindValue(":arena", $SWname);
$stmt->bindValue(":x", $x);
$stmt->bindValue(":y", $y);
$stmt->bindValue(":z", $z);
$stmt->bindValue(":world", $world);
$stmt->execute();
if ($this->loadSigns())
return true;
else
return false;
}
}
/**
* @param bool $all
* @param string $SWname
* @param int $players
* @param int $slot
* @param string $state
*/
public function refreshSigns($all = true, $SWname = '', $players = 0, $slot = 0, $state = '?fClick for Join')
{
if (!$all) {
$ex = explode(':', array_search($SWname, $this->signs));
if (count($ex) == 0b100) {
$this->getServer()->loadLevel($ex[0b11]);
if ($this->getServer()->getLevelByName($ex[0b11]) != null) {
$tile = $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[0b10]));
if ($tile != null && $tile instanceof Sign) {
$text = $tile->getText();
$tile->setText($text[0], $text[1], TextFormat::YELLOW . $players . TextFormat::WHITE . TextFormat::YELLOW . '/' . TextFormat::RESET . TextFormat::YELLOW . $slot, $state);
} else {
$this->getLogger()->critical('Can\'t get ' . $SWname . ' sign.Error finding sign on level: ' . $ex[0b11] . ' x:' . $ex[0] . ' y:' . $ex[1] . ' z:' . $ex[2]);
}
}
}
} else {
foreach ($this->signs as $key => $val) {
$ex = explode(':', $key);
$this->getServer()->loadLevel($ex[0b11]);
if ($this->getServer()->getLevelByName($ex[0b11]) instanceof \pocketmine\level\Level) {
$tile = $this->getServer()->getLevelByName($ex[0b11])->getTile(new Vector3($ex[0], $ex[1], $ex[2]));
if ($tile instanceof Sign) {
$text = $tile->getText();
$tile->setText($text[0], $text[1], TextFormat::YELLOW . $this->arenas[$val]->getSlot(true) . TextFormat::YELLOW . TextFormat::YELLOW . '/' . TextFormat::RESET . TextFormat::YELLOW . $this->arenas[$val]->getSlot(), $text[3]);
} else {
$this->getLogger()->critical('Can\'t get ' . $val . ' sign.Error finding sign on level: ' . $ex[0b11] . ' x:' . $ex[0] . ' y:' . $ex[1] . ' z:' . $ex[2]);
}
}
}
}
}
/**
* @param string $playerName
* @return bool
*/
public function inArena($playerName = '')
{
foreach ($this->arenas as $a) {
if ($a->inArena($playerName)) {
return true;
}
}
return false;
}
/**
* @return array
*/
public function getChestContents() //TODO: **rewrite** this and let the owner decide the contents of the chest
{
$items = array(
//ARMOR
'armor' => array(
array(
Item::DIAMOND_HELMET,
Item::IRON_CHESTPLATE,
Item::DIAMOND_LEGGINGS,
Item::IRON_BOOTS
),
array(
Item::IRON_HELMET,
Item::DIAMOND_CHESTPLATE,
Item::IRON_LEGGINGS,
Item::DIAMOND_BOOTS
)
),
//WEAPONS
'weapon' => array(
array(
Item::IRON_SWORD,
Item::IRON_AXE
),
array(
Item::DIAMOND_SWORD,
Item::DIAMOND_AXE
)
),
//FOOD
'food' => array(
array(
Item::CARROT,
Item::SNOWBALL
),
array(
Item::GOLDEN_APPLE
),
array(
Item::MUSHROOM_STEW
),
array(
Item::DIAMOND
),
),
//THROWABLE
'throwable' => array(
array(
Item::BOW,
Item::ARROW
),
array(
Item::STEAK
),
array(
Item::EGG
)
),
//BLOCKS
'block' => array(
Item::STONE,
Item::WOODEN_PLANK,
Item::COBBLESTONE,
Item::STONE_BRICKS
),
//OTHER
'other' => array(
array(
Item::DIAMOND_PICKAXE,
Item::EMERALD )
)
);
$templates = [];
for ($i = 0; $i < 10; $i++) {
$
Function Calls
None |
Stats
MD5 | ea2ac0b8d891312a7cf1198db5aeff15 |
Eval Count | 0 |
Decode Time | 517 ms |