Skip to content

Commit

Permalink
Complete v 1.3.0
Browse files Browse the repository at this point in the history
- Plugin rewrite
- Fixed generator (/mw create)
- Fixed bug when removing world
- Added MultiLanguage support
- Plugin cleanup
- Language support (2 languages)
- Plugin is 100% stable
  • Loading branch information
GamakCZ committed Aug 27, 2017
1 parent 531ffaa commit e4e556a
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 40 deletions.
5 changes: 4 additions & 1 deletion MultiWorld/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: MultiWorld
author: CzechPMDevs
authors: [GamakCZ]
api: [3.0.0-ALPHA7, 4.0.0]
version: 1.3.0 [BETA 3] [PocketMine]
version: 1.3.0
main: MultiWorld\MultiWorld
description: Ported MultiWorld to pocketmine.
website: https://github.com/CzechPMDevs/MultiWorld
Expand Down Expand Up @@ -34,4 +34,7 @@ permissions:
default: op
mw.cmd.unload:
description: Permission for /mw unload
default: op
mw.cmd.delete:
description: Permission for /mw delete
default: op
3 changes: 2 additions & 1 deletion MultiWorld/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
### Config for MultiWorld v:
plugin-version: '1.3.0'

## MultiWorld Language (English)
## MultiWorld Language (English, Czech)
# You can add your language by creating PullRequest at github (github.com/CzechPMDevs/MultiWorld)
lang: 'English'

## If you want to disable prefix, set prefix to ' '
Expand Down
48 changes: 48 additions & 0 deletions MultiWorld/resources/languages/Czech.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---

### Czech language file by @GamakCZ

## Commands:

not-perms: '§cNemáš povolení použít tento příkaz!'
default-usage: '§cPoužij: §7/mw help'

# Help Command:
help-0: '§b--- == §c[§aMultiWorld§c] §b== ---'
help-1: '§e/mw create §7: §9Vytvoří nový svět'
help-2: '§e/mw teleport §7: §9Teleportuje na svět'
help-3: '§e/mw list §7: §9Zobrazí list všech světů'
help-4: '§e/mw <load|unload> §7: §9Načte | Odnačte svět'
# Create Command:
create-usage: '§cPoužij: §7/mw create <jméno> [seed] [generátor]'
create-generating: '§aVytvářím svět %1'
create-done: 'Svět %1 je vytvořen se seedem: %2 a generátorem: %3.'
# Teleport Command:
teleport-usage: '§cPoužij: §7/mw teleport <svět> [hráč]'
teleport-levelnotexists: '§cSvět nebyl nalezen! Použij /mw create pro vytvoření světa.'
teleport-load: 'Načítám svět %1...'
teleport-done-1: '§aJsi teleportován do světa %1.'
teleport-done-2: '§aHráč %2 byl teleportován do světa %1!'
teleport-playernotexists: '§cPlayer does not exists!'
# Import Command:
import-usage: '§cPoužij: §7/mw import <NázevSložky>'
import-zipnotexists: '§cSložka neexistuje!'
import-done: '§aSvět byl importován!'
# List Command:
list-done: '§aSvěty: %1'
# Load Command
load-usage: '§cPoužij: §7/mw load <svět>'
load-levelnotexists: '§cSvět %1 neexistuje!'
load-loaded: '§cNelze načíst načtený svět!'
load-done: '§aSvět byl načten!'
# Unload Command
unload-usage: '§cPoužij: §7/mw unload <svět>'
unload-levelnotexists: '§cSvět %1 neexistuje!'
unload-unloaded: '§cNelze odnačíst odnačtený svět!'
unload-done: '§aSvět byl odnačten!'
# Delete Command
delete-usage: '§cPoužij: §7/mw delete <svět>'
delete-levelnotexists: '§cSvět %1 neexistuje!'
delete-done: '§aSvět byl smazán!'

...
9 changes: 4 additions & 5 deletions MultiWorld/resources/languages/English.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ teleport-load: 'Loading level %1...'
teleport-done-1: '§aYou are teleported to level %1.'
teleport-done-2: '§aPlayer %2 is teleported to level %1!'
teleport-playernotexists: '§cPlayer does not exists!'
# Import Command:
import-usage: '§cUsage: §7/mw import <FolderName>'
import-zipnotexists: '§cZip does not exists!'
import-done: '§aLevel imported!'
# List Command:
list-done: '§aLevels: %1'
# Load Command
Expand All @@ -39,5 +35,8 @@ unload-usage: '§cUsage: §7/mw unload <level>'
unload-levelnotexists: '§cLevel %1 does not exists!'
unload-unloaded: '§cUnable to unload unloaded level!'
unload-done: '§aLevel unloaded!'

