]>
jfr.im git - irc/rizon/acid.git/blob - vizon/src/main/java/net/rizon/acid/plugins/vizon/commands/BanCommand.java
2 * Copyright (c) 2021, Dwarf <dwarf@rizon.net>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice, this
9 * list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
26 package net
.rizon
.acid
.plugins
.vizon
.commands
;
28 import net
.rizon
.acid
.core
.*;
29 import net
.rizon
.acid
.plugins
.vizon
.Vizon
;
30 import net
.rizon
.acid
.plugins
.vizon
.db
.VizonDatabase
;
32 import java
.util
.Arrays
;
36 * @author Dwarf <dwarf@rizon.net>
38 public class BanCommand
extends Command
46 public void Run(User source
, AcidUser to
, Channel c
, String
[] args
)
48 String
[] parts
= args
[0].split(" ");
49 String nick
= parts
[0];
50 String reason
= String
.join(" ", Arrays
.copyOfRange(parts
, 1, parts
.length
));
52 VizonDatabase database
= Vizon
.getVizonDatabase();
53 if (database
.findBanByNick(nick
) != null)
55 Acidictive
.reply(source
, to
, c
, "Nickname is already banned.");
59 if (database
.insertBan(nick
, source
.getNick(), reason
))
61 Acidictive
.reply(source
, to
, c
, "Nickname banned from playing.");
65 Acidictive
.reply(source
, to
, c
, "Couldn't create a ban, contact a dev.");