Added custom command to syntax messages
Added different total types for ridecount Implemented update manager
This commit is contained in:
parent
08ff78c415
commit
584b2e738c
37 changed files with 250 additions and 86 deletions
|
@ -2,8 +2,10 @@ package nl.iobyte.themepark;
|
|||
|
||||
import nl.iobyte.menuapi.MenuAPI;
|
||||
import nl.iobyte.themepark.api.ThemeParkAPI;
|
||||
import nl.iobyte.themepark.api.config.enums.StorageKey;
|
||||
import nl.iobyte.themepark.commands.ThemeParkCommand;
|
||||
import nl.iobyte.themepark.listeners.*;
|
||||
import nl.iobyte.themepark.logger.ThemeParkLogger;
|
||||
import nl.iobyte.themepark.utils.UpdateManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@ -57,7 +59,41 @@ public class ThemePark extends JavaPlugin {
|
|||
}
|
||||
|
||||
private void loadUpdateManager() {
|
||||
//TODO new UpdateManager(this, 48648);
|
||||
if(!api.getConfigurationManager().getBoolean(StorageKey.UPDATE_CHECK_ENABLED))
|
||||
return;
|
||||
|
||||
UpdateManager manager = new UpdateManager(this, 48648);
|
||||
manager.handleResponse((response, version) -> {
|
||||
switch (response) {
|
||||
case LATEST:
|
||||
getLogger().info("You're running the latest version("+version.get()+")");
|
||||
break;
|
||||
case THIS_NEWER:
|
||||
getLogger().info("You're running a newer version("+version.get()+")");
|
||||
break;
|
||||
case UNAVAILABLE:
|
||||
getLogger().info("Unable to check for updates");
|
||||
break;
|
||||
case FOUND_NEW:
|
||||
getLogger().info("Found newer version("+version.get()+")");
|
||||
if(!api.getConfigurationManager().getBoolean(StorageKey.UPDATE_DOWNLOAD_ENABLED))
|
||||
return;
|
||||
|
||||
manager.handleDownloadResponse((downloadResponse, fileName) -> {
|
||||
switch (downloadResponse) {
|
||||
case DONE:
|
||||
getLogger().info("Update downloaded! If you restart your server, it will be loaded. Filename: " + fileName);
|
||||
break;
|
||||
case ERROR:
|
||||
getLogger().severe("Something went wrong when trying downloading the latest version.");
|
||||
break;
|
||||
case UNAVAILABLE:
|
||||
getLogger().warning("Unable to download the latest version.");
|
||||
break;
|
||||
}
|
||||
}).runUpdate();
|
||||
}
|
||||
}).check();
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
|
|
|
@ -4,6 +4,11 @@ public enum StorageKey {
|
|||
|
||||
//General Settings
|
||||
CMD(StorageLocation.SETTINGS, "cmd"),
|
||||
RIDECOUNT_TOTAL_TYPE(StorageLocation.SETTINGS, "ridecount_total_type"),
|
||||
|
||||
//Update Settings
|
||||
UPDATE_CHECK_ENABLED(StorageLocation.SETTINGS, "update.check"),
|
||||
UPDATE_DOWNLOAD_ENABLED(StorageLocation.SETTINGS, "update.download"),
|
||||
|
||||
//Database Settings
|
||||
MYSQL_ENABLED(StorageLocation.SETTINGS, "mysql.enabled"),
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package nl.iobyte.themepark.api.event.ridecount;
|
||||
|
||||
import nl.iobyte.themepark.api.event.objects.ChangeEvent;
|
||||
import nl.iobyte.themepark.api.ridecount.enums.TotalType;
|
||||
|
||||
public class RideCountTotalTypeChangeEvent extends ChangeEvent<TotalType> {
|
||||
|
||||
public RideCountTotalTypeChangeEvent(TotalType old, TotalType current) {
|
||||
super(old, current);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package nl.iobyte.themepark.api.ridecount;
|
||||
|
||||
import nl.iobyte.themepark.ThemePark;
|
||||
import nl.iobyte.themepark.api.event.ridecount.RideCountTotalTypeChangeEvent;
|
||||
import nl.iobyte.themepark.api.ridecount.enums.TotalType;
|
||||
import nl.iobyte.themepark.api.ridecount.objects.AttractionCount;
|
||||
import nl.iobyte.themepark.api.ridecount.objects.RideCount;
|
||||
import nl.iobyte.themepark.api.ridecount.objects.TopData;
|
||||
|
@ -13,6 +15,22 @@ public class RideCountService {
|
|||
private final Map<String, AttractionCount> counts = new ConcurrentHashMap<>();
|
||||
private final TopData topData = new TopData();
|
||||
private boolean changed = false;
|
||||
private TotalType type = TotalType.DAILY;
|
||||
|
||||
public TotalType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(TotalType type) {
|
||||
if(this.type == type)
|
||||
return;
|
||||
|
||||
TotalType old = this.type;
|
||||
this.type = type;
|
||||
ThemePark.getInstance().getAPI().getEventDispatcher().call(
|
||||
new RideCountTotalTypeChangeEvent(old, type)
|
||||
);
|
||||
}
|
||||
|
||||
public AttractionCount getCount(String id) {
|
||||
if(id == null || id.isEmpty())
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package nl.iobyte.themepark.api.ridecount.enums;
|
||||
|
||||
public enum TotalType {
|
||||
|
||||
DAILY,
|
||||
WEEKLY,
|
||||
MONTHLY,
|
||||
YEARLY,
|
||||
TOTAL
|
||||
|
||||
}
|
|
@ -16,7 +16,6 @@ import nl.iobyte.themepark.commands.subcommands.ridecount.RideCountCommands;
|
|||
import nl.iobyte.themepark.commands.subcommands.status.StatusCommands;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -30,10 +29,10 @@ public class ThemeParkCommand {
|
|||
|
||||
CommandFactory factory = new CommandFactory(cmd);
|
||||
factory.addSubCommand(new HelpCommand(factory))
|
||||
.addSubCommand(new MenuCommand());
|
||||
.addSubCommand(new MenuCommand(factory.getName()));
|
||||
|
||||
//Admin
|
||||
factory.addSubCommand(new ItemCommand());
|
||||
factory.addSubCommand(new ItemCommand(factory.getName()));
|
||||
|
||||
//Region
|
||||
RegionCommands.load(factory);
|
||||
|
|
|
@ -15,8 +15,8 @@ public class HelpCommand extends SubCommand {
|
|||
super(new String[]{"help"});
|
||||
|
||||
this.factory = factory;
|
||||
addSyntax("/themepark help");
|
||||
addSyntax("/themepark help <page>")
|
||||
addSyntax("/"+factory.getName()+" help");
|
||||
addSyntax("/"+factory.getName()+" help <page>")
|
||||
.addArgument(new IntegerArgument());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import java.util.List;
|
|||
|
||||
public class ItemCommand extends SubCommand {
|
||||
|
||||
public ItemCommand() {
|
||||
public ItemCommand(String cmd) {
|
||||
super("themepark.admin", "item");
|
||||
|
||||
addSyntax("/themepark item")
|
||||
addSyntax("/"+cmd+" item")
|
||||
.setAllowConsole(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,13 @@ import java.util.List;
|
|||
|
||||
public class MenuCommand extends SubCommand {
|
||||
|
||||
public MenuCommand() {
|
||||
public MenuCommand(String cmd) {
|
||||
super(new String[]{"menu"});
|
||||
|
||||
addSyntax("/themepark menu")
|
||||
addSyntax("/"+cmd+" menu")
|
||||
.setAllowConsole(false);
|
||||
|
||||
addSyntax("/themepark menu")
|
||||
addSyntax("/"+cmd+" menu status")
|
||||
.addArgument(new StringArgument("status"))
|
||||
.setAllowConsole(false);
|
||||
}
|
||||
|
|
|
@ -5,15 +5,15 @@ import nl.iobyte.commandapi.CommandFactory;
|
|||
public class AttractionCommands {
|
||||
|
||||
public static void load(CommandFactory factory) {
|
||||
factory.addSubCommand(new AttractionListCommand())
|
||||
.addSubCommand(new AttractionWarpCommand())
|
||||
.addSubCommand(new AttractionCreateCommand())
|
||||
.addSubCommand(new AttractionRegionCommand())
|
||||
.addSubCommand(new AttractionNameCommand())
|
||||
.addSubCommand(new AttractionCoverCommand())
|
||||
.addSubCommand(new AttractionStatusCommand())
|
||||
.addSubCommand(new AttractionLocationCommand())
|
||||
.addSubCommand(new AttractionRemoveCommand());
|
||||
factory.addSubCommand(new AttractionListCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionWarpCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionCreateCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionRegionCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionNameCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionCoverCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionStatusCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionLocationCommand(factory.getName()))
|
||||
.addSubCommand(new AttractionRemoveCommand(factory.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionCoverCommand extends SubCommand {
|
||||
|
||||
public AttractionCoverCommand() {
|
||||
public AttractionCoverCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "cover");
|
||||
|
||||
addSyntax("/themepark attraction cover <id> <url>")
|
||||
addSyntax("/"+cmd+" attraction cover <id> <url>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new StringArgument());
|
||||
}
|
||||
|
|
|
@ -18,21 +18,21 @@ import java.util.List;
|
|||
|
||||
public class AttractionCreateCommand extends SubCommand {
|
||||
|
||||
public AttractionCreateCommand() {
|
||||
public AttractionCreateCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "create");
|
||||
|
||||
addSyntax("/themepark attraction create <id> <region_id> <name>")
|
||||
addSyntax("/"+cmd+" attraction create <id> <region_id> <name>")
|
||||
.addArgument(new NoAttractionArgument())
|
||||
.addArgument(new RegionArgument())
|
||||
.addArgument(new MessageArgument());
|
||||
|
||||
addSyntax("/themepark attraction create <id> <region_id> <name> <status>")
|
||||
addSyntax("/"+cmd+" attraction create <id> <region_id> <name> <status>")
|
||||
.addArgument(new NoAttractionArgument())
|
||||
.addArgument(new RegionArgument())
|
||||
.addArgument(new MessageArgument())
|
||||
.addArgument(new EnumArgument(Status.values()));
|
||||
|
||||
addSyntax("/themepark attraction create <id> <region_id> <name> <status> <url>")
|
||||
addSyntax("/"+cmd+" attraction create <id> <region_id> <name> <status> <url>")
|
||||
.addArgument(new NoAttractionArgument())
|
||||
.addArgument(new RegionArgument())
|
||||
.addArgument(new MessageArgument())
|
||||
|
|
|
@ -14,18 +14,18 @@ import java.util.List;
|
|||
|
||||
public class AttractionListCommand extends SubCommand {
|
||||
|
||||
public AttractionListCommand() {
|
||||
public AttractionListCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "list");
|
||||
|
||||
addSyntax("/themepark attraction list");
|
||||
addSyntax("/"+cmd+" attraction list");
|
||||
|
||||
addSyntax("/themepark attraction list <page>")
|
||||
addSyntax("/"+cmd+" attraction list <page>")
|
||||
.addArgument(new IntegerArgument());
|
||||
|
||||
addSyntax("/themepark attraction list <region>")
|
||||
addSyntax("/"+cmd+" attraction list <region>")
|
||||
.addArgument(new RegionArgument());
|
||||
|
||||
addSyntax("/themepark attraction list <region> <page>")
|
||||
addSyntax("/"+cmd+" attraction list <region> <page>")
|
||||
.addArgument(new RegionArgument())
|
||||
.addArgument(new IntegerArgument());
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionLocationCommand extends SubCommand {
|
||||
|
||||
public AttractionLocationCommand() {
|
||||
public AttractionLocationCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "location");
|
||||
|
||||
addSyntax("/themepark attraction location <id>")
|
||||
addSyntax("/"+cmd+" attraction location <id>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.setAllowConsole(false);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionNameCommand extends SubCommand {
|
||||
|
||||
public AttractionNameCommand() {
|
||||
public AttractionNameCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "name");
|
||||
|
||||
addSyntax("/themepark attraction name <id> <name>")
|
||||
addSyntax("/"+cmd+" attraction name <id> <name>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new MessageArgument());
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionRegionCommand extends SubCommand {
|
||||
|
||||
public AttractionRegionCommand() {
|
||||
public AttractionRegionCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "region");
|
||||
|
||||
addSyntax("/themepark attraction region <attraction_id> <region_id>")
|
||||
addSyntax("/"+cmd+" attraction region <attraction_id> <region_id>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new RegionArgument());
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionRemoveCommand extends SubCommand {
|
||||
|
||||
public AttractionRemoveCommand() {
|
||||
public AttractionRemoveCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "remove");
|
||||
|
||||
addSyntax("/themepark attraction remove <id>")
|
||||
addSyntax("/"+cmd+" attraction remove <id>")
|
||||
.addArgument(new AttractionArgument());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionStatusCommand extends SubCommand {
|
||||
|
||||
public AttractionStatusCommand() {
|
||||
public AttractionStatusCommand(String cmd) {
|
||||
super("themepark.admin", "attraction", "status");
|
||||
|
||||
addSyntax("/themepark attraction status <id> <status>")
|
||||
addSyntax("/"+cmd+" attraction status <id> <status>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new EnumArgument(Status.values()));
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.util.List;
|
|||
|
||||
public class AttractionWarpCommand extends SubCommand {
|
||||
|
||||
public AttractionWarpCommand() {
|
||||
public AttractionWarpCommand(String cmd) {
|
||||
super(new String[]{"attraction", "warp"});
|
||||
|
||||
addSyntax("/themepark attraction warp <id>")
|
||||
addSyntax("/"+cmd+" attraction warp <id>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.setAllowConsole(false);
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ import nl.iobyte.commandapi.CommandFactory;
|
|||
public class RegionCommands {
|
||||
|
||||
public static void load(CommandFactory factory) {
|
||||
factory.addSubCommand(new RegionListCommand())
|
||||
.addSubCommand(new RegionCreateCommand())
|
||||
.addSubCommand(new RegionNameCommand())
|
||||
.addSubCommand(new RegionRemoveCommand());
|
||||
factory.addSubCommand(new RegionListCommand(factory.getName()))
|
||||
.addSubCommand(new RegionCreateCommand(factory.getName()))
|
||||
.addSubCommand(new RegionNameCommand(factory.getName()))
|
||||
.addSubCommand(new RegionRemoveCommand(factory.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.util.List;
|
|||
|
||||
public class RegionCreateCommand extends SubCommand {
|
||||
|
||||
public RegionCreateCommand() {
|
||||
public RegionCreateCommand(String cmd) {
|
||||
super("themepark.admin", "region", "create");
|
||||
|
||||
addSyntax("/themepark region create <id> <name>")
|
||||
addSyntax("/"+cmd+" region create <id> <name>")
|
||||
.addArgument(new NoRegionArgument())
|
||||
.addArgument(new MessageArgument());
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ import java.util.List;
|
|||
|
||||
public class RegionListCommand extends SubCommand {
|
||||
|
||||
public RegionListCommand() {
|
||||
public RegionListCommand(String cmd) {
|
||||
super("themepark.admin", "region", "list");
|
||||
|
||||
addSyntax("/themepark region list");
|
||||
addSyntax("/"+cmd+" region list");
|
||||
|
||||
addSyntax("/themepark region list <page>")
|
||||
addSyntax("/"+cmd+" region list <page>")
|
||||
.addArgument(new IntegerArgument());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class RegionNameCommand extends SubCommand {
|
||||
|
||||
public RegionNameCommand() {
|
||||
public RegionNameCommand(String cmd) {
|
||||
super("themepark.admin", "region", "name");
|
||||
|
||||
addSyntax("/themepark region name <id> <name>")
|
||||
addSyntax("/"+cmd+" region name <id> <name>")
|
||||
.addArgument(new RegionArgument())
|
||||
.addArgument(new MessageArgument());
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
|||
|
||||
public class RegionRemoveCommand extends SubCommand {
|
||||
|
||||
public RegionRemoveCommand() {
|
||||
public RegionRemoveCommand(String cmd) {
|
||||
super("themepark.admin", "region", "remove");
|
||||
|
||||
addSyntax("/themepark region remove <id>")
|
||||
addSyntax("/"+cmd+" region remove <id>")
|
||||
.addArgument(new RegionArgument());
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ import java.util.List;
|
|||
|
||||
public class RideCountAddCommand extends SubCommand {
|
||||
|
||||
public RideCountAddCommand() {
|
||||
public RideCountAddCommand(String cmd) {
|
||||
super("themepark.admin", "ridecount", "add");
|
||||
|
||||
addSyntax("/themepark ridecount add <attraction> <selector> <amount>")
|
||||
addSyntax("/"+cmd+" ridecount add <attraction> <selector> <amount>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new PlayersArgument())
|
||||
.addArgument(new IntegerArgument());
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package nl.iobyte.themepark.commands.subcommands.ridecount;
|
||||
|
||||
import nl.iobyte.commandapi.arguments.EnumArgument;
|
||||
import nl.iobyte.commandapi.interfaces.ICommandExecutor;
|
||||
import nl.iobyte.commandapi.objects.SubCommand;
|
||||
import nl.iobyte.themepark.ThemePark;
|
||||
import nl.iobyte.themepark.api.message.Text;
|
||||
import nl.iobyte.themepark.api.ridecount.enums.TotalType;
|
||||
import java.util.List;
|
||||
|
||||
public class RideCountChangeTotalTypeCommand extends SubCommand {
|
||||
|
||||
public RideCountChangeTotalTypeCommand(String cmd) {
|
||||
super("themepark.admin", "ridecount", "total_type");
|
||||
|
||||
addSyntax("/"+cmd+" ridecount total_type <type>")
|
||||
.addArgument(new EnumArgument(TotalType.values()));
|
||||
}
|
||||
|
||||
|
||||
public void onCommand(ICommandExecutor sender, List<Object> list, int i) {
|
||||
TotalType type = (TotalType) list.get(0);
|
||||
|
||||
ThemePark.getInstance().getAPI().getRideCountService().setType(type);
|
||||
sender.sendMessage(Text.color("&6&lThemeParkMC &f➢ Changed total type for ridecount to: &f"+type.toString()));
|
||||
}
|
||||
|
||||
}
|
|
@ -5,8 +5,9 @@ import nl.iobyte.commandapi.CommandFactory;
|
|||
public class RideCountCommands {
|
||||
|
||||
public static void load(CommandFactory factory) {
|
||||
factory.addSubCommand(new RideCountGetCommand())
|
||||
.addSubCommand(new RideCountAddCommand());
|
||||
factory.addSubCommand(new RideCountGetCommand(factory.getName()))
|
||||
.addSubCommand(new RideCountAddCommand(factory.getName()))
|
||||
.addSubCommand(new RideCountChangeTotalTypeCommand(factory.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ import java.util.List;
|
|||
|
||||
public class RideCountGetCommand extends SubCommand {
|
||||
|
||||
public RideCountGetCommand() {
|
||||
public RideCountGetCommand(String cmd) {
|
||||
super("themepark.admin", "ridecount", "get");
|
||||
|
||||
addSyntax("/themepark ridecount get <attraction> <player>")
|
||||
addSyntax("/"+cmd+" ridecount get <attraction> <player>")
|
||||
.addArgument(new AttractionArgument())
|
||||
.addArgument(new PlayerArgument());
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
|
||||
public class StatusColorCommand extends SubCommand {
|
||||
|
||||
public StatusColorCommand() {
|
||||
public StatusColorCommand(String cmd) {
|
||||
super("themepark.admin", "status", "color");
|
||||
|
||||
addSyntax("/themepark status color <id> <color>")
|
||||
addSyntax("/"+cmd+" status color <id> <color>")
|
||||
.addArgument(new EnumArgument(Status.values()))
|
||||
.addArgument(new StringArgument());
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import nl.iobyte.commandapi.CommandFactory;
|
|||
public class StatusCommands {
|
||||
|
||||
public static void load(CommandFactory factory) {
|
||||
factory.addSubCommand(new StatusNameCommand())
|
||||
.addSubCommand(new StatusColorCommand())
|
||||
.addSubCommand(new StatusHexColorCommand())
|
||||
.addSubCommand(new StatusMaterialCommand())
|
||||
.addSubCommand(new StatusTeleportCommand());
|
||||
factory.addSubCommand(new StatusNameCommand(factory.getName()))
|
||||
.addSubCommand(new StatusColorCommand(factory.getName()))
|
||||
.addSubCommand(new StatusHexColorCommand(factory.getName()))
|
||||
.addSubCommand(new StatusMaterialCommand(factory.getName()))
|
||||
.addSubCommand(new StatusTeleportCommand(factory.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ import java.util.List;
|
|||
|
||||
public class StatusHexColorCommand extends SubCommand {
|
||||
|
||||
public StatusHexColorCommand() {
|
||||
public StatusHexColorCommand(String cmd) {
|
||||
super("themepark.admin", "status", "hex_color");
|
||||
|
||||
addSyntax("/themepark status hex_color <id> <color>")
|
||||
addSyntax("/"+cmd+" status hex_color <id> <color>")
|
||||
.addArgument(new EnumArgument(Status.values()))
|
||||
.addArgument(new StringArgument());
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
|
||||
public class StatusMaterialCommand extends SubCommand {
|
||||
|
||||
public StatusMaterialCommand() {
|
||||
public StatusMaterialCommand(String cmd) {
|
||||
super("themepark.admin", "status", "material");
|
||||
|
||||
addSyntax("/themepark status material <status> <material>")
|
||||
addSyntax("/"+cmd+" status material <status> <material>")
|
||||
.addArgument(new EnumArgument(Status.values()))
|
||||
.addArgument(new MaterialArgument());
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
|
||||
public class StatusNameCommand extends SubCommand {
|
||||
|
||||
public StatusNameCommand() {
|
||||
public StatusNameCommand(String cmd) {
|
||||
super("themepark.admin", "status", "name");
|
||||
|
||||
addSyntax("/themepark status name <id> <name>")
|
||||
addSyntax("/"+cmd+" status name <id> <name>")
|
||||
.addArgument(new EnumArgument(Status.values()))
|
||||
.addArgument(new MessageArgument());
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
|||
|
||||
public class StatusTeleportCommand extends SubCommand {
|
||||
|
||||
public StatusTeleportCommand() {
|
||||
public StatusTeleportCommand(String cmd) {
|
||||
super("themepark.admin", "status", "teleport");
|
||||
|
||||
addSyntax("/themepark status teleport <id> <teleport>")
|
||||
addSyntax("/"+cmd+" status teleport <id> <teleport>")
|
||||
.addArgument(new EnumArgument(Status.values()))
|
||||
.addArgument(new BooleanArgument());
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import nl.iobyte.themepark.api.ThemeParkAPI;
|
|||
import nl.iobyte.themepark.api.config.ConfigurationManager;
|
||||
import nl.iobyte.themepark.api.config.enums.StorageKey;
|
||||
import nl.iobyte.themepark.api.message.Text;
|
||||
import nl.iobyte.themepark.api.ridecount.enums.TotalType;
|
||||
import nl.iobyte.themepark.scheduler.ThemeParkScheduler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -32,17 +33,58 @@ public class PlayerListener implements Listener {
|
|||
doItem(player);
|
||||
|
||||
//Load RideCount data
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(new Date());
|
||||
TotalType type = api.getRideCountService().getType();
|
||||
String query;
|
||||
Map<Integer, Object> parameters;
|
||||
if(type == TotalType.TOTAL) {
|
||||
query = "SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=?";
|
||||
parameters = new HashMap<>(){{
|
||||
put(1, player.getUniqueId().toString());
|
||||
}};
|
||||
} else {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(new Date());
|
||||
switch (type) {
|
||||
case DAILY:
|
||||
query = "SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id AND t1.year=t2.year AND t1.day=t2.day GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=? AND year=? AND day=?";
|
||||
parameters = new HashMap<>() {{
|
||||
put(1, player.getUniqueId().toString());
|
||||
put(2, calendar.get(Calendar.YEAR));
|
||||
put(3, calendar.get(Calendar.DAY_OF_YEAR));
|
||||
}};
|
||||
break;
|
||||
case WEEKLY:
|
||||
query = "SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id AND t1.year=t2.year AND t1.week=t2.week GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=? AND year=? AND week=?";
|
||||
parameters = new HashMap<>() {{
|
||||
put(1, player.getUniqueId().toString());
|
||||
put(2, calendar.get(Calendar.YEAR));
|
||||
put(3, calendar.get(Calendar.WEEK_OF_YEAR));
|
||||
}};
|
||||
break;
|
||||
case MONTHLY:
|
||||
query = "SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id AND t1.year=t2.year AND t1.month=t2.month GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=? AND year=? AND month=?";
|
||||
parameters = new HashMap<>() {{
|
||||
put(1, player.getUniqueId().toString());
|
||||
put(2, calendar.get(Calendar.YEAR));
|
||||
put(3, calendar.get(Calendar.MONTH));
|
||||
}};
|
||||
break;
|
||||
case YEARLY:
|
||||
query = "SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id AND t1.year=t2.year GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=? AND year=?";
|
||||
parameters = new HashMap<>() {{
|
||||
put(1, player.getUniqueId().toString());
|
||||
put(2, calendar.get(Calendar.YEAR));
|
||||
}};
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
api.getDatabaseService().executeQueryAsync(
|
||||
"local",
|
||||
"SELECT count, attraction_id, (SELECT sum(count) FROM counts AS t1 WHERE t1.uuid=t2.uuid AND t1.attraction_id=t2.attraction_id AND t1.year=t2.year AND t1.month=? GROUP BY t1.uuid) AS total_count FROM counts AS t2 WHERE uuid=? AND year=? AND day=?",
|
||||
new HashMap<>() {{
|
||||
put(1, calendar.get(Calendar.MONTH));
|
||||
put(2, player.getUniqueId().toString());
|
||||
put(3, calendar.get(Calendar.YEAR));
|
||||
put(4, calendar.get(Calendar.DAY_OF_YEAR));
|
||||
}}
|
||||
query,
|
||||
parameters
|
||||
).setWhenSuccessful(result -> {
|
||||
if(result != null)
|
||||
for(Map<String, Object> row : result)
|
||||
|
|
|
@ -2,8 +2,10 @@ package nl.iobyte.themepark.listeners;
|
|||
|
||||
import nl.iobyte.themepark.ThemePark;
|
||||
import nl.iobyte.themepark.api.attraction.objects.Attraction;
|
||||
import nl.iobyte.themepark.api.config.enums.StorageKey;
|
||||
import nl.iobyte.themepark.api.database.objects.types.SQLiteDatabase;
|
||||
import nl.iobyte.themepark.api.event.ridecount.RideCountAddEvent;
|
||||
import nl.iobyte.themepark.api.event.ridecount.RideCountTotalTypeChangeEvent;
|
||||
import nl.iobyte.themepark.api.message.MessageKey;
|
||||
import nl.iobyte.themepark.api.message.Text;
|
||||
import nl.iobyte.themepark.api.ridecount.objects.RideCount;
|
||||
|
@ -89,4 +91,9 @@ public class RideCountListener implements Listener {
|
|||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChance(RideCountTotalTypeChangeEvent e) {
|
||||
ThemePark.getInstance().getAPI().getConfigurationManager().set(StorageKey.RIDECOUNT_TOTAL_TYPE, e.getCurrent());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
version: 1.2
|
||||
|
||||
cmd: "themepark"
|
||||
ridecount_total_type: MONTHLY
|
||||
|
||||
update:
|
||||
check: true
|
||||
download: true
|
||||
|
||||
mysql:
|
||||
enabled: false
|
||||
|
|
Reference in a new issue