mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
96 lines
2.9 KiB
Java
96 lines
2.9 KiB
Java
/*
|
|
* AntiCheatReloaded for Bukkit and Spigot.
|
|
* Copyright (c) 2012-2015 AntiCheat Team
|
|
* Copyright (c) 2016-2021 Rammelkast
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package com.rammelkast.anticheatreloaded.util;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
public class Group {
|
|
|
|
private String name;
|
|
private int level;
|
|
private ChatColor color = ChatColor.RED;
|
|
private List<String> actions = new ArrayList<String>();
|
|
|
|
public Group(String name, int level, String color, List<String> actions) {
|
|
|
|
this.name = name;
|
|
this.level = level;
|
|
this.actions = actions;
|
|
|
|
ChatColor c = ChatColor.valueOf(color);
|
|
if (c == null) {
|
|
AntiCheatReloaded.getPlugin().getLogger()
|
|
.warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
|
|
AntiCheatReloaded.getPlugin().getLogger().warning(
|
|
"This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
|
|
} else {
|
|
this.color = c;
|
|
}
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public int getLevel() {
|
|
return level;
|
|
}
|
|
|
|
public ChatColor getColor() {
|
|
return color;
|
|
}
|
|
|
|
public List<String> getActions() {
|
|
return actions;
|
|
}
|
|
|
|
public static Group load(String string) {
|
|
try {
|
|
if (string.split(" : ").length == 4) {
|
|
String name = string.split(" : ")[0];
|
|
int level = Integer.parseInt(string.split(" : ")[1]);
|
|
String color = string.split(" : ")[2];
|
|
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
|
|
return new Group(name, level, color, actions);
|
|
} else {
|
|
throw new Exception();
|
|
}
|
|
} catch (Exception ex) {
|
|
AntiCheatReloaded.getPlugin().getLogger()
|
|
.warning("An event was initialized with an invalid string: '" + string + "'");
|
|
AntiCheatReloaded.getPlugin().getLogger().warning(
|
|
"The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
|
|
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions);
|
|
}
|
|
}
|