+/*
+ * Copyright (c) 2021, Dwarf <dwarf@rizon.net>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package net.rizon.acid.plugins.vizon.commands;
+
+import net.rizon.acid.core.*;
+import net.rizon.acid.plugins.vizon.Vizon;
+import net.rizon.acid.plugins.vizon.db.VizonDatabase;
+
+import java.util.Arrays;
+
+/**
+ *
+ * @author Dwarf <dwarf@rizon.net>
+ */
+public class BanCommand extends Command
+{
+ public BanCommand()
+ {
+ super(1, 1);
+ }
+
+ @Override
+ public void Run(User source, AcidUser to, Channel c, String[] args)
+ {
+ String[] parts = args[0].split(" ");
+ String nick = parts[0];
+ String reason = String.join(" ", Arrays.copyOfRange(parts, 1, parts.length));
+
+ VizonDatabase database = Vizon.getVizonDatabase();
+ if (database.findBanByNick(nick) != null)
+ {
+ Acidictive.reply(source, to, c, "Nickname is already banned.");
+ return;
+ }
+
+ if (database.insertBan(nick, source.getNick(), reason))
+ {
+ Acidictive.reply(source, to, c, "Nickname banned from playing.");
+ }
+ else
+ {
+ Acidictive.reply(source, to, c, "Couldn't create a ban, contact a dev.");
+ }
+ }
+}
\ No newline at end of file