# Delete Command
delete-usage: '§cUsage: §7/mw delete <level>'
delete-levelnotexists: '§cLevel %1 does not exists!'
delete-done: '§aLevel deleted!'
...
107 changes: 82 additions & 25 deletions MultiWorld/src/MultiWorld/MultiWorld.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class MultiWorld extends PluginBase {

const NAME = "MultiWorld";
const VERSION = "1.3.0 [BETA 3] [PocketMine]";
const VERSION = "1.3.0";
const AUTHOR = "GamakCZ";
const GITHUB = "https://github.com/CzechPMDevs/MultiWorld/";

Expand Down Expand Up @@ -154,7 +154,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
switch (strtolower($args[0])) {
case "help":
case "?":
if(!$this->checkPerms($sender, "help")) return false;
if (!$this->checkPerms($sender, "help")) return false;
$sender->sendMessage(LanguageManager::translateMessage("help-0") . "\n" .
LanguageManager::translateMessage("help-1") . "\n" .
LanguageManager::translateMessage("help-2") . "\n" .
Expand All @@ -165,7 +165,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
case "new":
case "add":
case "generate":
if(!$this->checkPerms($sender, "create")) return false;
if (!$this->checkPerms($sender, "create")) return false;
if (empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("create-usage"));
return false;
Expand All @@ -176,7 +176,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
}
$seed = null;
$generator = null;
count($args) < 3 ? $seed = rand(rand(1,10), rand(50, 99999999999999)) : $seed = $args[2];
count($args) < 3 ? $seed = rand(rand(1, 10), rand(50, 99999999999999)) : $seed = $args[2];
count($args) < 4 ? $generator = "normal" : $generator = $args[3];
strtolower($generator) == "nether" ? $generator = "hell" : $generator = strtolower($generator);
if (Generator::getGeneratorName(Generator::getGenerator($generator)) != strtolower($generator)) {
Expand All @@ -190,7 +190,7 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
case "teleport":
case "tp":
case "move":
if(!$this->checkPerms($sender, "teleport")) return false;
if (!$this->checkPerms($sender, "teleport")) return false;
if (empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("teleport-usage"));
return false;
Expand Down Expand Up @@ -228,8 +228,8 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
return false;
case "ls":
case "list":
if(!$this->checkPerms($sender, "list")) return false;
$allLevels = scandir(ConfigManager::getDataPath()."worlds");
if (!$this->checkPerms($sender, "list")) return false;
$allLevels = scandir(ConfigManager::getDataPath() . "worlds");
unset($allLevels[0]);
unset($allLevels[1]);
$loaded = [];
Expand All @@ -247,46 +247,103 @@ public function onCommand(CommandSender $sender, Command $cmd, string $label, ar
}
}*/
$list = implode(", ", $allLevels);
$sender->sendMessage(MultiWorld::getPrefix().str_replace("%1", $list, LanguageManager::translateMessage("list-done")));
$sender->sendMessage(MultiWorld::getPrefix() . str_replace("%1", $list, LanguageManager::translateMessage("list-done")));
return false;
case "load":
case "ld":
if(!$this->checkPerms($sender, "load")) return false;
if(empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("load-usage"));
if (!$this->checkPerms($sender, "load")) return false;
if (empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("load-usage"));
return false;
}
if(!$this->getServer()->isLevelGenerated($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("load-notexists"));
if (!$this->getServer()->isLevelGenerated($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("load-levelnotexists"));
return false;
}
if($this->getServer()->isLevelLoaded($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("load-loaded"));
if ($this->getServer()->isLevelLoaded($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("load-loaded"));
return false;
}
$this->getServer()->loadLevel($args[1]);
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("load-done"));
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("load-done"));
return false;
case "unload":
case "uld":
if(!$this->checkPerms($sender, "unload")) return false;
if(empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("unload-usage"));
if (!$this->checkPerms($sender, "unload")) return false;
if (empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("unload-usage"));
return false;
}
if(!$this->getServer()->isLevelGenerated($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("unload-notexists"));
if (!$this->getServer()->isLevelGenerated($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("unload-levelnotexists"));
return false;
}
if(!$this->getServer()->isLevelLoaded($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("unload-unloaded"));
if (!$this->getServer()->isLevelLoaded($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("unload-unloaded"));
return false;
}
$this->getServer()->unloadLevel($this->getServer()->getLevelByName($args[1]));
$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("unload-done"));
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("unload-done"));
return false;
case "delete":
case "remove":
case "del":
case "rm":
if (!$this->checkPerms($sender, "delete")) return false;
if (empty($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("delete-usage"));
return false;
}
if (!$this->getServer()->isLevelGenerated($args[1])) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("delete-levelnotexists"));
return false;
}
$levelName = $args[1];
$folderName = $args[1];
if ($this->getServer()->isLevelLoaded($levelName)) {
$level = $this->getServer()->getLevelByName($levelName);
if (count($level->getPlayers()) != 0) {
foreach ($level->getPlayers() as $player) {
$player->teleport($this->getServer()->getDefaultLevel()->getSpawnLocation());
}
}
$folderName = $level->getFolderName();
$level->unload();
}
$folderPath = ConfigManager::getDataPath() . "worlds/{$folderName}";
try {
if(is_dir($folderPath)) {
if(is_dir($folderPath."/region")) {
foreach (glob($folderPath."/region/*.mca") as $chunks) {
unlink($chunks);
}
}
else {
$this->getLogger()->critical("DELETE ERROR #1");
}
rmdir($folderPath."/region");
unlink($folderPath."/level.dat");
foreach (scandir($folderPath) as $file) {
if(!in_array($file, [".", ".."])) {
is_dir($file) ? rmdir($folderPath.$file) : unlink($folderPath.$file);
}
}
rmdir($folderPath);
}
else {
$this->getLogger()->critical("DELETE ERROR #2");
}
}
catch (\Exception $exception) {
$github = MultiWorld::GITHUB;
$sender->sendMessage("§cError when deleting world. Submit issue to {$github}\n§7Error: {$exception->getMessage()}");
$this->getLogger()->critical("\n§cError when deleting world. Submit issue to {$github}\n§7Error: {$exception->getMessage()}");
}

