use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.
the class BanCommand method banProfile.
@SuppressWarnings("rawtypes")
private static int banProfile(MessageContext context, Player profile, Duration duration, String reason) {
if (context.isAdmin()) {
Ban ban = profile.ban(context, duration, reason);
String message = "Banned profile " + profile.getPrettyDiscord() + ": \n\n" + ban;
if (context.isConsoleMessage()) {
context.sendMessage(message);
} else {
PrivateChannel privateChannel;
if (context.isPrivateMessage()) {
privateChannel = (PrivateChannel) context.getChannel();
} else {
privateChannel = context.getDiscordAuthor().getJDAUser().openPrivateChannel().complete();
}
privateChannel.sendMessage(message);
}
} else {
context.sendMessage("You do not have permission to execute this command");
}
return 1;
}
use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.
the class DiscoveryAudit method addProfileDiscovery.
@SuppressWarnings("rawtypes")
public static DiscoveryAudit addProfileDiscovery(MessageContext context, boolean automatic, Player player) {
Audit parent = Audit.addAudit(context, AuditType.DISCOVERY_AUDIT, getMessage(context, automatic, player));
PreparedStatement st;
try {
st = Insertion.insertInto(Table.AUDIT_PROFILE_DISCOVERIES).setColumns(AUDIT_ID, PLAYER_ID).to(parent.getID(), player.getID()).prepare(context, true);
st.execute();
DiscoveryAudit ret = getProfileDiscoveryByDiscoveredID(ConsoleContext.INSTANCE, player.getID());
ret.parentData = parent;
return ret;
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.
the class NameChangeAudit method addNameChange.
@SuppressWarnings("rawtypes")
public static NameChangeAudit addNameChange(MessageContext context, Player player, String newName) {
Audit parent = Audit.addAudit(ConsoleContext.INSTANCE, context, AuditType.NAME_CHANGE_AUDIT, getMessage(context, newName));
String name = player.getName();
PreparedStatement st;
try {
st = Insertion.insertInto(Table.AUDIT_NAME_CHANGES).setColumns(AUDIT_ID, OLD_PLAYER_NAME, NEW_PLAYER_NAME, PLAYER_ID, FRIEND_CODE).to(parent.getID(), name, newName, player.getID(), player.getFriendCode()).prepare(ConsoleContext.INSTANCE, true);
st.execute();
NameChangeAudit ret = getNameChangeByAuditID(ConsoleContext.INSTANCE, parent.getID());
ret.parentData = parent;
return ret;
} catch (SQLException e) {
throw new IOError(e);
}
}
use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.
the class InsertCommand method addProfile.
private static int addProfile(MessageContext context, int pid, String fc, String name) {
if (context.isOperator()) {
if (!Player.isPlayerKnown(context, pid)) {
try {
if (Player.isValidFriendCode(fc)) {
name = name.replace("\"", "");
Player.addPlayer(context, false, pid, fc, name);
Player player = Player.getPlayerByID(context, pid);
context.sendMessage("Inserted " + player.toFullString());
return 1;
} else {
context.sendMessage(fc + " is not a valid friend code");
return 1;
}
} catch (SQLException e) {
context.sendMessage("Unable to add profile " + pid + ":\n\n + " + StacktraceUtil.getStackTrace(e));
return 1;
}
} else {
context.sendMessage("A profile with PID " + pid + " is already known.");
return 1;
}
}
context.sendMessage("You do not have permission to execute that command.");
return 1;
}
use of com.gamebuster19901.excite.Player in project ExciteBot by TheGameCommunity.
the class RegisterCommand method requestRegistration.
@SuppressWarnings("rawtypes")
private static void requestRegistration(MessageContext context, String player) {
HashSet<Player> players = new HashSet<Player>();
DiscordUser discordUser = context.getDiscordAuthor();
if (context.isConsoleMessage()) {
context.sendMessage("This command must be executed from discord.");
return;
}
if (discordUser.requestingRegistration()) {
context.sendMessage("You are already trying to register a profile! Please wait until registration is complete or the registration code expires.");
return;
}
try {
int pid = Integer.parseInt(player);
players.add(Player.getPlayerByID(ConsoleContext.INSTANCE, pid));
} catch (NumberFormatException e) {
for (Player p : Player.getPlayersByName(ConsoleContext.INSTANCE, player)) {
players.add(p);
}
}
switch(players.size()) {
case 0:
context.sendMessage("Could not find a player with name or PID of " + player);
break;
case 1:
Player desiredProfile = players.toArray(new Player[] {})[0];
if (desiredProfile.isBanned()) {
context.sendMessage("You cannot register a banned profile.");
return;
}
String securityCode = discordUser.requestRegistration(desiredProfile);
sendInfo(context, discordUser, desiredProfile, securityCode);
break;
default:
String ambiguities = "";
for (Player p : players) {
ambiguities += p.toFullString() + "\n";
}
context.sendMessage(player + " is ambiguous as there is more than one profile known with that name. Please supply your account's PID instead of it's name." + "\n\nAmbiguities:\n\n" + ambiguities);
break;
}
}
Aggregations