Merge branch 'develop'
This commit is contained in:
+7
-3
@@ -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",""
|
||||
@@ -183,7 +185,7 @@
|
||||
"Localized Strings","LeaderboardInfo","Shows you the 10 users with the most beans on the server"
|
||||
"Localized Strings","LeaderboardTitle","Server Leaderboard"
|
||||
"Localized Strings","MapHeight",""
|
||||
"Localized Strings","MapInfo","Generates a map! You can pass additional information if you want with the flags `-s<seed>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.nn**Defaults**nDefault Seed: Random,nDefault Width: 35(max %s),nDefault Height: 25(max %s)nn**Key**nLand: ~nMountain: ▲nBeach: "
|
||||
"Localized Strings","MapInfo","Generates a map! You can pass additional information if you want with the flags `-s<seed>`. If one of the fields isn't provided, its default will be used. Note that adjusting the width and height impacts the map outcomes.\n\n**Defaults**\nDefault Seed: Random,\nDefault Width: 35(max %s),\nDefault Height: 25(max %s)\n\n**Key**\nLand: ~\nMountain: \u25B2\nBeach: =\nTrees: \u00A5\nVolcano: #"
|
||||
"Localized Strings","MapInvalid","Invalid arguments provided!"
|
||||
"Localized Strings","MapSeed","Seed"
|
||||
"Localized Strings","MapVersion","Using mapgen v0.1"
|
||||
@@ -193,11 +195,11 @@
|
||||
"Localized Strings","PingResponse","Pong!"
|
||||
"Localized Strings","PollManageInfo","'start' will start a new poll with the query of the line you put after, 'choice' will add a choice to the poll, 'stop' will end the poll"
|
||||
"Localized Strings","PollResultsInfo","Will show current results of a poll and percentages of votes per choice"
|
||||
"Localized Strings","PollResultsResponse","%s people voted for %s `%s` with `%s%` !n"
|
||||
"Localized Strings","PollResultsResponse","%s people voted for `%s` with `%s%%` "
|
||||
"Localized Strings","PollShowChoices","And the choices are:n"
|
||||
"Localized Strings","PollShowInfo","Will show the current poll running"
|
||||
"Localized Strings","PollShowNoPoll","There is no poll running!"
|
||||
"Localized Strings","PollShowPoll","The current poll is `%s`n"
|
||||
"Localized Strings","PollShowPoll","The current poll is `%s`"
|
||||
"Localized Strings","PollVoteAlreadyVoted","You already voted"
|
||||
"Localized Strings","PollVoteInfo","Vote in a poll with the choice number, won't work if no poll is running, you can't change your vote once you have cast it! Be careful!"
|
||||
"Localized Strings","PollVoteNoPoll","There is no poll running!"
|
||||
@@ -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"
|
||||
|
||||
|
@@ -8,6 +8,7 @@ function plugin(message, user)
|
||||
hours = ((timedif / (60*60)) % 24);
|
||||
mins = ((timedif / (60)) % 60);
|
||||
secs = timedif % 60;
|
||||
|
||||
return "*GASP!!!* \n" .. user.name .. " said **THE** word! It's been " .. round(days) .. " days, " .. round(hours) .. " hours, " .. round(mins) .. " minutes, and " .. round(secs) .. " seconds since the last time!";
|
||||
end
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterEditBio extends Command
|
||||
{
|
||||
public CommandCharacterEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditBioInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditBioNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editBio(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.send(LocStrings.stub("CharacterEditBioSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditBioNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterEditName extends Command
|
||||
{
|
||||
public CommandCharacterEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditNameInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditNameNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editName(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.send(LocStrings.stub("CharacterEditNameSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditNameNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterEditURL extends Command
|
||||
{
|
||||
public CommandCharacterEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterEditURLInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.args.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditURLNotValid"));
|
||||
return;
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.args.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editRefImage(character, input.args.substring(input.args.indexOf(' ')));
|
||||
res.send(LocStrings.stub("CharacterEditURLSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterEditURLNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
package commands.characters;
|
||||
|
||||
import commands.guildrole.*;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import core.SubCommandFramework;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterMain extends Command
|
||||
{
|
||||
@@ -17,14 +12,16 @@ public class CommandCharacterMain extends Command
|
||||
public CommandCharacterMain(KittyRole level, KittyRating rating)
|
||||
{
|
||||
super(level, rating);
|
||||
framework.addCommand("add", new SubCommandAdd(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("editbio", new SubCommandEditBio(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("editname", new SubCommandEditName(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("editurl", new SubCommandEditURL(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("search", new SubCommandSearch(KittyRole.General, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterInfo"); }
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package commands.characters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.Command;
|
||||
import core.LocStrings;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterSearch extends Command
|
||||
{
|
||||
public CommandCharacterSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("CharacterSearchInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input.args);
|
||||
if(characters.size() < 1)
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||
return;
|
||||
}
|
||||
if(characters.size() > 1)
|
||||
{
|
||||
res.send(LocStrings.stub("CharacterSearchMultipleCharacterHeader"));
|
||||
for(KittyCharacter character:characters)
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("CharacterSearchMultipleCharacter"), character.getName(), character.getOwner().name, character.getUID()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("CharacterSearchOneCharacter"), characters.get(0).getOwner().name, characters.get(0).getName(), characters.get(0).getBio(), characters.get(0).getRefImage(), characters.get(0).getUID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -6,9 +6,9 @@ import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandCharacterCreate extends SubCommand
|
||||
public class SubCommandCreate extends SubCommand
|
||||
{
|
||||
public CommandCharacterCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
public SubCommandCreate(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
@@ -0,0 +1,40 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyCharacter;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandEditBio extends SubCommand
|
||||
{
|
||||
public SubCommandEditBio(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editBio(character, input.substring(input.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditBioNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyCharacter;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandEditName extends SubCommand
|
||||
{
|
||||
public SubCommandEditName(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editName(character, input.substring(input.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditNameNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package commands.characters;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyCharacter;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandEditURL extends SubCommand
|
||||
{
|
||||
public SubCommandEditURL(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
try
|
||||
{
|
||||
Long.parseLong(input.split(" ")[0]);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLNotValid"));
|
||||
}
|
||||
KittyCharacter character = CharacterManager.instance.searchCharacter(input.split(" ")[0]).get(0);
|
||||
if(character.getOwner().equals(user))
|
||||
{
|
||||
CharacterManager.instance.editRefImage(character, input.substring(input.indexOf(' ')));
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterEditURLNotAuth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package commands.characters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.CharacterManager;
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyCharacter;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandSearch extends SubCommand
|
||||
{
|
||||
public SubCommandSearch(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
ArrayList <KittyCharacter> characters = CharacterManager.instance.searchCharacter(input);
|
||||
if(characters.size() < 1)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("CharacterSearchNoCharacterFound"));
|
||||
}
|
||||
String formatted = "";
|
||||
if(characters.size() > 1)
|
||||
{
|
||||
formatted += (LocStrings.stub("CharacterSearchMultipleCharacterHeader"));
|
||||
for(KittyCharacter character:characters)
|
||||
{
|
||||
formatted += "\n" + (String.format(LocStrings.stub("CharacterSearchMultipleCharacter"), character.getName(), character.getOwner().name, character.getUID()));
|
||||
}
|
||||
return new SubCommandFormattable(formatted);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("CharacterSearchOneCharacter"), characters.get(0).getOwner().name, characters.get(0).getName(), characters.get(0).getBio(), characters.get(0).getRefImage(), characters.get(0).getUID()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
import dataStructures.Response;
|
||||
import dataStructures.UserInput;
|
||||
|
||||
public class CommandPollManage extends Command
|
||||
{
|
||||
public CommandPollManage(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollManageInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
switch(input.args.split(" ")[0].toLowerCase())
|
||||
{
|
||||
case "start":
|
||||
res.send(guild.startPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "choice":
|
||||
res.send(guild.addChoiceToPoll(input.args.substring(input.args.indexOf(' ')).trim()));
|
||||
break;
|
||||
|
||||
case "stop":
|
||||
res.send(guild.endPoll());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollShow extends Command
|
||||
{
|
||||
public CommandPollShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollShowInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(!guild.polling)
|
||||
{
|
||||
res.send(LocStrings.stub("PollShowNoPoll"));
|
||||
return;
|
||||
}
|
||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.stub("PollShowChoices");
|
||||
for(int i = 0; i < guild.choices.size(); i++)
|
||||
{
|
||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||
}
|
||||
|
||||
res.send(poll);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package commands.general;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollVote extends Command
|
||||
{
|
||||
public CommandPollVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollVoteInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
{
|
||||
if(guild.polling)
|
||||
{
|
||||
if(guild.hasVoted.contains(user.uniqueID))
|
||||
{
|
||||
res.send(LocStrings.stub("PollVoteAlreadyVoted"));
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int voteNum = Integer.parseInt(input.args)-1;
|
||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||
{
|
||||
res.send(String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||
return;
|
||||
}
|
||||
|
||||
KittyPoll polled = guild.choices.get(voteNum);
|
||||
polled.votes++;
|
||||
guild.hasVoted.add(user.uniqueID);
|
||||
res.send(LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
res.send(LocStrings.stub("PollVoteNotValidNumber"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
res.send(LocStrings.stub("PollVoteNoPoll"));
|
||||
}
|
||||
}
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class CommandGuildRoleMain extends Command
|
||||
super(level, rating);
|
||||
framework.addCommand("add", new SubCommandAdd (KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("remove", new SubCommandRemove(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("list", new SubCommandList(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("allowed", new SubCommandAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
framework.addCommand("unallowed", new SubCommandNotAllowed(KittyRole.Admin, KittyRating.Safe));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
|
||||
framework.addCommand("start", new SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("addoption", new SubCommandAddOption(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
|
||||
framework.addCommand("show", new SubCommandShow(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("results", new SubCommandResults(KittyRole.General, KittyRating.Safe));
|
||||
framework.addCommand("vote", new SubCommandVote(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,22 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandAddOption extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandAddOption(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.addChoiceToPoll(input));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandEnd extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandEnd(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.endPoll());
|
||||
}
|
||||
|
||||
}
|
||||
+6
-9
@@ -1,19 +1,16 @@
|
||||
package commands.general;
|
||||
package commands.poll;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import core.*;
|
||||
import dataStructures.*;
|
||||
|
||||
public class CommandPollResults extends Command
|
||||
public class SubCommandResults extends SubCommand
|
||||
{
|
||||
public CommandPollResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
public SubCommandResults(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public String getHelpText() { return LocStrings.stub("PollResultsInfo"); }
|
||||
|
||||
@Override
|
||||
public void onRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
String results = "";
|
||||
int totalVotes = 0;
|
||||
@@ -28,9 +25,9 @@ public class CommandPollResults extends Command
|
||||
|
||||
for(int i = 0; i < votes.size(); i++)
|
||||
{
|
||||
results += String.format(LocStrings.stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100));
|
||||
results += String.format(LocStrings.stub("PollResultsResponse"), votes.get(i).votes, votes.get(i).choice, (int)(((double)votes.get(i).votes) / ((double)totalVotes) * 100)) + "\n";
|
||||
}
|
||||
|
||||
res.send(results);
|
||||
return new SubCommandFormattable (results);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package commands.poll;
|
||||
|
||||
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 SubCommandShow extends SubCommand
|
||||
{
|
||||
public SubCommandShow(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
if(!guild.polling)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollShowNoPoll"));
|
||||
}
|
||||
String poll = String.format(LocStrings.stub("PollShowPoll"), guild.poll);
|
||||
poll += LocStrings.stub("PollShowChoices");
|
||||
for(int i = 0; i < guild.choices.size(); i++)
|
||||
{
|
||||
poll += (i+1) + ": `" + guild.choices.get(i).choice + "`\n";
|
||||
}
|
||||
|
||||
return new SubCommandFormattable (poll);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandStart extends SubCommand
|
||||
{
|
||||
|
||||
public SubCommandStart(KittyRole roleLevel, KittyRating contentRating) {super(roleLevel, contentRating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
return new SubCommandFormattable (guild.startPoll(input));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package commands.poll;
|
||||
|
||||
import core.LocStrings;
|
||||
import core.SubCommand;
|
||||
import core.SubCommandFormattable;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyPoll;
|
||||
import dataStructures.KittyRating;
|
||||
import dataStructures.KittyRole;
|
||||
import dataStructures.KittyUser;
|
||||
|
||||
public class SubCommandVote extends SubCommand
|
||||
{
|
||||
public SubCommandVote(KittyRole level, KittyRating rating) { super(level, rating); }
|
||||
|
||||
@Override
|
||||
public SubCommandFormattable OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, String input)
|
||||
{
|
||||
if(guild.polling)
|
||||
{
|
||||
if(guild.hasVoted.contains(user.uniqueID))
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteAlreadyVoted"));
|
||||
}
|
||||
try
|
||||
{
|
||||
int voteNum = Integer.parseInt(input.substring(input.indexOf(" ")).trim())-1;
|
||||
if(voteNum >= guild.choices.size() || voteNum < 0)
|
||||
{
|
||||
return new SubCommandFormattable (String.format(LocStrings.stub("PollVoteNotValidVote"), voteNum));
|
||||
}
|
||||
|
||||
KittyPoll polled = guild.choices.get(voteNum);
|
||||
polled.votes++;
|
||||
guild.hasVoted.add(user.uniqueID);
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteSuccess") + " `" + polled.choice + "`!");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteNotValidNumber"));
|
||||
}
|
||||
}
|
||||
|
||||
return new SubCommandFormattable (LocStrings.stub("PollVoteNoPoll"));
|
||||
}
|
||||
}
|
||||
@@ -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 SubCommandStart(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("spin", new SubCommandSpin(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("end", new SubCommandEnd(KittyRole.Mod, KittyRating.Safe));
|
||||
framework.addCommand("join", new SubCommandJoin(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 SubCommandEnd extends SubCommand
|
||||
{
|
||||
public SubCommandEnd(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 SubCommandJoin extends SubCommand
|
||||
{
|
||||
public SubCommandJoin(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,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 SubCommandSpin extends SubCommand
|
||||
{
|
||||
public SubCommandSpin(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 SubCommandStart extends SubCommand
|
||||
{
|
||||
public SubCommandStart(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,14 +1,54 @@
|
||||
package core;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import commands.characters.CommandCharacterEditBio;
|
||||
import commands.characters.CommandCharacterEditName;
|
||||
import commands.characters.CommandCharacterEditURL;
|
||||
import commands.characters.CommandCharacterSearch;
|
||||
import commands.general.*;
|
||||
import commands.characters.CommandCharacterMain;
|
||||
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.CommandPollMain;
|
||||
import commands.raffle.CommandRaffleMain;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyGuild;
|
||||
import dataStructures.KittyRating;
|
||||
@@ -73,12 +113,8 @@ public class CommandManager
|
||||
this.register(LocCommands.stub("indicator"), new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe));
|
||||
|
||||
// Mod
|
||||
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));
|
||||
@@ -91,9 +127,6 @@ public class CommandManager
|
||||
this.register(LocCommands.stub("choose"), new CommandChoose(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("help"), new CommandHelp(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("info, about"), new CommandInfo(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("vote"), new CommandPollVote(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("results"), new CommandPollResults(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("showpoll"), new CommandPollShow(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("wolfram"), new CommandWolfram(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("c++, g++, cplus, cpp"), new CommandColiru(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("java, jdoodle"), new CommandJDoodle(KittyRole.General, KittyRating.Safe));
|
||||
@@ -110,15 +143,14 @@ 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("searchcharacter"), new CommandCharacterSearch(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("charactereditbio"), new CommandCharacterEditBio(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("charactereditname"), new CommandCharacterEditName(KittyRole.General, KittyRating.Safe));
|
||||
this.register(LocCommands.stub("charactereditURL"), new CommandCharacterEditURL(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));
|
||||
this.register(LocCommands.stub("poll"), new CommandPollMain(KittyRole.General, KittyRating.Safe));
|
||||
|
||||
}
|
||||
|
||||
// Allows the command manager to keep track of a command. Takes a pair (the un-localized and localzied commands)
|
||||
|
||||
@@ -14,8 +14,10 @@ import java.util.Vector;
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.CSVReaderBuilder;
|
||||
import com.opencsv.CSVWriter;
|
||||
import com.opencsv.RFC4180ParserBuilder;
|
||||
|
||||
import utils.GlobalLog;
|
||||
import utils.StringUtils;
|
||||
|
||||
public class ConfigCSV
|
||||
{
|
||||
@@ -41,7 +43,7 @@ public class ConfigCSV
|
||||
return new CSVWriter(writer,
|
||||
CSVWriter.DEFAULT_SEPARATOR,
|
||||
CSVWriter.DEFAULT_QUOTE_CHARACTER,
|
||||
'\\',
|
||||
CSVWriter.DEFAULT_ESCAPE_CHARACTER,
|
||||
CSVWriter.DEFAULT_LINE_END);
|
||||
}
|
||||
|
||||
@@ -60,7 +62,7 @@ public class ConfigCSV
|
||||
}
|
||||
|
||||
Reader reader = Files.newBufferedReader(Paths.get(filepath));
|
||||
CSVReader csvReader = new CSVReaderBuilder(reader).withSkipLines(1).build();
|
||||
CSVReader csvReader = new CSVReaderBuilder(reader).withSkipLines(1).withCSVParser(new RFC4180ParserBuilder().build()).build();
|
||||
fileContents.clear();
|
||||
|
||||
// Read contents. As for the line number, we not only start counting at 1, we also skip the header.
|
||||
@@ -74,7 +76,7 @@ public class ConfigCSV
|
||||
continue;
|
||||
}
|
||||
|
||||
ConfigItem parsedLine = new ConfigItem(record[0], record[1], record[2]);
|
||||
ConfigItem parsedLine = new ConfigItem(StringUtils.unEscape(record[0]), StringUtils.unEscape(record[1]), StringUtils.unEscape(record[2]));
|
||||
fileContents.add(parsedLine);
|
||||
++line;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package core;
|
||||
|
||||
import utils.StringUtils;
|
||||
|
||||
// Everything in here must be a string type. This class does not
|
||||
// perform any parsing past naming columns, and just holds the raw data.
|
||||
public class ConfigItem
|
||||
@@ -30,7 +32,7 @@ public class ConfigItem
|
||||
|
||||
public String[] getAll()
|
||||
{
|
||||
return new String[] {type, key, value};
|
||||
return new String[] {StringUtils.reEscape(type), StringUtils.reEscape(key), StringUtils.reEscape(value) };
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
||||
@@ -7,9 +7,6 @@ import java.util.concurrent.Semaphore;
|
||||
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import commands.characters.*;
|
||||
import commands.general.*;
|
||||
import commands.guildrole.CommandGuildRoleMain;
|
||||
import core.lua.PluginManager;
|
||||
import dataStructures.*;
|
||||
import main.Main;
|
||||
|
||||
@@ -42,12 +42,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,16 @@ 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(" ")));
|
||||
SubCommandFormattable res = null;
|
||||
try
|
||||
{
|
||||
res = commands.get(input.split(" ")[0].toLowerCase()).Invoke(guild, channel, user, input.substring(input.indexOf(" ")));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
res = commands.get(input.split(" ")[0].toLowerCase()).Invoke(guild, channel, user, "");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,14 @@ public class Plugin
|
||||
public Plugin(Path filepath)
|
||||
{
|
||||
this.filepath = filepath;
|
||||
reRead();
|
||||
}
|
||||
|
||||
|
||||
StringBuilder contentBuilder = new StringBuilder();
|
||||
|
||||
public void reRead()
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder contentBuilder = new StringBuilder();
|
||||
Stream<String> stream = Files.lines(filepath, StandardCharsets.UTF_8);
|
||||
stream.forEach(str -> contentBuilder.append(str).append("\n"));
|
||||
stream.close();
|
||||
|
||||
@@ -1,33 +1,31 @@
|
||||
package core.lua;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
import dataStructures.KittyUser;
|
||||
import utils.GlobalLog;
|
||||
import utils.LogFilter;
|
||||
import utils.io.DirectoryMonitor;
|
||||
|
||||
// Reads in, handles, and manipulates plugins. Plugins are loaded in the order they appear in the folder.
|
||||
public class PluginManager
|
||||
{
|
||||
// Variables
|
||||
public final String pluginFolder;
|
||||
public ArrayList<Plugin> plugins;
|
||||
public DirectoryMonitor directoryMonitor;
|
||||
|
||||
// Constructor
|
||||
public PluginManager(String folder)
|
||||
{
|
||||
this.pluginFolder = folder;
|
||||
this.directoryMonitor = new DirectoryMonitor(folder);
|
||||
plugins = new ArrayList<Plugin>();
|
||||
|
||||
try
|
||||
{
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(this.pluginFolder)))
|
||||
{
|
||||
paths.filter(Files::isRegularFile).forEach((path)->{ addPlugin(path); });
|
||||
}
|
||||
directoryMonitor.getCurrentFiles().forEach((file) -> addPlugin(file.path));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -35,6 +33,43 @@ public class PluginManager
|
||||
}
|
||||
}
|
||||
|
||||
public void update()
|
||||
{
|
||||
directoryMonitor.update(
|
||||
(addedFile) ->
|
||||
{
|
||||
addPlugin(addedFile.path);
|
||||
|
||||
GlobalLog.log(LogFilter.Plugin, "Found new plugin at " + addedFile.path);
|
||||
},
|
||||
(updatedFile) ->
|
||||
{
|
||||
for(Plugin plugin : plugins)
|
||||
{
|
||||
if(plugin.filepath.toString().equalsIgnoreCase(updatedFile.path.toString()))
|
||||
{
|
||||
plugin.reRead();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GlobalLog.log(LogFilter.Plugin, "A plugin was updated " + updatedFile.path);
|
||||
},
|
||||
(deletedFile) ->
|
||||
{
|
||||
for(int i = plugins.size() - 1; i >= 0; i--)
|
||||
{
|
||||
Plugin plugin = plugins.get(i);
|
||||
|
||||
if(plugin.filepath.toString().equalsIgnoreCase(deletedFile.path.toString()))
|
||||
plugins.remove(i);
|
||||
}
|
||||
|
||||
GlobalLog.log(LogFilter.Plugin, "Plugin deleted at " + deletedFile.path);
|
||||
});
|
||||
}
|
||||
|
||||
// Registers a plugin based on the path
|
||||
public void addPlugin(Path path)
|
||||
{
|
||||
plugins.add(new Plugin(path));
|
||||
@@ -66,6 +101,8 @@ public class PluginManager
|
||||
public void printAll()
|
||||
{
|
||||
for(int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
PluginLog.log(plugins.get(i).contents.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -86,7 +86,8 @@ public class Main extends ListenerAdapter
|
||||
RPManager.instance.addLine(channel, user, input);
|
||||
|
||||
// Run any pre-emptive upkeep we need to
|
||||
Superintendent.perCommandUpkeepPre();
|
||||
if(!Superintendent.perCommandUpkeepPre(pluginManager))
|
||||
return;
|
||||
|
||||
// Attempt to spin up a command. If the command doesn't exist.
|
||||
// Run plugins right before invoking the commands but after all other setup.
|
||||
@@ -111,6 +112,7 @@ public class Main extends ListenerAdapter
|
||||
}
|
||||
|
||||
// Run any upkeep in post we need to
|
||||
Superintendent.perCommandUpkeepPost(kittyCore, databaseManager);
|
||||
if(!Superintendent.perCommandUpkeepPost(kittyCore, databaseManager))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import core.Config;
|
||||
import core.DatabaseManager;
|
||||
import core.RPManager;
|
||||
import core.Stats;
|
||||
import core.lua.PluginManager;
|
||||
import dataStructures.KittyChannel;
|
||||
import dataStructures.KittyCore;
|
||||
import dataStructures.KittyGuild;
|
||||
@@ -71,11 +72,13 @@ public class Superintendent
|
||||
|
||||
// Only called once per command. Good for lazily updating.
|
||||
// Happens just before the command / plugin runs.
|
||||
public static boolean perCommandUpkeepPre()
|
||||
public static boolean perCommandUpkeepPre(PluginManager pluginManager)
|
||||
{
|
||||
// Upkeep the config file monitoring
|
||||
Config.instance.upkeep();
|
||||
pluginManager.update();
|
||||
|
||||
// Return if we succeeded or not. At this time, we always succeed.
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
package utils;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class StringUtils
|
||||
{
|
||||
public static String unEscape(String str)
|
||||
{
|
||||
str = str.replaceAll("\\\\b", "\b");
|
||||
str = str.replaceAll("\\\\n", "\n");
|
||||
str = str.replaceAll("\\\\t", "\t");
|
||||
str = str.replaceAll("\\\\r", "\r");
|
||||
str = str.replaceAll("\\\\f", "\f");
|
||||
str = str.replaceAll("\\\\\"", "\"");
|
||||
str = str.replaceAll("\\\\\\\\\\\\", "\\\\");
|
||||
|
||||
return str;
|
||||
return StringEscapeUtils.unescapeJava(str);
|
||||
}
|
||||
|
||||
public static String reEscape(String str)
|
||||
{
|
||||
str = str.replaceAll("\\\b", "\\\\\\b");
|
||||
str = str.replaceAll("\\\n", "\\\\\\n");
|
||||
str = str.replaceAll("\\\t", "\\\\\\t");
|
||||
str = str.replaceAll("\\\r", "\\\\\\r");
|
||||
str = str.replaceAll("\\\f", "\\\\\\f");
|
||||
|
||||
return str;
|
||||
return StringEscapeUtils.escapeJava(str);
|
||||
}
|
||||
|
||||
// Finds first whitespace in the string
|
||||
|
||||
Reference in New Issue
Block a user