Merge branch 'master' into MPS-Maps

This commit is contained in:
William Burns 2015-08-03 11:46:38 +01:00
commit 44ee735f4a
11 changed files with 226 additions and 34 deletions

View File

@ -18,7 +18,6 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.Database" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/org-apache-commons-lang.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
</root>
</artifact>

View File

@ -21,33 +21,16 @@
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
<profile default="false" name="Annotation profile for hub" enabled="true">
<profile default="false" name="Annotation profile for bungee" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="hub" />
</profile>
<profile default="false" name="Annotation profile for gameplay" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="gameplay" />
</profile>
<profile default="false" name="Annotation profile for common" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="true" />
<module name="common" />
<module name="bungee" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="1.7">
<module name="common" target="1.7" />
<module name="gameplay" target="1.7" />
<module name="hub" target="1.7" />
<module name="parent" target="1.7" />
<module name="bungee" target="1.7" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">

View File

@ -2,8 +2,8 @@
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="file://$PROJECT_DIR$/ParkerFactions" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ParkerFactions/bungee" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ParkerFactions/common" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ParkerFactions/gameplay" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ParkerFactions/hub" charset="UTF-8" />
</component>
</project>

View File

@ -8,10 +8,12 @@
</component>
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option name="ignoredFiles">
<set>
<option value="$PROJECT_DIR$/ParkerFactions/common/pom.xml" />
<option value="$PROJECT_DIR$/ParkerFactions/gameplay/pom.xml" />
<option value="$PROJECT_DIR$/ParkerFactions/pom.xml" />
</list>
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">

View File

