Anticheat help

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

funpvp

Member
Oct 7, 2023
47
1
8
22
code

package me.willgames_.batanticheat;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;

import java.util.ArrayList;
import java.util.List;


public abstract class Check {

protected String name;
protected CheckType type;
public float vl;

public static List<UserData> alertsEnabled = new ArrayList<>();

//Used for individual players
private final UserData data;

private static TextComponent lbracket = new TextComponent("["),
rbracket = new TextComponent("]"),
prefix = new TextComponent("Bat"),
space = new TextComponent(" "),
message = new TextComponent("failed"),
infoPrefix = new TextComponent("Information: ");

public void flag(String info, Object... objects) {
String formattedInfo = String.format(info, objects);

TextComponent playerName = new TextComponent(data.getPlayer().getName());
playerName.setColor(ChatColor.WHITE);

TextComponent checkName = new TextComponent(name);
checkName.setColor(ChatColor.WHITE);

TextComponent violationCount = new TextComponent(String.valueOf(MathUtils.round(vl, 1);
violationCount.setColor(ChatColor.RED);

TextComponent alertMsg = new TextComponent(lbracket, prefix, rbracket, space, playerName,
space, message, space, checkName, space, lbracket, violationCount, rbracket);

TextComponent information = new TextComponent(Color.translate(formattedInfo));

information.setColor(ChatColor.WHITE);

alertMsg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
new BaseComponent[] {infoPrefix, space, information}));

alertsEnabled.forEach(user -> {
alertMsg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + name));

user.getPlayer().spigot().sendMessage(prefix space message space infoPrefix);
});
}

public abstract void receive(Object packet);

public abstract void send(Object packet);

static {
lbracket.setColor(ChatColor.DARK_GRAY);
rbracket.setColor(ChatColor.DARK_GRAY);
prefix.setColor(ChatColor.DARK_RED);
prefix.setBold(true);
message.setColor(ChatColor.GRAY);
infoPrefix.setColor(ChatColor.GOLD);
}
 

Attachments

  • errors.PNG
    errors.PNG
    41.9 KB · Views: 36
I'm not an avid Java user, but to handle the first error I'm assuming it's because you didn't import CheckType (nor can I find anything about it online), and you didn't import a UserData class either. The third error might resolve from fixing that, but if not, it shouldn't be hard to debug.

Error 4 is the same as error 2, and .getPlayer() won't work because 'data' is a variable that doesn't exist.

You didn't import MathUtils either, so there goes error 6.

7 and 8 are the same, and come from your two (?) missing parenthesis on the same line.

You didn't import java.awt.Color, so of course Color isn't going to work (that handles 9).

.getPlayer() doesn't work again because it relies on a UserData class that just doesn't exist.

Not sure about 11, 12, 13, 14, or 15. Maybe someone who's more experienced can answer that for you. This should give you a head start, though?

I can't propose a fix because I haven't written anything in Java before. All of this information is from the first link on Google when I looked up stuff from this post. Hope this helps.

Edit: It's useful if you use a code block next time, so I don't have to count 55 lines to find a single character.