=SubCommand Routine modifications
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"Localized Commands","buildHelp",""
|
||||
"Localized Commands","c++, g++, cplus, cpp",""
|
||||
"Localized Commands","catch",""
|
||||
"Localized Commands","character",""
|
||||
"Localized Commands","charactercreate",""
|
||||
"Localized Commands","charactereditbio",""
|
||||
"Localized Commands","charactereditname",""
|
||||
@@ -39,6 +40,7 @@
|
||||
"Localized Commands","perish, thenperish",""
|
||||
"Localized Commands","ping",""
|
||||
"Localized Commands","poll",""
|
||||
"Localized Commands","raffle",""
|
||||
"Localized Commands","raffleend",""
|
||||
"Localized Commands","rafflejoin",""
|
||||
"Localized Commands","rafflespin",""
|
||||
@@ -263,6 +265,7 @@
|
||||
"Command Enabler","buildhelp","1"
|
||||
"Command Enabler","c++, g++, cplus, cpp","1"
|
||||
"Command Enabler","catch","1"
|
||||
"Command Enabler","character","1"
|
||||
"Command Enabler","charactercreate","1"
|
||||
"Command Enabler","charactereditbio","1"
|
||||
"Command Enabler","charactereditname","1"
|
||||
@@ -294,6 +297,7 @@
|
||||
"Command Enabler","perish, thenperish","1"
|
||||
"Command Enabler","ping","1"
|
||||
"Command Enabler","poll","1"
|
||||
"Command Enabler","raffle","1"
|
||||
"Command Enabler","raffleend","1"
|
||||
"Command Enabler","rafflejoin","1"
|
||||
"Command Enabler","rafflespin","1"
|
||||
|
||||
|
@@ -22,9 +22,6 @@ public class CommandCharacterMain extends Command
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterInfo"); }
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleEnd extends Command
|
||||
{
|
||||
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleEndInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.endRaffle())
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleEndSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleEndFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleJoin extends Command
|
||||
{
|
||||
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleJoinInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.joinRaffle(user))
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleJoinSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleJoinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleSpin extends Command
|
||||
{
|
||||
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleSpinInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleSpinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandRaffleStart extends Command
|
||||
{
|
||||
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("RaffleStartInfo"); }
|
||||
|
||||
public int beanCost;
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
beanCost = Integer.parseInt(input.args);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
beanCost = 100;
|
||||
}
|
||||
|
||||
if(guild.startRaffle(beanCost))
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("RaffleStartFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.Command;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandPollMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandPollMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input.args).Call(res);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package commands.general;
|
||||
package commands.poll;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
@@ -37,4 +37,4 @@ public class CommandPollManage extends Command
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package commands.general;
|
||||
package commands.poll;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.general;
|
||||
package commands.poll;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
@@ -1,4 +1,4 @@
|
||||
package commands.general;
|
||||
package commands.poll;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
@@ -0,0 +1,28 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class CommandRaffleEnd extends SubCommand
|
||||
{
|
||||
public CommandRaffleEnd(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
if(guild.endRaffle())
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleEndSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleEndFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandRaffleJoin extends SubCommand
|
||||
{
|
||||
public CommandRaffleJoin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
if(guild.joinRaffle(user))
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleJoinSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleJoinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.Command;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandRaffleMain extends Command
|
||||
{
|
||||
SubCommandFramework framework = new SubCommandFramework();
|
||||
public CommandRaffleMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("start", new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("spin", new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("end", new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("join", new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
framework.run(guild, channel, user, input.args).Call(res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class CommandRaffleSpin extends SubCommand
|
||||
{
|
||||
public CommandRaffleSpin(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleSpinSuccess"), guild.chooseRaffleWinner().name));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleSpinFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package commands.raffle;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandRaffleStart extends SubCommand
|
||||
{
|
||||
public CommandRaffleStart(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
public int beanCost;
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
beanCost = Integer.parseInt(input);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
beanCost = 100;
|
||||
}
|
||||
|
||||
if(guild.startRaffle(beanCost))
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("RaffleStartSuccess"), beanCost));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("RaffleStartFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,57 @@
|
||||
package core;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import commands.characters.CommandCharacterMain;
|
||||
import commands.general.*;
|
||||
import commands.general.CommandBeansShow;
|
||||
import commands.general.CommandBenchmark;
|
||||
import commands.general.CommandBetBeans;
|
||||
import commands.general.CommandBetHistory;
|
||||
import commands.general.CommandBlurry;
|
||||
import commands.general.CommandBoop;
|
||||
import commands.general.CommandCatch;
|
||||
import commands.general.CommandChangeIndicator;
|
||||
import commands.general.CommandChoose;
|
||||
import commands.general.CommandColiru;
|
||||
import commands.general.CommandColor;
|
||||
import commands.general.CommandCrouton;
|
||||
import commands.general.CommandDBFlush;
|
||||
import commands.general.CommandDBStats;
|
||||
import commands.general.CommandDoWork;
|
||||
import commands.general.CommandEightBall;
|
||||
import commands.general.CommandFetch;
|
||||
import commands.general.CommandGiveBeans;
|
||||
import commands.general.CommandHelp;
|
||||
import commands.general.CommandHelpBuilder;
|
||||
import commands.general.CommandInfo;
|
||||
import commands.general.CommandInvite;
|
||||
import commands.general.CommandJDoodle;
|
||||
import commands.general.CommandLeaderboard;
|
||||
import commands.general.CommandMap;
|
||||
import commands.general.CommandPerish;
|
||||
import commands.general.CommandPing;
|
||||
import commands.general.CommandRPEnd;
|
||||
import commands.general.CommandRPG;
|
||||
import commands.general.CommandRPStart;
|
||||
import commands.general.CommandRating;
|
||||
import commands.general.CommandRemind;
|
||||
import commands.general.CommandRole;
|
||||
import commands.general.CommandRoll;
|
||||
import commands.general.CommandShutdown;
|
||||
import commands.general.CommandStark;
|
||||
import commands.general.CommandStats;
|
||||
import commands.general.CommandTeey;
|
||||
import commands.general.CommandTweet;
|
||||
import commands.general.CommandWolfram;
|
||||
import commands.general.CommandYeet;
|
||||
import commands.guildrole.CommandGuildRoleMain;
|
||||
import commands.poll.CommandPollManage;
|
||||
import commands.poll.CommandPollResults;
|
||||
import commands.poll.CommandPollShow;
|
||||
import commands.poll.CommandPollVote;
|
||||
import commands.raffle.CommandRaffleMain;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
@@ -73,9 +119,6 @@ public class CommandManager
|
||||
this.register(LocCommands.stub("poll"), new CommandPollManage(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("givebeans"), new CommandGiveBeans(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("rpg"), new CommandRPG(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("rafflestart"), new CommandRaffleStart(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("rafflespin"), new CommandRaffleSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("raffleend"), new CommandRaffleEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
|
||||
// General
|
||||
this.register(LocCommands.stub("fetch"), new CommandFetch(KittyRole.General, KittyRating.Safe));
|
||||
@@ -107,12 +150,12 @@ public class CommandManager
|
||||
this.register(LocCommands.stub("bethistory"), new CommandBetHistory(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("crouton"), new CommandCrouton(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("benchmark, bench"), new CommandBenchmark(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("rafflejoin"), new CommandRaffleJoin(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("leaderboard"), new CommandLeaderboard(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("color, colour"), new CommandColor(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("remind"), new CommandRemind(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("role"), new CommandGuildRoleMain(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("character"), new CommandCharacterMain(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("raffle"), new CommandRaffleMain(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
||||
|
||||
@@ -23,6 +23,7 @@ public abstract class SubCommand
|
||||
|
||||
private boolean CanCall(KittyGuild guild, KittyChannel channel, KittyUser user)
|
||||
{
|
||||
System.out.println("TESTING CAN CALL");
|
||||
if(guild.contentRating.getValue() < contentRating.getValue())
|
||||
{
|
||||
Reject(user, "content rating");
|
||||
@@ -42,12 +43,12 @@ public abstract class SubCommand
|
||||
|
||||
// Called by the Command manager - this will run the command
|
||||
// if the issuing user has the permission to do so!
|
||||
protected final void Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
protected final SubCommandFormattable Invoke(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
if(!CanCall(guild, channel, user))
|
||||
return;
|
||||
return null;
|
||||
|
||||
OnRun(guild, channel, user, input);
|
||||
return OnRun(guild, channel, user, input);
|
||||
}
|
||||
|
||||
public KittyRating Rating()
|
||||
|
||||
@@ -27,8 +27,17 @@ public class SubCommandFramework
|
||||
|
||||
public SubCommandFormattable run(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
System.out.print(input);
|
||||
SubCommandFormattable res = commands.get(input.split(" ")[0].toLowerCase()).OnRun(guild, channel, user, input.substring(input.indexOf(" ")));
|
||||
System.out.println(input);
|
||||
SubCommandFormattable res = null;
|
||||
try
|
||||
{
|
||||
res = commands.get(input.split(" ")[0].toLowerCase()).OnRun(guild, channel, user, input.substring(input.indexOf(" ")));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res = commands.get(input.split(" ")[0].toLowerCase()).OnRun(guild, channel, user, "");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user