$sender->sendMessage(MultiWorld::getPrefix().LanguageManager::translateMessage("delete-done"));
return false;
default:
if($this->checkPerms($sender, "help")) {
if ($this->checkPerms($sender, "help")) {
$sender->sendMessage(MultiWorld::getPrefix() . LanguageManager::translateMessage("default-usage"));
}
return false;
Expand Down
3 changes: 3 additions & 0 deletions MultiWorld/src/MultiWorld/Util/ConfigManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public function initConfig() {
if(!is_file(self::getDataFolder()."languages/English.yml")) {
MultiWorld::getInstance()->saveResource("languages/English.yml");
}
if(!is_file(self::getDataFolder()."languages/Czech.yml")) {
MultiWorld::getInstance()->saveResource("languages/Czech.yml");
}

// load prefix
self::$prefix = MultiWorld::getInstance()->getConfig()->get("prefix")." §7";
Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ _**Ported MultiWorld to PocketMine-MP**_
- BlueLight

### Phar Download:
- Version 1.3.0 (Stable):
- PocketMine:
- GitHub:
- Poggit:
- GenisysPro:
- GitHub: unavaliable
- Version Latest (Unstable):
- Poggit: https://poggit.pmmp.io/ci/CzechPMDevs/MultiWorld/MultiWorld
- Version 1.3.0 [BETA 3] (Stable):
- Poggit: https://poggit.pmmp.io/ci/CzechPMDevs/MultiWorld/MultiWorld
- Version 1.3.0 [BETA 3] (Unstable):
- Github: https://github.com/CzechPMDevs/MultiWorld/releases/tag/1.3.0-BETA3
- Poggit: https://poggit.pmmp.io/ci/CzechPMDevs/MultiWorld/~/dev:73
- Version 1.3.0 [BETA 2] (Untable):
Expand All @@ -28,6 +34,7 @@ _**Ported MultiWorld to PocketMine-MP**_
### Features:
- MultiLanguage support
- Working on PMMP 3.0.0-ALPHA7
- Commands works in console


### Update log:
Expand Down Expand Up @@ -56,10 +63,7 @@ _**Ported MultiWorld to PocketMine-MP**_
- [ ] Update wiki
- [ ] Release it

### Wiki:

- Commands:
- **/mw create** command
- **/mw teleport** command
- **/mw load|unload** command
- **/mw list** command
### MultiWorld wiki:

- https://github.com/CzechPMDevs/MultiWorld/wiki/MultiWorld-wiki

2 comments on commit e4e556a

@SOF3
Copy link

@SOF3 SOF3 commented on e4e556a Aug 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'd like to remind you that your icon is 512x512 and is too large to be used on Poggit. Your release is still accepted, but the icon isn't being used.

@GamakCZ
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I edit it.

Please sign in to comment.