Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
90ea3d4cff
@ -18,7 +18,6 @@
|
|||||||
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/gson-2.2.1.jar" path-in-jar="/" />
|
<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="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/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="/" />
|
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
|
||||||
</root>
|
</root>
|
||||||
</artifact>
|
</artifact>
|
||||||
|
@ -21,33 +21,15 @@
|
|||||||
<profile default="true" name="Default" enabled="false">
|
<profile default="true" name="Default" enabled="false">
|
||||||
<processorPath useClasspath="true" />
|
<processorPath useClasspath="true" />
|
||||||
</profile>
|
</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" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<processorPath useClasspath="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" />
|
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="1.7">
|
<bytecodeTargetLevel target="1.7">
|
||||||
<module name="common" target="1.7" />
|
<module name="bungee" target="1.7" />
|
||||||
<module name="gameplay" target="1.7" />
|
|
||||||
<module name="hub" target="1.7" />
|
|
||||||
<module name="parent" target="1.7" />
|
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
<component name="JavacSettings">
|
<component name="JavacSettings">
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
|
<component name="IdProvider" IDEtalkID="7E81636CD93857493DFE224533ECF492" />
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="ignoredFiles">
|
||||||
<list>
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/ParkerFactions/common/pom.xml" />
|
||||||
|
<option value="$PROJECT_DIR$/ParkerFactions/gameplay/pom.xml" />
|
||||||
<option value="$PROJECT_DIR$/ParkerFactions/pom.xml" />
|
<option value="$PROJECT_DIR$/ParkerFactions/pom.xml" />
|
||||||
</list>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</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">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" filepath="$PROJECT_DIR$/Mineplex.Game.Clans/Mineplex.Game.Clans.iml" group="Game" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" filepath="$PROJECT_DIR$/Mineplex.Hub/Mineplex.Hub.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" filepath="$PROJECT_DIR$/Mineplex.MapParser/Mineplex.MapParser.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.BungeeSigns/Mineplex.Minecraft.BungeeSigns.iml" group="Bungee" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.ClassCombat/Mineplex.Minecraft.Game.ClassCombat.iml" group="Game" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" filepath="$PROJECT_DIR$/Mineplex.Minecraft.Game.Core/Mineplex.Minecraft.Game.Core.iml" group="Game" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" filepath="$PROJECT_DIR$/Mineplex.PlayerCache/Mineplex.PlayerCache.iml" />
|
||||||
|
@ -7,6 +7,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
@ -78,11 +79,11 @@ public class EventModule extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void setHostDebug(PlayerCommandPreprocessEvent event)
|
public void setHostDebug(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
if (!event.getPlayer().isOp())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!event.getMessage().toLowerCase().startsWith("/sethost "))
|
if (!event.getMessage().toLowerCase().startsWith("/sethost "))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true))
|
||||||
|
return;
|
||||||
|
|
||||||
Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1];
|
Manager.GetServerConfig().HostName = event.getMessage().split(" ")[1];
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ public class ChooseMapButton implements IButton
|
|||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_arcadeManager.GetGameCreationManager().MapPref = _map;
|
_arcadeManager.GetGameCreationManager().MapPref = _map;
|
||||||
|
_arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName();
|
||||||
_arcadeManager.GetGame().setGame(_gameType, player, true);
|
_arcadeManager.GetGame().setGame(_gameType, player, true);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package nautilus.game.arcade.gui.privateServer.button;
|
package nautilus.game.arcade.gui.privateServer.button;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
|
|
||||||
@ -29,6 +32,11 @@ public class WhitelistButton implements IButton
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(Player player, ClickType clickType)
|
public void onClick(Player player, ClickType clickType)
|
||||||
{
|
{
|
||||||
_shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player));
|
List<String> strings = new ArrayList<>();
|
||||||
|
for (String s : _arcadeManager.GetGameHostManager().getWhitelist())
|
||||||
|
{
|
||||||
|
strings.add(s);
|
||||||
|
}
|
||||||
|
_shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player, strings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public class GameVotingPage extends BasePage
|
|||||||
addBackButton(4);
|
addBackButton(4);
|
||||||
addStartVoteButton(0);
|
addStartVoteButton(0);
|
||||||
addEndVoteButton(8);
|
addEndVoteButton(8);
|
||||||
|
addPickHighestButton(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -70,6 +71,49 @@ public class GameVotingPage extends BasePage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addPickHighestButton(int slot)
|
||||||
|
{
|
||||||
|
ShopItem item = new ShopItem(Material.DIAMOND_BLOCK, (byte)0, "§b§lSelect Highest Voted Game", new String[]{"§7Game: §e" + getHighestVoted().GetName()}, 1, false, false);
|
||||||
|
addButton(slot, item, new IButton()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(Player player, ClickType clickType)
|
||||||
|
{
|
||||||
|
if (!_manager.isHost(player)) //Double Check...
|
||||||
|
return;
|
||||||
|
|
||||||
|
_manager.setVoteInProgress(false);
|
||||||
|
getPlugin().GetGame().setGame(getHighestVoted(), player, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private GameType getHighestVoted()
|
||||||
|
{
|
||||||
|
GameType highest = GameType.Skywars;
|
||||||
|
int highestVotes = getVotes(GameType.Skywars);
|
||||||
|
for (GameType cur : _manager.getVotes().values())
|
||||||
|
{
|
||||||
|
if (getVotes(cur) > highestVotes)
|
||||||
|
{
|
||||||
|
highestVotes = getVotes(cur);
|
||||||
|
highest = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return highest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getVotes(GameType type)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for (GameType cur : _manager.getVotes().values())
|
||||||
|
{
|
||||||
|
if (cur.equals(type))
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
private void addCloseButton(int slot)
|
private void addCloseButton(int slot)
|
||||||
{
|
{
|
||||||
ShopItem item = new ShopItem(Material.BED, (byte)0, "§cClose Menu", new String[]{}, 1, false, false);
|
ShopItem item = new ShopItem(Material.BED, (byte)0, "§cClose Menu", new String[]{}, 1, false, false);
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package nautilus.game.arcade.gui.privateServer.page;
|
package nautilus.game.arcade.gui.privateServer.page;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@ -13,9 +17,20 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
|
|||||||
|
|
||||||
public abstract class PlayerPage extends BasePage
|
public abstract class PlayerPage extends BasePage
|
||||||
{
|
{
|
||||||
|
private List<String> _players;
|
||||||
|
private boolean useOtherList;
|
||||||
|
|
||||||
public PlayerPage(ArcadeManager plugin, PrivateServerShop shop, String pageName, Player player)
|
public PlayerPage(ArcadeManager plugin, PrivateServerShop shop, String pageName, Player player)
|
||||||
{
|
{
|
||||||
super(plugin, shop, pageName, player);
|
super(plugin, shop, pageName, player);
|
||||||
|
useOtherList = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerPage(ArcadeManager plugin, PrivateServerShop shop, String pageName, Player player, List<String> players)
|
||||||
|
{
|
||||||
|
super(plugin, shop, pageName, player);
|
||||||
|
useOtherList = true;
|
||||||
|
_players = players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -23,7 +38,20 @@ public abstract class PlayerPage extends BasePage
|
|||||||
{
|
{
|
||||||
addBackButton(4);
|
addBackButton(4);
|
||||||
|
|
||||||
Player[] players = UtilServer.getPlayers();
|
List<Player> players = null;
|
||||||
|
if (useOtherList)
|
||||||
|
{
|
||||||
|
players = new ArrayList<>();
|
||||||
|
for (String s : _players)
|
||||||
|
{
|
||||||
|
players.add(Bukkit.getPlayer(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (Player p : UtilServer.getPlayers())
|
||||||
|
players.add(p);
|
||||||
|
}
|
||||||
|
|
||||||
int slot = 9;
|
int slot = 9;
|
||||||
for (Player player : players)
|
for (Player player : players)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package nautilus.game.arcade.gui.privateServer.page;
|
package nautilus.game.arcade.gui.privateServer.page;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -15,9 +17,9 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
|
|||||||
*/
|
*/
|
||||||
public class WhitelistedPage extends PlayerPage
|
public class WhitelistedPage extends PlayerPage
|
||||||
{
|
{
|
||||||
public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player)
|
public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player, List<String> players)
|
||||||
{
|
{
|
||||||
super(plugin, shop, "Whitelisted Players", player);
|
super(plugin, shop, "Whitelisted Players", player, players);
|
||||||
buildPage();
|
buildPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ public class GameHostManager implements Listener
|
|||||||
if (!getWhitelist().contains(p.getName())){
|
if (!getWhitelist().contains(p.getName())){
|
||||||
if (_host == p)
|
if (_host == p)
|
||||||
return;
|
return;
|
||||||
Manager.GetPortal().sendToHub(p, "You aren't on the whitelist of this Mineplex Private Server.");
|
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,6 +360,20 @@ public class GameHostManager implements Listener
|
|||||||
return _adminList;
|
return _adminList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void getAdmin(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if (!event.getMessage().equalsIgnoreCase("/getadmin"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
giveAdmin(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void broadcastCommand(PlayerCommandPreprocessEvent event)
|
public void broadcastCommand(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -295,7 +295,7 @@ class WorldComponent implements Listener, BenchTask
|
|||||||
//This will return a UID for the game
|
//This will return a UID for the game
|
||||||
public function getNewGameId()
|
public function getNewGameId()
|
||||||
{
|
{
|
||||||
return rand(0, 999999); //Make this acutally unique
|
return rand(0, 999999); //Make this actually unique
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isWorldReady()
|
public function isWorldReady()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: Exerosis
|
* User: WilliamTiger
|
||||||
* Date: 7/14/2015
|
* Date: 7/14/2015
|
||||||
* Time: 3:26 AM
|
* 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\arenas\events\ArenaStartEvent;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent;
|
||||||
use mineplex\plugin\gameengine\game\components\gamestate\GameState;
|
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\event\WorldLoadSuccessEvent;
|
||||||
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
|
use mineplex\plugin\gameengine\game\components\world\WorldComponent;
|
||||||
|
use mineplex\plugin\util\UtilMath;
|
||||||
use pocketmine\event\HandlerList;
|
use pocketmine\event\HandlerList;
|
||||||
use pocketmine\event\Listener;
|
use pocketmine\event\Listener;
|
||||||
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\math\Math;
|
||||||
use pocketmine\Server;
|
use pocketmine\Server;
|
||||||
|
use pocketmine\tile\Chest;
|
||||||
|
|
||||||
class ChestComponent implements Listener {
|
class ChestComponent implements Listener {
|
||||||
|
|
||||||
private $arena;
|
private $arena;
|
||||||
private $worldComponent;
|
private $worldComponent;
|
||||||
|
private $loot;
|
||||||
|
|
||||||
//You can put what you want in the constructor, but for chests this is all you should need.
|
//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->arena = $arena;
|
||||||
$this->worldComponent = $worldComponent;
|
$this->worldComponent = $worldComponent;
|
||||||
Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
|
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)
|
function onStart(ArenaStartEvent $event)
|
||||||
@ -52,6 +105,31 @@ class ChestComponent implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//Called after the world is loaded
|
//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)
|
function onStateChange(GameStateChangeEvent $event)
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#Properties Config file
|
#Properties Config file
|
||||||
#Mon Jul 13 05:54:15 ACT 2015
|
#Tue Jul 14 11:17:25 UTC 2015
|
||||||
motd=Box
|
motd=Box
|
||||||
server-port=19132
|
server-port=19132
|
||||||
memory-limit=-1
|
memory-limit=-1
|
||||||
|
Loading…
Reference in New Issue
Block a user