Removed bad code thats bad from the bad birdy.
Hooked in PersonalServer item click and command. Re-enabled redis transport commands. Added transfer command sending on personal server start. Updated Enjin to handle more versatile inventory purchases.
This commit is contained in:
parent
103ff0e6b0
commit
f00854ee4c
@ -0,0 +1,20 @@
|
||||
package mineplex.core.personalServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public class HostServerCommand extends CommandBase<PersonalServerManager>
|
||||
{
|
||||
public HostServerCommand(PersonalServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.LEGEND, "host");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.hostServer(caller, caller.getName());
|
||||
}
|
||||
}
|
@ -1,21 +1,33 @@
|
||||
package mineplex.core.personalServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.ServerGroup;
|
||||
import mineplex.serverdata.ServerManager;
|
||||
import mineplex.serverdata.ServerRepository;
|
||||
|
||||
public class PersonalServerManager extends MiniPlugin
|
||||
{
|
||||
{
|
||||
private ServerRepository _repository;
|
||||
|
||||
private boolean _us;
|
||||
|
||||
private int _interfaceSlot = 6;
|
||||
private ItemStack _interfaceItem;
|
||||
private boolean _giveInterfaceItem = true;
|
||||
|
||||
public PersonalServerManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
{
|
||||
@ -27,6 +39,32 @@ public class PersonalServerManager extends MiniPlugin
|
||||
|
||||
Region region = _us ? Region.US : Region.EU;
|
||||
_repository = ServerManager.getServerRepository(region);
|
||||
|
||||
_interfaceItem = ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_giveInterfaceItem)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openServer(PlayerInteractEvent event)
|
||||
{
|
||||
if (_interfaceItem.equals(event.getPlayer().getItemInHand()))
|
||||
{
|
||||
hostServer(event.getPlayer(), event.getPlayer().getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddCommands()
|
||||
{
|
||||
addCommand(new HostServerCommand(this));
|
||||
}
|
||||
|
||||
private void setupConfigValues()
|
||||
@ -41,28 +79,17 @@ public class PersonalServerManager extends MiniPlugin
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void testing(PlayerCommandPreprocessEvent event)
|
||||
public void hostServer(Player player, String serverName)
|
||||
{
|
||||
String[] parts = event.getMessage().split(" ");
|
||||
String[] args = new String[parts.length - 1];
|
||||
System.arraycopy(parts, 1, args, 0, parts.length - 1);
|
||||
|
||||
if (event.getMessage().toLowerCase().startsWith("/host"))
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
createGroup(event.getPlayer().getName(), event.getPlayer().getName(), 16, 16, "Smash");
|
||||
}
|
||||
}
|
||||
createGroup(player, serverName, 24, 24, "Smash");
|
||||
}
|
||||
|
||||
private void createGroup(String host, String serverName, int minPlayers, int maxPlayers, String games)
|
||||
private void createGroup(final Player host, final String serverName, int minPlayers, int maxPlayers, String games)
|
||||
{
|
||||
final ServerGroup serverGroup = new ServerGroup(host, serverName, host, 1024, 1, 1, 0, 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
|
||||
final ServerGroup serverGroup = new ServerGroup(serverName, serverName, host.getName(), 1024, 1, 1, 0, 19999, true, "arcade.zip", "Arcade.jar", "plugins/Arcade/", minPlayers, maxPlayers,
|
||||
true, false, false, games, "Player", false, false, true, false, true, true, false, false, false, false, true, true, true, false, false, "", _us ? Region.US : Region.EU);
|
||||
|
||||
GetPlugin().getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
@ -70,6 +97,14 @@ public class PersonalServerManager extends MiniPlugin
|
||||
public void run()
|
||||
{
|
||||
_repository.updateServerGroup(serverGroup);
|
||||
Bukkit.getScheduler().runTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
host.sendMessage(F.main(getName(), serverName + "-1 successfully created. You will be sent to it shortly."));
|
||||
host.sendMessage(F.main(getName(), "If you haven't been connected in 20 seconds, type /server " + serverName + "-1."));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -336,14 +336,45 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
}
|
||||
else if (args.length >= 3 && args[0].equalsIgnoreCase("purchase"))
|
||||
{
|
||||
String packageName = args[2];
|
||||
final int amount = Integer.parseInt(args[2]);
|
||||
final String category = args[3];
|
||||
String tempName = args[4];
|
||||
|
||||
for (int i = 3; i < args.length; i++)
|
||||
for (int i = 5; i < args.length; i++)
|
||||
{
|
||||
packageName += " " + args[i];
|
||||
tempName += " " + args[i];
|
||||
}
|
||||
|
||||
_donationManager.PurchaseUnknownSalesPackage(null, name, playerUUID, packageName, false, 0, false);
|
||||
final String packageName = tempName;
|
||||
|
||||
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
|
||||
{
|
||||
public void run(TransactionResponse data)
|
||||
{
|
||||
if (data == TransactionResponse.Success)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " " + packageName + ".");
|
||||
else
|
||||
{
|
||||
// Add arg so we don't add back to windows api call
|
||||
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + packageName + ". Queuing for run later.");
|
||||
}
|
||||
}
|
||||
}, playerUUID.toString(), category, packageName, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
_commandQueue.add(new QueuedCommand(sender, command, label, args));
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
|
||||
}
|
||||
}
|
||||
}, name, playerUUID, packageName, false, 0, false);
|
||||
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + packageName + ".");
|
||||
}
|
||||
else if (args.length >= 3 && args[0].equalsIgnoreCase("unban"))
|
||||
|
@ -91,7 +91,6 @@ import mineplex.hub.modules.JumpManager;
|
||||
import mineplex.hub.modules.MapManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.PrivateServerManager;
|
||||
import mineplex.hub.modules.TextManager;
|
||||
import mineplex.hub.modules.UHCManager;
|
||||
import mineplex.hub.modules.VisibilityManager;
|
||||
@ -202,8 +201,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
// NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager);
|
||||
// new MailManager(_plugin, notificationManager);
|
||||
|
||||
new PrivateServerManager(_plugin);
|
||||
|
||||
_ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { });
|
||||
BookMeta meta = (BookMeta)_ruleBook.getItemMeta();
|
||||
|
@ -1,22 +0,0 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.hub.modules.PrivateServerManager;
|
||||
|
||||
public class HostServerCommand extends CommandBase<PrivateServerManager>
|
||||
{
|
||||
public HostServerCommand(PrivateServerManager plugin)
|
||||
{
|
||||
super(plugin, Rank.HERO, "hostserver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
// TODO
|
||||
Plugin.hostServer(caller);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package mineplex.hub.modules;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.hub.commands.HostServerCommand;
|
||||
|
||||
public class PrivateServerManager extends MiniPlugin
|
||||
{
|
||||
private int _interfaceSlot = 6;
|
||||
private ItemStack _interfaceItem;
|
||||
private boolean _giveInterfaceItem = true;
|
||||
|
||||
public PrivateServerManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Private Server", plugin);
|
||||
|
||||
_interfaceItem = ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_giveInterfaceItem)
|
||||
{
|
||||
event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openServer(PlayerInteractEvent event)
|
||||
{
|
||||
if (_interfaceItem.equals(event.getPlayer().getItemInHand()))
|
||||
{
|
||||
hostServer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public void hostServer(Player player)
|
||||
{
|
||||
//do stuff????
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddCommands()
|
||||
{
|
||||
addCommand(new HostServerCommand(this));
|
||||
}
|
||||
}
|
@ -44,7 +44,6 @@ public class ServerCommandManager
|
||||
*/
|
||||
private void initialize()
|
||||
{
|
||||
/* CAUSING STUTTER LAG IN HUBS
|
||||
final Jedis jedis = _jedisPool.getResource();
|
||||
|
||||
// Spin up a new thread and subscribe to the Redis pubsub network
|
||||
@ -68,7 +67,6 @@ public class ServerCommandManager
|
||||
});
|
||||
|
||||
thread.start();
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,6 +287,11 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_classShop = new ClassCombatShop(_classShopManager, clientManager, donationManager, false, "Class Shop");
|
||||
|
||||
_eloManager = new EloManager(_plugin, clientManager);
|
||||
|
||||
if (GetHost() != null && !GetHost().isEmpty())
|
||||
{
|
||||
Portal.transferPlayer(GetHost(), _serverStatusManager.getCurrentServerName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user