@ -18,10 +18,7 @@
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" filepath="$PROJECT_DIR$/Mineplex.ServerData/Mineplex.ServerData.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" filepath="$PROJECT_DIR$/Mineplex.ServerMonitor/Mineplex.ServerMonitor.iml" group="Core" />
<module fileurl="file://$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" filepath="$PROJECT_DIR$/Nautilus.Game.Arcade/Nautilus.Game.Arcade.iml" group="Game" />
<module fileurl="file://$PROJECT_DIR$/ParkerFactions/common/common.iml" filepath="$PROJECT_DIR$/ParkerFactions/common/common.iml" />
<module fileurl="file://$PROJECT_DIR$/ParkerFactions/gameplay/gameplay.iml" filepath="$PROJECT_DIR$/ParkerFactions/gameplay/gameplay.iml" />
<module fileurl="file://$PROJECT_DIR$/ParkerFactions/hub/hub.iml" filepath="$PROJECT_DIR$/ParkerFactions/hub/hub.iml" />
<module fileurl="file://$PROJECT_DIR$/ParkerFactions/parent.iml" filepath="$PROJECT_DIR$/ParkerFactions/parent.iml" />
<module fileurl="file://$PROJECT_DIR$/ParkerFactions/bungee/bungee.iml" filepath="$PROJECT_DIR$/ParkerFactions/bungee/bungee.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,61 @@
<?php
/**
* Created by PhpStorm.
* User: william
* Date: 14/07/2015
* Time: 09:57
*/
namespace mineplex\plugin\gameengine\game\components\loot;
use mineplex\plugin\gameengine\game\loot\RandomItem;
use mineplex\plugin\util\UtilMath;
use pocketmine\item\Item;
class ChestLoot {
private $randomItems = array();
private $totalLoot;
function __construct()
{
$this->totalLoot = 0;
}
function addItem($id, $chance, $size, $name)
{
$this->addLoot(new RandomItem(new Item($id, 0, 1, $name), $chance, $size, $size));
}
function addItemFull($id, $chance, $min, $max, $name)
{
$this->addLoot(new RandomItem(new Item($id, 0, 1, $name), $chance, $min, $max));
}
function addLoot($ri)
{
array_push($this->randomItems, $ri);
$this->totalLoot += $ri->getChance();
}
function getLoot()
{
$num = UtilMath::random($this->totalLoot);
foreach ($this->randomItems as $ri)
{
if ($ri instanceof RandomItem)
{
$num -= $ri->getChance();
if ($num < 0)
{
return $ri->getItem();
}
}
}
return null;
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* Created by PhpStorm.
* User: william
* Date: 14/07/2015
* Time: 10:01
*/
namespace mineplex\plugin\gameengine\game\loot;
use mineplex\plugin\util\UtilMath;
use pocketmine\item\Item;
class RandomItem {
private $chance;
private $item;
private $min;
private $max;
function __construct(Item $item, $chance, $min, $max)
{
$this->chance = $chance;
$this->item = $item;
$this->min = $min;
$this->max = $max;
}
function getChance()
{
return $this->chance;
}
function getItem()
{
return new Item($this->item->getId(), 0, UtilMath::randBetween($this->min, $this->max), $this->item->getName());
}
}

View File

@ -295,7 +295,7 @@ class WorldComponent implements Listener, BenchTask
//This will return a UID for the game
public function getNewGameId()
{
return rand(0, 999999); //Make this acutally unique
return rand(0, 999999); //Make this actually unique
}
public function isWorldReady()

View File

@ -1,7 +1,7 @@
<?php
/**
* Created by PhpStorm.
* User: Exerosis
* User: WilliamTiger
* Date: 7/14/2015
* Time: 3:26 AM
*/
@ -14,17 +14,22 @@ use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent;
use mineplex\plugin\gameengine\arenas\events\ArenaStartEvent;
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent;
use mineplex\plugin\gameengine\game\components\loot\ChestLoot;
use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent;
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
use mineplex\plugin\util\UtilMath;
use pocketmine\event\HandlerList;
use pocketmine\event\Listener;
use pocketmine\item\Item;
use pocketmine\math\Math;
use pocketmine\Server;
use pocketmine\tile\Chest;
class ChestComponent implements Listener {
private $arena;
private $worldComponent;
private $loot;
//You can put what you want in the constructor, but for chests this is all you should need.
/**
@ -36,7 +41,55 @@ class ChestComponent implements Listener {
$this->arena = $arena;
$this->worldComponent = $worldComponent;
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
//Don't to game start stuff here cause there might be other components not enabled yet
$this->loot = new ChestLoot();
//Food
$this->loot->addItemFull(Item::BAKED_POTATO, 30, 1, 3, "Baked Potato");
$this->loot->addItemFull(Item::COOKED_BEEF, 30, 1, 2, "Steak");
$this->loot->addItemFull(Item::COOKED_CHICKEN, 30, 1, 2, "Cooked Chicken");
$this->loot->addItemFull(Item::CARROT, 30, 1, 3, "Carrot");
$this->loot->addItemFull(Item::MUSHROOM_STEW, 15, 1, 1, "Mushroom Stew");
$this->loot->addItemFull(Item::WHEAT, 30, 1, 6, "Wheat");
$this->loot->addItemFull(Item::APPLE, 30, 1, 4, "Apple");
$this->loot->addItemFull(Item::RAW_PORKCHOP, 30, 1, 4, "Pork");
//Weapons
$this->loot->addItem(Item::WOODEN_AXE, 80, 1, "Wooden Axe");
$this->loot->addItem(Item::WOODEN_SWORD, 70, 1, "Wooden Sword");
$this->loot->addItem(Item::STONE_AXE, 60, 1, "Stone Axe");
$this->loot->addItem(Item::STONE_SWORD, 30, 1, "Stone Sword");
//Leather Armour
$this->loot->addItem(Item::LEATHER_BOOTS, 30, 1, "Leather Boots");
$this->loot->addItem(Item::LEATHER_CAP, 30, 1, "Leather Cap");
$this->loot->addItem(Item::LEATHER_PANTS, 30, 1, "Leather Pants");
$this->loot->addItem(Item::LEATHER_TUNIC, 30, 1, "Leather Boots");
//Gold Armour
$this->loot->addItem(Item::GOLD_CHESTPLATE, 25, 1, "");
$this->loot->addItem(Item::GOLD_LEGGINGS, 25, 1, "");
$this->loot->addItem(Item::GOLD_BOOTS, 25, 1, "");
$this->loot->addItem(Item::GOLD_HELMET, 25, 1, "");
//Chain Armour
$this->loot->addItem(Item::CHAIN_BOOTS, 20, 1, "");
$this->loot->addItem(Item::CHAIN_CHESTPLATE, 20, 1, "");
$this->loot->addItem(Item::CHAIN_LEGGINGS, 20, 1, "");
$this->loot->addItem(Item::CHAIN_HELMET, 20, 1, "");
//Throwable
$this->loot->addItem(Item::BOW, 20, 1, "");
$this->loot->addItemFull(Item::ARROW, 20, 1, 3, "");
$this->loot->addItemFull(Item::SNOWBALL, 30, 1, 2, "");
$this->loot->addItemFull(Item::EGG, 30, 1, 2, "");
//Misc
$this->loot->addItem(Item::COMPASS, 20, 1, "");
$this->loot->addItemFull(Item::STICK, 30, 1, 2, "");
$this->loot->addItem(Item::FLINT, 30, 1, 2, "");
$this->loot->addItem(Item::FEATHER, 30, 1, 2, "");
$this->loot->addItem(Item::GOLD_INGOT, 20, 1, "");
}
function onStart(ArenaStartEvent $event)
@ -52,6 +105,31 @@ class ChestComponent implements Listener {
return;
//Called after the world is loaded
foreach ($this->worldComponent->getData("54") as $loc)
{
$block = $loc->getLevel()->getBlock($loc);
if ($block instanceof Chest)
{
$inv = $block->getInventory();
$items = 2;
if (UtilMath::random(100) > 50)
++$items;
if (UtilMath::random(100) > 65)
++$items;
if (UtilMath::random(100) > 80)
++$items;
if (UtilMath::random(100) > 95)
++$items;
for ($i = 0; $i < $items; $i++)
{
$chosenItem = $this->loot->getLoot();
$inv->setItem(UtilMath::random(27), $chosenItem);
}
}
}
}
function onStateChange(GameStateChangeEvent $event)

View File

@ -0,0 +1,33 @@
<?php
/**
* Created by PhpStorm.
* User: william
* Date: 14/07/2015
* Time: 10:57
*/
namespace mineplex\plugin\util;
class UtilMath {
static function random($num)
{
return rand(0, ($num - 1));
}
static function randInclusive($num)
{
return rand(0, $num);
}
static function randBetween($min, $max)
{
return rand($min, ($max - 1));
}
static function randBetweenInclusive($min, $max)
{
return rand($min, $max);
}
}

View File

@ -1,5 +1,5 @@
#Properties Config file
#Mon Jul 13 05:54:15 ACT 2015
#Tue Jul 14 11:17:25 UTC 2015
motd=Box
server-port=19132
memory-limit=-1