├── .github
└── FUNDING.yml
├── LICENSE
├── README.md
├── pom.xml
└── src
├── dependencies
├── Advanced Abilities.jar
├── AureliumSkills.jar
├── CrackShot.jar
├── FileGUI.jar
├── GrapplingHook.jar
├── MagicSpells.jar
├── MineTinker.jar
├── MythicMobs.jar
├── PrinterMode.jar
├── ProjectKorra-1.8.6.jar
├── ProtocolLib.jar
├── ProtocolSupport.jar
├── RampenDrills.jar
├── VeinMiner-Bukkit-2.1.1.jar
├── ViaVersion-5.0.3.jar
├── WildToolsAPI.jar
├── acidisland.jar
└── floodgate-spigot.jar
└── main
├── java
├── ai
│ └── idealistic
│ │ └── spartan
│ │ ├── Register.java
│ │ ├── abstraction
│ │ ├── check
│ │ │ ├── Check.java
│ │ │ ├── CheckCancellation.java
│ │ │ ├── CheckDetection.java
│ │ │ ├── CheckEnums.java
│ │ │ ├── CheckPrevention.java
│ │ │ ├── CheckProcess.java
│ │ │ ├── CheckRunner.java
│ │ │ ├── definition
│ │ │ │ └── ImplementedDetection.java
│ │ │ └── example
│ │ │ │ ├── CheckExecutorExample.java
│ │ │ │ └── DetectionExecutorExample.java
│ │ ├── configuration
│ │ │ ├── ConfigurationBuilder.java
│ │ │ └── implementation
│ │ │ │ ├── Messages.java
│ │ │ │ ├── SQLFeature.java
│ │ │ │ └── Settings.java
│ │ ├── data
│ │ │ ├── Buffer.java
│ │ │ ├── CheckBoundData.java
│ │ │ ├── Cooldowns.java
│ │ │ ├── EnvironmentData.java
│ │ │ ├── PacketWorld.java
│ │ │ ├── TimerBalancer.java
│ │ │ └── component
│ │ │ │ ├── ComponentXZ.java
│ │ │ │ └── ComponentY.java
│ │ ├── entity
│ │ │ └── PluginNPC.java
│ │ ├── event
│ │ │ ├── CBlockPlaceEvent.java
│ │ │ ├── CPlayerRiptideEvent.java
│ │ │ ├── CPlayerVelocityEvent.java
│ │ │ ├── EntityAttackPlayerEvent.java
│ │ │ ├── PlayerAttackEvent.java
│ │ │ ├── PlayerLeftClickEvent.java
│ │ │ ├── PlayerTickEvent.java
│ │ │ ├── PlayerTransactionEvent.java
│ │ │ ├── PlayerUseEvent.java
│ │ │ ├── ServerBlockChange.java
│ │ │ └── SuperPositionPacketEvent.java
│ │ ├── inventory
│ │ │ ├── InventoryMenu.java
│ │ │ └── implementation
│ │ │ │ ├── ManageChecks.java
│ │ │ │ └── PlayerInfo.java
│ │ ├── profiling
│ │ │ ├── MiningHistory.java
│ │ │ ├── PlayerProfile.java
│ │ │ └── ProfileContinuity.java
│ │ ├── protocol
│ │ │ ├── CPlayerInventory.java
│ │ │ ├── ExtendedPotionEffect.java
│ │ │ ├── PlayerProtocol.java
│ │ │ └── PlayerPunishments.java
│ │ └── world
│ │ │ ├── ServerBlock.java
│ │ │ └── ServerLocation.java
│ │ ├── api
│ │ ├── BackgroundAPI.java
│ │ ├── CheckCancelEvent.java
│ │ ├── CheckPunishmentToggleEvent.java
│ │ ├── CheckSilentToggleEvent.java
│ │ ├── CheckToggleEvent.java
│ │ ├── Permission.java
│ │ ├── PlayerFoundOreEvent.java
│ │ ├── PlayerViolationCommandEvent.java
│ │ ├── PlayerViolationEvent.java
│ │ ├── SpartanAPI.java
│ │ ├── SpartanReloadEvent.java
│ │ └── ToggleAction.java
│ │ ├── compatibility
│ │ ├── Compatibility.java
│ │ ├── manual
│ │ │ ├── abilities
│ │ │ │ ├── AdvancedAbilities.java
│ │ │ │ ├── AureliumSkills.java
│ │ │ │ ├── GrapplingHook.java
│ │ │ │ ├── ItemsAdder.java
│ │ │ │ ├── MagicSpells.java
│ │ │ │ ├── MineTinker.java
│ │ │ │ ├── ProjectKorra.java
│ │ │ │ └── crackshot
│ │ │ │ │ ├── CrackShot.java
│ │ │ │ │ └── CrackShotPlus.java
│ │ │ ├── building
│ │ │ │ ├── MineBomb.java
│ │ │ │ ├── MythicMobs.java
│ │ │ │ ├── PrinterMode.java
│ │ │ │ ├── RampenDrills.java
│ │ │ │ ├── SuperPickaxe.java
│ │ │ │ ├── TreeFeller.java
│ │ │ │ ├── VeinMiner.java
│ │ │ │ └── WildTools.java
│ │ │ ├── damage
│ │ │ │ └── RealDualWield.java
│ │ │ ├── enchants
│ │ │ │ ├── CustomEnchantsPlus.java
│ │ │ │ └── EcoEnchants.java
│ │ │ ├── entity
│ │ │ │ ├── CraftBook.java
│ │ │ │ └── Vehicles.java
│ │ │ └── vanilla
│ │ │ │ └── Attributes.java
│ │ └── necessary
│ │ │ ├── BedrockCompatibility.java
│ │ │ ├── Floodgate.java
│ │ │ ├── ProtocolSupport.java
│ │ │ └── protocollib
│ │ │ ├── BackgroundProtocolLib.java
│ │ │ └── ProtocolLib.java
│ │ ├── functionality
│ │ ├── command
│ │ │ ├── CommandExecution.java
│ │ │ └── CommandTab.java
│ │ ├── concurrent
│ │ │ ├── CheckThread.java
│ │ │ └── GeneralThread.java
│ │ ├── connection
│ │ │ ├── CloudBase.java
│ │ │ ├── CloudConnections.java
│ │ │ ├── DiscordServer.java
│ │ │ ├── IDs.java
│ │ │ ├── JarVerification.java
│ │ │ ├── Metrics.java
│ │ │ └── PluginAddons.java
│ │ ├── moderation
│ │ │ ├── AwarenessNotifications.java
│ │ │ ├── CrossServerNotifications.java
│ │ │ ├── DetectionNotifications.java
│ │ │ ├── Wave.java
│ │ │ └── clickable
│ │ │ │ ├── BackgroundClickableMessage.java
│ │ │ │ └── ClickableMessage.java
│ │ ├── server
│ │ │ ├── Config.java
│ │ │ ├── MultiVersion.java
│ │ │ ├── Permissions.java
│ │ │ ├── PluginBase.java
│ │ │ ├── ServerSchedulers.java
│ │ │ └── TPS.java
│ │ └── tracking
│ │ │ ├── AntiCheatLogs.java
│ │ │ ├── MovementProcessing.java
│ │ │ ├── Piston.java
│ │ │ └── ResearchEngine.java
│ │ ├── listeners
│ │ ├── NPCManager.java
│ │ ├── bukkit
│ │ │ ├── CombatEvent.java
│ │ │ ├── DeathEvent.java
│ │ │ ├── MovementEvent.java
│ │ │ ├── PlaceEvent.java
│ │ │ ├── TeleportEvent.java
│ │ │ ├── TridentEvent.java
│ │ │ ├── VehicleEvent.java
│ │ │ ├── VelocityEvent.java
│ │ │ ├── standalone
│ │ │ │ ├── BowEvent.java
│ │ │ │ ├── ChatEvent.java
│ │ │ │ ├── ChunksEvent.java
│ │ │ │ ├── ElytraEvent.java
│ │ │ │ ├── HealthEvent.java
│ │ │ │ ├── InventoryEvent.java
│ │ │ │ ├── JoinEvent.java
│ │ │ │ ├── LeaveEvent.java
│ │ │ │ ├── PluginEvent.java
│ │ │ │ ├── VehicleDeathEvent.java
│ │ │ │ └── WorldEvent.java
│ │ │ └── test
│ │ │ │ └── GhostBlockTest.java
│ │ └── protocol
│ │ │ ├── AbilitiesListener.java
│ │ │ ├── BlockPlaceListener.java
│ │ │ ├── ClicksListener.java
│ │ │ ├── DeathListener.java
│ │ │ ├── ExplosionListener.java
│ │ │ ├── MovementListener.java
│ │ │ ├── MultiBlockLegacyListener.java
│ │ │ ├── MultiBlockListener.java
│ │ │ ├── PacketDebug.java
│ │ │ ├── PacketLatencyHandler.java
│ │ │ ├── PacketPistonHandle.java
│ │ │ ├── PacketServerBlockHandle.java
│ │ │ ├── TeleportListener.java
│ │ │ ├── TridentListener.java
│ │ │ ├── UseEntityListener.java
│ │ │ ├── UseItemStatusHandle.java
│ │ │ ├── VehicleHandle.java
│ │ │ ├── VelocityListener.java
│ │ │ ├── combat
│ │ │ ├── CombatListener.java
│ │ │ └── LegacyCombatListener.java
│ │ │ └── standalone
│ │ │ ├── BlockPlaceBalancerListener.java
│ │ │ ├── EntityActionListener.java
│ │ │ ├── JoinListener.java
│ │ │ └── LegacyLagCompensationListener.java
│ │ └── utils
│ │ ├── java
│ │ ├── ConcurrentList.java
│ │ ├── OverflowList.java
│ │ ├── OverflowMap.java
│ │ ├── Pair.java
│ │ ├── ReflectionUtils.java
│ │ ├── RequestUtils.java
│ │ ├── StringUtils.java
│ │ ├── TimeUtils.java
│ │ └── TryIgnore.java
│ │ ├── math
│ │ ├── AlgebraUtils.java
│ │ ├── ClientMath.java
│ │ ├── MathHelper.java
│ │ ├── OptifineMath.java
│ │ ├── RayLine.java
│ │ ├── RayUtils.java
│ │ ├── Sensitivity.java
│ │ ├── VanillaMath.java
│ │ └── statistics
│ │ │ ├── LinearRegression.java
│ │ │ └── StatisticsMath.java
│ │ └── minecraft
│ │ ├── entity
│ │ ├── AxisAlignedBB.java
│ │ ├── CombatUtils.java
│ │ ├── EntityUtils.java
│ │ ├── MovingObjectPosition.java
│ │ ├── PlayerUtils.java
│ │ └── PotionEffectUtils.java
│ │ ├── inventory
│ │ ├── BackgroundInventoryUtils.java
│ │ ├── EnchantmentUtils.java
│ │ ├── InventoryUtils.java
│ │ └── MaterialUtils.java
│ │ ├── protocol
│ │ └── ProtocolTools.java
│ │ ├── server
│ │ ├── ConfigUtils.java
│ │ ├── PluginUtils.java
│ │ └── ProxyUtils.java
│ │ ├── vector
│ │ ├── CVector2D.java
│ │ ├── CVector2F.java
│ │ ├── Vec3.java
│ │ └── Vec3i.java
│ │ └── world
│ │ ├── BlockPatternUtils.java
│ │ ├── BlockPos.java
│ │ ├── BlockUtils.java
│ │ ├── BoundingBoxUtil.java
│ │ ├── EnumFacing.java
│ │ └── GroundUtils.java
└── me
│ └── vagdedes
│ └── spartan
│ └── api
│ ├── API.java
│ ├── BackgroundAPI.java
│ ├── CheckCancelEvent.java
│ ├── CheckPunishmentToggleEvent.java
│ ├── CheckSilentToggleEvent.java
│ ├── CheckToggleEvent.java
│ ├── LEGACY
│ ├── PlayerFoundOreEvent.java
│ ├── PlayerViolationCommandEvent.java
│ ├── PlayerViolationEvent.java
│ ├── SpartanReloadEvent.java
│ └── system
│ └── Enums.java
└── resources
└── plugin.yml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: SpartanAntiCheat
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | Spartan
8 | me.vagdedes.spartan
9 | Spartan
10 | 1.0
11 |
12 |
13 |
14 |
15 | papermc
16 | https://repo.papermc.io/repository/maven-public/
17 |
18 |
19 |
20 |
21 |
22 | 8
23 | 8
24 |
25 |
26 |
27 |
28 |
29 | dev.folia
30 | folia-api
31 | 1.20.1-R0.1-SNAPSHOT
32 | provided
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/dependencies/Advanced Abilities.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/Advanced Abilities.jar
--------------------------------------------------------------------------------
/src/dependencies/AureliumSkills.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/AureliumSkills.jar
--------------------------------------------------------------------------------
/src/dependencies/CrackShot.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/CrackShot.jar
--------------------------------------------------------------------------------
/src/dependencies/FileGUI.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/FileGUI.jar
--------------------------------------------------------------------------------
/src/dependencies/GrapplingHook.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/GrapplingHook.jar
--------------------------------------------------------------------------------
/src/dependencies/MagicSpells.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/MagicSpells.jar
--------------------------------------------------------------------------------
/src/dependencies/MineTinker.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/MineTinker.jar
--------------------------------------------------------------------------------
/src/dependencies/MythicMobs.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/MythicMobs.jar
--------------------------------------------------------------------------------
/src/dependencies/PrinterMode.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/PrinterMode.jar
--------------------------------------------------------------------------------
/src/dependencies/ProjectKorra-1.8.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/ProjectKorra-1.8.6.jar
--------------------------------------------------------------------------------
/src/dependencies/ProtocolLib.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/ProtocolLib.jar
--------------------------------------------------------------------------------
/src/dependencies/ProtocolSupport.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/ProtocolSupport.jar
--------------------------------------------------------------------------------
/src/dependencies/RampenDrills.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/RampenDrills.jar
--------------------------------------------------------------------------------
/src/dependencies/VeinMiner-Bukkit-2.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/VeinMiner-Bukkit-2.1.1.jar
--------------------------------------------------------------------------------
/src/dependencies/ViaVersion-5.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/ViaVersion-5.0.3.jar
--------------------------------------------------------------------------------
/src/dependencies/WildToolsAPI.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/WildToolsAPI.jar
--------------------------------------------------------------------------------
/src/dependencies/acidisland.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/acidisland.jar
--------------------------------------------------------------------------------
/src/dependencies/floodgate-spigot.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/dependencies/floodgate-spigot.jar
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/CheckCancellation.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check;
2 |
3 | import ai.idealistic.spartan.compatibility.Compatibility;
4 | import ai.idealistic.spartan.functionality.server.TPS;
5 | import lombok.Getter;
6 |
7 | public class CheckCancellation {
8 |
9 | @Getter
10 | private final String reason, pointer;
11 | private final long expiration;
12 |
13 | CheckCancellation(Compatibility.CompatibilityType compatibilityType) {
14 | this.reason = compatibilityType.toString();
15 | this.pointer = null;
16 | this.expiration = 0L;
17 | }
18 |
19 | CheckCancellation(String reason, String pointer, int ticks) {
20 | this.reason = reason;
21 | this.pointer = pointer;
22 | this.expiration = ticks == 0
23 | ? Long.MAX_VALUE
24 | : System.currentTimeMillis() + (ticks * TPS.tickTime);
25 | }
26 |
27 | boolean hasExpired() {
28 | return expiration < System.currentTimeMillis();
29 | }
30 |
31 | boolean pointerMatches(String info) {
32 | return this.pointer == null || info.contains(this.pointer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/CheckPrevention.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check;
2 |
3 | import ai.idealistic.spartan.functionality.server.Config;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import ai.idealistic.spartan.functionality.server.TPS;
6 | import org.bukkit.Location;
7 |
8 | public class CheckPrevention {
9 |
10 | boolean canPrevent;
11 | private final Location location;
12 | private final boolean groundTeleport;
13 | private final double damage;
14 | private final long expiration;
15 |
16 | CheckPrevention() {
17 | this.canPrevent = false;
18 | this.location = null;
19 | this.groundTeleport = false;
20 | this.damage = 0.0;
21 | this.expiration = 0L;
22 | }
23 |
24 | CheckPrevention(Location location, int cancelTicks, boolean groundTeleport, double damage) {
25 | this.canPrevent = false;
26 | this.location = location;
27 | this.groundTeleport = groundTeleport
28 | && Config.settings.getBoolean("Detections.ground_teleport_on_detection");
29 | this.damage = Config.settings.getBoolean("Detections.damage_on_detection")
30 | ? damage
31 | : 0.0;
32 | this.expiration = cancelTicks <= 1
33 | ? Long.MAX_VALUE
34 | : System.currentTimeMillis() + (cancelTicks * TPS.tickTime);
35 | }
36 |
37 | boolean complete() {
38 | return this.canPrevent
39 | && System.currentTimeMillis() <= this.expiration;
40 | }
41 |
42 | boolean hasDetails() {
43 | return this.location != null
44 | || this.groundTeleport
45 | || this.damage > 0.0;
46 | }
47 |
48 | void handle(CheckDetection detection) {
49 | if (PluginBase.isSynchronised()) {
50 | detection.prevention(
51 | this.location,
52 | this.groundTeleport,
53 | this.damage
54 | ).run();
55 | } else {
56 | PluginBase.transferTask(
57 | detection.protocol,
58 | detection.prevention(
59 | this.location,
60 | this.groundTeleport,
61 | this.damage
62 | )
63 | );
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/CheckProcess.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 |
5 | public abstract class CheckProcess {
6 |
7 | public final CheckEnums.HackType hackType;
8 | public final PlayerProtocol protocol;
9 |
10 | protected CheckProcess(CheckEnums.HackType hackType, PlayerProtocol protocol) {
11 | this.hackType = hackType;
12 | this.protocol = protocol;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/definition/ImplementedDetection.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check.definition;
2 |
3 | import ai.idealistic.spartan.abstraction.check.Check;
4 | import ai.idealistic.spartan.abstraction.check.CheckDetection;
5 | import ai.idealistic.spartan.abstraction.check.CheckRunner;
6 |
7 | public class ImplementedDetection extends CheckDetection {
8 |
9 | public ImplementedDetection(
10 | CheckRunner executor,
11 | Check.DataType forcedDataType,
12 | Check.DetectionType detectionType,
13 | String name,
14 | Boolean def
15 | ) {
16 | super(
17 | executor,
18 | forcedDataType,
19 | detectionType,
20 | name,
21 | def
22 | );
23 | }
24 |
25 | public ImplementedDetection(
26 | CheckRunner executor,
27 | Check.DataType forcedDataType,
28 | Check.DetectionType detectionType,
29 | String name,
30 | Boolean def,
31 | long defaultAverageTime,
32 | long timeToNotify,
33 | long timeToPrevent,
34 | long timeToPunish
35 | ) {
36 | super(
37 | executor,
38 | forcedDataType,
39 | detectionType,
40 | name,
41 | def,
42 | defaultAverageTime,
43 | timeToNotify,
44 | timeToPrevent,
45 | timeToPunish
46 | );
47 | }
48 |
49 | public ImplementedDetection(
50 | CheckDetection detection,
51 | String name,
52 | Boolean def
53 | ) {
54 | super(
55 | detection.executor,
56 | detection.forcedDataType,
57 | detection.detectionType,
58 | name,
59 | def,
60 | detection.defaultAverageTime,
61 | detection.timeToNotify,
62 | detection.timeToPrevent,
63 | detection.timeToPunish
64 | );
65 |
66 | if (!detection.hasName) {
67 | detection.executor.removeDetection(detection);
68 | detection.executor.hackType.removeDetection(detection.name);
69 | }
70 | }
71 |
72 | public ImplementedDetection(
73 | CheckDetection detection,
74 | String name,
75 | Boolean def,
76 | long defaultAverageTime,
77 | long timeToNotify,
78 | long timeToPrevent,
79 | long timeToPunish
80 | ) {
81 | super(
82 | detection.executor,
83 | detection.forcedDataType,
84 | detection.detectionType,
85 | name,
86 | def,
87 | defaultAverageTime,
88 | timeToNotify,
89 | timeToPrevent,
90 | timeToPunish
91 | );
92 |
93 | if (!detection.hasName) {
94 | detection.executor.removeDetection(detection);
95 | detection.executor.hackType.removeDetection(detection.name);
96 | }
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/example/CheckExecutorExample.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check.example;
2 |
3 | import ai.idealistic.spartan.abstraction.check.Check;
4 | import ai.idealistic.spartan.abstraction.check.CheckDetection;
5 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
6 | import ai.idealistic.spartan.abstraction.check.CheckRunner;
7 | import ai.idealistic.spartan.abstraction.check.definition.ImplementedDetection;
8 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
9 |
10 | public class CheckExecutorExample extends CheckRunner {
11 |
12 | private final DetectionExecutorExample detection1;
13 | private final CheckDetection detection2;
14 |
15 | public CheckExecutorExample(CheckEnums.HackType hackType, PlayerProtocol protocol, String playerName) {
16 | super(hackType, protocol);
17 |
18 | this.detection1 = new DetectionExecutorExample(
19 | this
20 | );
21 |
22 |
23 | this.detection2 = new ImplementedDetection(
24 | this,
25 | Check.DataType.JAVA,
26 | Check.DetectionType.PACKETS,
27 | "detection_option_name_in_checks_yml",
28 | true // Enabled By Default Or Not
29 | );
30 |
31 | // This is the constructor you will call to initiate this abstract class
32 | // implementation. If your check/detection has higher complexity, it will
33 | // likely need to be produced in multiple classes. In that case, you can
34 | // separate the functionality by using the 'DetectionExecutor' class and
35 | // connect them all via the 'CheckExecutor' class.
36 | }
37 |
38 | @Override
39 | protected void handleInternal(boolean cancelled, Object object) {
40 | // This method should be used to handle data for a check/detection.
41 | //
42 | // The boolean 'cancelled' is 'true' when an event is cancelled by the server
43 | // or by another plugin. Based on configuration, a user of this plugin may
44 | // choose for cancelled events to not go through, thus causing this method to
45 | // not be called at all.
46 | }
47 |
48 | @Override
49 | protected boolean canRun() {
50 | this.detection1.customMethod2();
51 | // This method should be used to judge whether a check should run or not.
52 | // However, each check/detection may have different requirements, so use
53 | // this method for the requirements all checks/detections have in common.
54 | // Keep in mind that basic factors such as the check being enabled are
55 | // already accounted for prior to running this method.
56 | return true;
57 | }
58 |
59 | // Here you can add more methods since you are extending an abstract class.
60 | // It is nonetheless recommended to stick to the default methods, otherwise
61 | // you may run into scenarios where you need to use casting to access methods
62 | // of the child class from the parent class which produces overhead. For
63 | // comparison, accessing a parent class from a child class is significantly
64 | // lighter.
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/check/example/DetectionExecutorExample.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.check.example;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckDetection;
4 | import ai.idealistic.spartan.abstraction.check.CheckRunner;
5 |
6 | public class DetectionExecutorExample extends CheckDetection {
7 |
8 | DetectionExecutorExample(CheckRunner executor) {
9 | super(
10 | executor,
11 | null,
12 | null,
13 | "detection_option_name_in_checks_yml",
14 | true // Enabled By Default Or Not
15 | );
16 | }
17 |
18 | void customMethod1() {
19 |
20 | }
21 |
22 | boolean customMethod2() {
23 | return true;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/CheckBoundData.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import org.bukkit.Location;
5 |
6 | public class CheckBoundData {
7 | private PlayerProtocol attacker;
8 | private Location target;
9 | public int failures;
10 |
11 | public CheckBoundData(PlayerProtocol player, PlayerProtocol target) {
12 | this.attacker = player;
13 | this.target = target.getLocation();
14 | this.failures = 0;
15 | }
16 |
17 | public CheckBoundData(PlayerProtocol player, Location target) {
18 | this.attacker = player;
19 | this.target = target;
20 | this.failures = 0;
21 | }
22 |
23 | public PlayerProtocol getAttacker() {
24 | return this.attacker;
25 | }
26 |
27 | public Location getTarget() {
28 | return this.target;
29 | }
30 |
31 | public int getFailures() {
32 | return this.failures;
33 | }
34 |
35 | public void setAttacker(PlayerProtocol attacker) {
36 | this.attacker = attacker;
37 | }
38 |
39 | public void setTarget(Location target) {
40 | this.target = target;
41 | }
42 |
43 | public void setFailures(int failures) {
44 | this.failures = failures;
45 | }
46 |
47 | public boolean equals(final Object o) {
48 | if (o == this) return true;
49 | if (!(o instanceof CheckBoundData)) return false;
50 | final CheckBoundData other = (CheckBoundData) o;
51 | if (!other.canEqual((Object) this)) return false;
52 | final Object this$attacker = this.getAttacker();
53 | final Object other$attacker = other.getAttacker();
54 | if (this$attacker == null ? other$attacker != null : !this$attacker.equals(other$attacker)) return false;
55 | final Object this$target = this.getTarget();
56 | final Object other$target = other.getTarget();
57 | if (this$target == null ? other$target != null : !this$target.equals(other$target)) return false;
58 | if (this.getFailures() != other.getFailures()) return false;
59 | return true;
60 | }
61 |
62 | protected boolean canEqual(final Object other) {
63 | return other instanceof CheckBoundData;
64 | }
65 |
66 | public int hashCode() {
67 | final int PRIME = 59;
68 | int result = 1;
69 | final Object $attacker = this.getAttacker();
70 | result = result * PRIME + ($attacker == null ? 43 : $attacker.hashCode());
71 | final Object $target = this.getTarget();
72 | result = result * PRIME + ($target == null ? 43 : $target.hashCode());
73 | result = result * PRIME + this.getFailures();
74 | return result;
75 | }
76 |
77 | public String toString() {
78 | return "CheckBoundData(attacker=" + this.getAttacker() + ", target=" + this.getTarget() + ", failures=" + this.getFailures() + ")";
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/Cooldowns.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data;
2 |
3 | import ai.idealistic.spartan.functionality.server.TPS;
4 | import ai.idealistic.spartan.utils.math.AlgebraUtils;
5 |
6 | import java.util.Map;
7 |
8 | public class Cooldowns {
9 |
10 | private final Map storage;
11 |
12 | public Cooldowns(Map map) {
13 | this.storage = map;
14 | }
15 |
16 | public int get(String name) {
17 | Long object = storage.get(name);
18 |
19 | if (object == null) {
20 | return 0;
21 | } else {
22 | object -= System.currentTimeMillis();
23 | return object < 0L ? 0 : AlgebraUtils.integerCeil(object / (double) TPS.tickTime);
24 | }
25 | }
26 |
27 | public boolean canDo(String name) {
28 | return get(name) == 0;
29 | }
30 |
31 | public void add(String name, int ticks) {
32 | storage.put(name, System.currentTimeMillis() + (ticks * TPS.tickTime));
33 | }
34 |
35 | public void add(String[] names, int ticks) {
36 | for (String name : names) {
37 | storage.put(name, System.currentTimeMillis() + (ticks * TPS.tickTime));
38 | }
39 | }
40 |
41 | public void remove(String name) {
42 | storage.remove(name);
43 | }
44 |
45 | public void remove(String[] names) {
46 | for (String name : names) {
47 | storage.remove(name);
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/PacketWorld.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data;
2 |
3 | import ai.idealistic.spartan.abstraction.event.PlayerTickEvent;
4 | import ai.idealistic.spartan.abstraction.event.ServerBlockChange;
5 | import ai.idealistic.spartan.listeners.bukkit.standalone.ChunksEvent;
6 | import ai.idealistic.spartan.utils.java.ConcurrentList;
7 | import ai.idealistic.spartan.utils.minecraft.world.BlockUtils;
8 | import org.bukkit.Location;
9 | import org.bukkit.Material;
10 | import org.bukkit.block.Block;
11 | import org.bukkit.entity.Player;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 |
17 | public class PacketWorld {
18 |
19 | private final List query;
20 | private final Player player;
21 | private int lagTick;
22 | public boolean transactionLock;
23 |
24 | public PacketWorld(Player player) {
25 | this.player = player;
26 | this.query = new ConcurrentList<>();
27 | this.lagTick = 0;
28 | }
29 |
30 |
31 | public void tick(PlayerTickEvent tickEvent) {
32 | if (tickEvent.getDelay() < 12) {
33 | this.lagTick = 3;
34 | } else if (lagTick > 0) {
35 | if (!this.transactionLock) this.lagTick--;
36 | } else {
37 | this.query.removeIf(change -> --change.tick == 0);
38 | }
39 | }
40 |
41 | public List getLocalWorld() {
42 | return new ArrayList<>(this.query);
43 | }
44 |
45 | public Material getBlock(Location location) {
46 | for (ServerBlockChange change : this.query) {
47 | Location lL = change.position.toLocation(this.player.getWorld());
48 |
49 | if (Math.abs(lL.getX() - location.getX()) <= 1.3 &&
50 | Math.abs(lL.getY() - location.getY()) <= 1.3 &&
51 | Math.abs(lL.getZ() - location.getZ()) <= 1.3) {
52 | return change.getData();
53 | }
54 | }
55 |
56 | Block b = ChunksEvent.getBlockAsync(location);
57 | return (b == null) ? null : b.getType();
58 | }
59 |
60 | public void worldChange(ServerBlockChange blockChange) {
61 | if (BlockUtils.areAir(blockChange.getData())) {
62 | Block b = ChunksEvent.getBlockAsync(
63 | blockChange.position.toLocation(this.player.getWorld())
64 | );
65 | if (b == null || BlockUtils.areAir(b.getType())) return;
66 | blockChange.setData(b.getType());
67 | }
68 | long hash = blockChange.hashCode();
69 |
70 | for (ServerBlockChange c : this.query) {
71 | if (c.generateHash() == hash) {
72 | this.query.remove(c); // to delete
73 | break;
74 | }
75 | }
76 | this.query.add(blockChange);
77 | this.transactionLock = true;
78 | this.lagTick = 3;
79 | }
80 |
81 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/TimerBalancer.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data;
2 |
3 | import ai.idealistic.spartan.abstraction.event.PlayerTickEvent;
4 | import lombok.Getter;
5 |
6 | @Getter
7 | public class TimerBalancer {
8 |
9 | private long balancer, result;
10 | private int negative, forced, latency;
11 |
12 | public TimerBalancer() {
13 | balancer = 1000;
14 | result = 0;
15 | forced = 0;
16 | latency = 0;
17 | }
18 |
19 | public void pushDelay(PlayerTickEvent event) {
20 | long delay = event.getDelay();
21 | forced = ((delay > 15 && delay < 48) ? forced + 1 : 0);
22 | latency = ((delay > 40 && delay < 48) ? latency + 10 : latency / 2);
23 |
24 | if (delay > 50) {
25 | balancer += delay - 50;
26 | if (delay > 53) negative++;
27 | } else if (delay < 50) {
28 | final long deviance = 50 - delay;
29 |
30 | if (balancer - deviance >= 0) {
31 | balancer -= deviance;
32 | } else {
33 | final long totalDeviance = deviance - balancer;
34 | result += totalDeviance;
35 | balancer = 0;
36 | }
37 | negative = 0;
38 | } else if (result >= 0) {
39 | result /= 2L;
40 | balancer /= 2L;
41 | negative = 0;
42 | }
43 | }
44 |
45 | public boolean isNegativeTimer() {
46 | return this.negative > 15;
47 | }
48 |
49 | public void addBalance(long balance) {
50 | this.balancer += balance;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/component/ComponentXZ.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data.component;
2 |
3 | public class ComponentXZ {
4 | public boolean pistonHandle, pistonTick, explosionTick;
5 |
6 | public ComponentXZ() {
7 | this.pistonHandle = false;
8 | this.pistonTick = false;
9 | this.explosionTick = false;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/data/component/ComponentY.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.data.component;
2 |
3 | public class ComponentY {
4 |
5 | public boolean pistonHandle, pistonTick, explosionTick;
6 |
7 | public ComponentY() {
8 | this.pistonHandle = false;
9 | this.pistonTick = false;
10 | this.explosionTick = false;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/CBlockPlaceEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.block.Block;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Cancellable;
6 |
7 | public class CBlockPlaceEvent implements Cancellable {
8 |
9 | private boolean cancelled;
10 | public final Block placedBlock, placedAgainstBlock;
11 | public final Player player;
12 |
13 | public CBlockPlaceEvent(Player player, Block placedBlock, Block placedAgainst, boolean cancelled) {
14 | this.player = player;
15 | this.placedAgainstBlock = placedAgainst;
16 | this.placedBlock = placedBlock;
17 | this.cancelled = cancelled;
18 | }
19 |
20 | @Override
21 | public boolean isCancelled() {
22 | return this.cancelled;
23 | }
24 |
25 | @Override
26 | public void setCancelled(boolean b) {
27 | this.cancelled = b;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/CPlayerRiptideEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import org.bukkit.inventory.ItemStack;
5 | import org.bukkit.util.Vector;
6 |
7 | public class CPlayerRiptideEvent {
8 |
9 | public final PlayerProtocol protocol;
10 | public final ItemStack item;
11 | public final Vector velocity;
12 |
13 | public CPlayerRiptideEvent(PlayerProtocol protocol, ItemStack item, Vector velocity) {
14 | this.protocol = protocol;
15 | this.item = item;
16 | this.velocity = velocity;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/CPlayerVelocityEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.HandlerList;
6 | import org.bukkit.event.player.PlayerEvent;
7 | import org.bukkit.util.Vector;
8 | import org.jetbrains.annotations.NotNull;
9 |
10 | public class CPlayerVelocityEvent extends PlayerEvent implements Cancellable {
11 |
12 | private static final HandlerList handlers = new HandlerList();
13 | private boolean cancel = false;
14 | private Vector velocity;
15 |
16 | public CPlayerVelocityEvent(@NotNull Player player, @NotNull Vector velocity) {
17 | super(player);
18 | this.velocity = velocity;
19 | }
20 |
21 | public boolean isCancelled() {
22 | return this.cancel;
23 | }
24 |
25 | public void setCancelled(boolean cancel) {
26 | this.cancel = cancel;
27 | }
28 |
29 | public @NotNull Vector getVelocity() {
30 | return this.velocity;
31 | }
32 |
33 | public void setVelocity(@NotNull Vector velocity) {
34 | this.velocity = velocity;
35 | }
36 |
37 | public @NotNull HandlerList getHandlers() {
38 | return handlers;
39 | }
40 |
41 | public static @NotNull HandlerList getHandlerList() {
42 | return handlers;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/EntityAttackPlayerEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.entity.LivingEntity;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Cancellable;
6 |
7 | public class EntityAttackPlayerEvent implements Cancellable {
8 |
9 | public final Player player;
10 | public final LivingEntity damager;
11 | private boolean cancelled;
12 |
13 | public EntityAttackPlayerEvent(Player player, LivingEntity damager, boolean cancelled) {
14 | this.player = player;
15 | this.damager = damager;
16 | this.cancelled = cancelled;
17 | }
18 |
19 | @Override
20 | public boolean isCancelled() {
21 | return this.cancelled;
22 | }
23 |
24 | @Override
25 | public void setCancelled(boolean b) {
26 | this.cancelled = b;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/PlayerAttackEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.entity.LivingEntity;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Cancellable;
6 |
7 | public class PlayerAttackEvent implements Cancellable {
8 |
9 | public final Player player;
10 | public final LivingEntity target;
11 | private boolean cancelled;
12 |
13 | public PlayerAttackEvent(Player player, LivingEntity target, boolean cancelled) {
14 | this.player = player;
15 | this.target = target;
16 | this.cancelled = cancelled;
17 | }
18 |
19 | @Override
20 | public boolean isCancelled() {
21 | return this.cancelled;
22 | }
23 |
24 | @Override
25 | public void setCancelled(boolean b) {
26 | this.cancelled = b;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/PlayerLeftClickEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | public class PlayerLeftClickEvent {
6 |
7 | public final Player player;
8 | public final long delay;
9 |
10 | public PlayerLeftClickEvent(Player player, long delay) {
11 | this.player = player;
12 | this.delay = delay;
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/PlayerTickEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import lombok.Getter;
5 |
6 | public class PlayerTickEvent {
7 |
8 | public final PlayerProtocol protocol;
9 | public final long time;
10 | public final boolean legacy;
11 | public final boolean onGround;
12 | @Getter
13 | private long delay;
14 |
15 | public PlayerTickEvent(PlayerProtocol protocol, boolean legacy, boolean onGround) {
16 | this.time = System.currentTimeMillis();
17 | this.protocol = protocol;
18 | this.delay = -1;
19 | this.onGround = onGround;
20 | this.legacy = legacy;
21 | }
22 |
23 | public PlayerTickEvent build() {
24 | this.delay = this.time - this.protocol.tickTime;
25 |
26 | if (this.legacy) {
27 | // Via Version :cry:
28 | if (this.delay > 1020 && this.delay < 1060) {
29 | this.delay -= 1000;
30 | } else if (this.delay > 950) {
31 | this.delay -= 950;
32 | }
33 | }
34 | this.protocol.tickTime = this.time;
35 | return this;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/PlayerTransactionEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 |
5 | public class PlayerTransactionEvent {
6 |
7 | public final PlayerProtocol protocol;
8 | public final long time, delay;
9 |
10 | public PlayerTransactionEvent(PlayerProtocol protocol) {
11 | this.time = System.currentTimeMillis();
12 | this.protocol = protocol;
13 | this.delay = protocol.transactionPing;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/PlayerUseEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import org.bukkit.entity.LivingEntity;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Cancellable;
6 |
7 | public class PlayerUseEvent implements Cancellable {
8 |
9 | public final Player player;
10 | public final LivingEntity target;
11 | private boolean cancelled;
12 |
13 | public PlayerUseEvent(Player player, LivingEntity target, boolean cancelled) {
14 | this.player = player;
15 | this.target = target;
16 | this.cancelled = cancelled;
17 | }
18 |
19 | @Override
20 | public boolean isCancelled() {
21 | return this.cancelled;
22 | }
23 |
24 | @Override
25 | public void setCancelled(boolean b) {
26 | this.cancelled = b;
27 | }
28 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/ServerBlockChange.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import com.comphenix.protocol.wrappers.BlockPosition;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.Material;
7 |
8 | public class ServerBlockChange {
9 |
10 | public final BlockPosition position;
11 | @Setter
12 | @Getter
13 | private Material data;
14 | public int tick;
15 |
16 | public ServerBlockChange(BlockPosition position, Material data) {
17 | this.position = position;
18 | this.data = data;
19 | this.tick = 2;
20 | }
21 |
22 | public long generateHash() {
23 | return (this.position.getX() * 2L)
24 | + (this.position.getY())
25 | * (this.position.getZ() / 2L);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/event/SuperPositionPacketEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.event;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import com.comphenix.protocol.events.PacketEvent;
5 |
6 | public class SuperPositionPacketEvent {
7 |
8 | public final PlayerProtocol protocol;
9 | public final PacketEvent packetEvent;
10 |
11 | public SuperPositionPacketEvent(PlayerProtocol protocol, PacketEvent packetEvent) {
12 | this.protocol = protocol;
13 | this.packetEvent = packetEvent;
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/abstraction/protocol/ExtendedPotionEffect.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.abstraction.protocol;
2 |
3 | import ai.idealistic.spartan.functionality.server.TPS;
4 | import org.bukkit.potion.PotionEffect;
5 |
6 | public class ExtendedPotionEffect {
7 |
8 | public final PotionEffect bukkitEffect;
9 | private final long expiration;
10 |
11 | public ExtendedPotionEffect(PotionEffect effect) {
12 | this.bukkitEffect = effect;
13 | this.expiration = System.currentTimeMillis() + (effect.getDuration() * TPS.tickTime);
14 | }
15 |
16 | public long timePassed() {
17 | long remaining = this.expiration - System.currentTimeMillis();
18 | return remaining >= 0 ? 0 : Math.abs(remaining);
19 | }
20 |
21 | public boolean isActive() {
22 | return this.expiration - System.currentTimeMillis() >= 0;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/CheckCancelEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class CheckCancelEvent extends Event implements Cancellable {
13 |
14 | private final Player p;
15 | private final HackType h;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public CheckCancelEvent(Player player, HackType HackType) {
21 | p = player;
22 | h = HackType;
23 | cancelled = false;
24 | me.vagdedes.spartan.api.CheckCancelEvent event
25 | = new me.vagdedes.spartan.api.CheckCancelEvent(player, HackType);
26 | event.setCancelled(this.isCancelled());
27 | Bukkit.getPluginManager().callEvent(event);
28 | }
29 |
30 | public Player getPlayer() {
31 | return p;
32 | }
33 |
34 | public HackType getHackType() {
35 | return h;
36 | }
37 |
38 | private static final HandlerList handlers = new HandlerList();
39 |
40 | public HandlerList getHandlers() {
41 | return handlers;
42 | }
43 |
44 | public static HandlerList getHandlerList() {
45 | return handlers;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/CheckPunishmentToggleEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class CheckPunishmentToggleEvent extends Event implements Cancellable {
13 |
14 | private final CheckEnums.HackType ht;
15 | private final ToggleAction ta;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public CheckPunishmentToggleEvent(CheckEnums.HackType hackType, ToggleAction toggleAction) {
21 | ht = hackType;
22 | ta = toggleAction;
23 | cancelled = false;
24 | me.vagdedes.spartan.api.CheckPunishmentToggleEvent event
25 | = new me.vagdedes.spartan.api.CheckPunishmentToggleEvent(
26 | hackType,
27 | Enums.ToggleAction.valueOf(toggleAction.toString())
28 | );
29 | event.setCancelled(this.isCancelled());
30 | Bukkit.getPluginManager().callEvent(event);
31 | }
32 |
33 | public CheckEnums.HackType getHackType() {
34 | return ht;
35 | }
36 |
37 | public ToggleAction getToggleAction() {
38 | return ta;
39 | }
40 |
41 | private static final HandlerList handlers = new HandlerList();
42 |
43 | public HandlerList getHandlers() {
44 | return handlers;
45 | }
46 |
47 | public static HandlerList getHandlerList() {
48 | return handlers;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/CheckSilentToggleEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class CheckSilentToggleEvent extends Event implements Cancellable {
13 |
14 | private final CheckEnums.HackType ht;
15 | private final ToggleAction ta;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public CheckSilentToggleEvent(CheckEnums.HackType hackType, ToggleAction toggleAction) {
21 | ht = hackType;
22 | ta = toggleAction;
23 | cancelled = false;
24 | me.vagdedes.spartan.api.CheckSilentToggleEvent event = new me.vagdedes.spartan.api.CheckSilentToggleEvent(
25 | hackType,
26 | Enums.ToggleAction.valueOf(toggleAction.toString())
27 | );
28 | event.setCancelled(this.isCancelled());
29 | Bukkit.getPluginManager().callEvent(event);
30 | }
31 |
32 | public CheckEnums.HackType getHackType() {
33 | return ht;
34 | }
35 |
36 | public ToggleAction getToggleAction() {
37 | return ta;
38 | }
39 |
40 | private static final HandlerList handlers = new HandlerList();
41 |
42 | public HandlerList getHandlers() {
43 | return handlers;
44 | }
45 |
46 | public static HandlerList getHandlerList() {
47 | return handlers;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/CheckToggleEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class CheckToggleEvent extends Event implements Cancellable {
13 |
14 | private final CheckEnums.HackType ht;
15 | private final ToggleAction ta;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public CheckToggleEvent(CheckEnums.HackType hackType, ToggleAction toggleAction) {
21 | ht = hackType;
22 | ta = toggleAction;
23 | cancelled = false;
24 | me.vagdedes.spartan.api.CheckToggleEvent event = new me.vagdedes.spartan.api.CheckToggleEvent(
25 | hackType,
26 | Enums.ToggleAction.valueOf(toggleAction.toString())
27 | );
28 | event.setCancelled(this.isCancelled());
29 | Bukkit.getPluginManager().callEvent(event);
30 | }
31 |
32 | public CheckEnums.HackType getHackType() {
33 | return ht;
34 | }
35 |
36 | public ToggleAction getToggleAction() {
37 | return ta;
38 | }
39 |
40 | private static final HandlerList handlers = new HandlerList();
41 |
42 | public HandlerList getHandlers() {
43 | return handlers;
44 | }
45 |
46 | public static HandlerList getHandlerList() {
47 | return handlers;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/Permission.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.Register;
4 |
5 | public enum Permission {
6 | CONDITION, WAVE, ADMIN, RELOAD,
7 | KICK, BYPASS, MANAGE, INFO, WARN, USE_BYPASS,
8 | NOTIFICATIONS, BEDROCK;
9 |
10 | private final String key;
11 |
12 | Permission() {
13 | key = Register.command + "." + this.name().toLowerCase();
14 | }
15 |
16 | public String getKey() {
17 | return key;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/PlayerFoundOreEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Location;
7 | import org.bukkit.Material;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.Cancellable;
10 | import org.bukkit.event.Event;
11 | import org.bukkit.event.HandlerList;
12 |
13 | public class PlayerFoundOreEvent extends Event implements Cancellable {
14 |
15 | private final Player p;
16 | private final String me;
17 | private final Location l;
18 | private final Material ma;
19 | @Setter
20 | @Getter
21 | private boolean cancelled;
22 |
23 | public PlayerFoundOreEvent(Player player, String message, Location location, Material material) {
24 | p = player;
25 | me = message;
26 | l = location;
27 | ma = material;
28 | cancelled = false;
29 | me.vagdedes.spartan.api.PlayerFoundOreEvent event
30 | = new me.vagdedes.spartan.api.PlayerFoundOreEvent(player, message, location, material);
31 | event.setCancelled(this.isCancelled());
32 | Bukkit.getPluginManager().callEvent(event);
33 | }
34 |
35 | public Player getPlayer() {
36 | return p;
37 | }
38 |
39 | public String getMessage() {
40 | return me;
41 | }
42 |
43 | public Location getLocation() {
44 | return l;
45 | }
46 |
47 | public Material getMaterial() {
48 | return ma;
49 | }
50 |
51 | private static final HandlerList handlers = new HandlerList();
52 |
53 | public HandlerList getHandlers() {
54 | return handlers;
55 | }
56 |
57 | public static HandlerList getHandlerList() {
58 | return handlers;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/PlayerViolationCommandEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class PlayerViolationCommandEvent extends Event implements Cancellable {
13 |
14 | private final Player p;
15 | private final HackType h;
16 | private final String c;
17 | @Setter
18 | @Getter
19 | private boolean cancelled;
20 |
21 | public PlayerViolationCommandEvent(Player player, HackType HackType, String command) {
22 | p = player;
23 | h = HackType;
24 | c = command;
25 | cancelled = false;
26 | me.vagdedes.spartan.api.PlayerViolationCommandEvent event
27 | = new me.vagdedes.spartan.api.PlayerViolationCommandEvent(player, HackType, command);
28 | event.setCancelled(this.isCancelled());
29 | Bukkit.getPluginManager().callEvent(event);
30 | }
31 |
32 | public Player getPlayer() {
33 | return p;
34 | }
35 |
36 | public HackType getHackType() {
37 | return h;
38 | }
39 |
40 | public String getCommand() {
41 | return c;
42 | }
43 |
44 | private static final HandlerList handlers = new HandlerList();
45 |
46 | public HandlerList getHandlers() {
47 | return handlers;
48 | }
49 |
50 | public static HandlerList getHandlerList() {
51 | return handlers;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/PlayerViolationEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class PlayerViolationEvent extends Event implements Cancellable {
13 |
14 | private final Player p;
15 | private final HackType h;
16 | private final String m;
17 | @Setter
18 | @Getter
19 | private boolean cancelled;
20 |
21 | public PlayerViolationEvent(Player player, HackType HackType, String message) {
22 | p = player;
23 | h = HackType;
24 | m = message;
25 | cancelled = false;
26 | me.vagdedes.spartan.api.PlayerViolationEvent event
27 | = new me.vagdedes.spartan.api.PlayerViolationEvent(player, HackType, message);
28 | event.setCancelled(this.isCancelled());
29 | Bukkit.getPluginManager().callEvent(event);
30 | }
31 |
32 | public Player getPlayer() {
33 | return p;
34 | }
35 |
36 | public HackType getHackType() {
37 | return h;
38 | }
39 |
40 | public String getMessage() {
41 | return m;
42 | }
43 |
44 | private static final HandlerList handlers = new HandlerList();
45 |
46 | public HandlerList getHandlers() {
47 | return handlers;
48 | }
49 |
50 | public static HandlerList getHandlerList() {
51 | return handlers;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/SpartanReloadEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import org.bukkit.Bukkit;
5 | import org.bukkit.event.Cancellable;
6 | import org.bukkit.event.Event;
7 | import org.bukkit.event.HandlerList;
8 | import org.bukkit.plugin.Plugin;
9 |
10 | public class SpartanReloadEvent extends Event implements Cancellable {
11 |
12 | private boolean cancelled;
13 |
14 | public SpartanReloadEvent() {
15 | cancelled = false;
16 | me.vagdedes.spartan.api.SpartanReloadEvent event = new me.vagdedes.spartan.api.SpartanReloadEvent();
17 | event.setCancelled(this.isCancelled());
18 | Bukkit.getPluginManager().callEvent(event);
19 | }
20 |
21 | public Plugin getPlugin() {
22 | return Register.plugin;
23 | }
24 |
25 | public boolean isCancelled() {
26 | return cancelled;
27 | }
28 |
29 | public void setCancelled(boolean b) {
30 | this.cancelled = b;
31 | }
32 |
33 | private static final HandlerList handlers = new HandlerList();
34 |
35 | public HandlerList getHandlers() {
36 | return handlers;
37 | }
38 |
39 | public static HandlerList getHandlerList() {
40 | return handlers;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/api/ToggleAction.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.api;
2 |
3 | public enum ToggleAction {
4 | ENABLE, DISABLE
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/AdvancedAbilities.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import be.anybody.api.advancedabilities.ability.event.AbilityCallEvent;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | public class AdvancedAbilities implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST)
15 | private void AbilityEvent(AbilityCallEvent e) {
16 | if (Compatibility.CompatibilityType.ADVANCED_ABILITIES.isFunctional()) {
17 | Config.compatibility.evadeFalsePositives(
18 | PluginBase.getProtocol(e.getPlayer()),
19 | Compatibility.CompatibilityType.ADVANCED_ABILITIES,
20 | new CheckEnums.HackCategoryType[]{
21 | CheckEnums.HackCategoryType.MOVEMENT,
22 | CheckEnums.HackCategoryType.COMBAT
23 | },
24 | 60
25 | );
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/AureliumSkills.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.data.Cooldowns;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.compatibility.Compatibility;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import ai.idealistic.spartan.utils.java.OverflowMap;
8 | import com.archyx.aureliumskills.api.event.TerraformBlockBreakEvent;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 |
13 | import java.util.LinkedHashMap;
14 |
15 | public class AureliumSkills implements Listener {
16 |
17 | private static final Cooldowns cooldowns = new Cooldowns(
18 | new OverflowMap<>(new LinkedHashMap<>(), 512)
19 | );
20 |
21 | @EventHandler(priority = EventPriority.HIGHEST)
22 | private void Event(TerraformBlockBreakEvent e) {
23 | if (Compatibility.CompatibilityType.AURELIUM_SKILLS.isEnabled()) {
24 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer());
25 | cooldowns.add(protocol.getUUID() + "=aureliumskills=compatibility", 20);
26 | }
27 | }
28 |
29 | public static boolean isUsing(PlayerProtocol p) {
30 | return Compatibility.CompatibilityType.AURELIUM_SKILLS.isFunctional()
31 | && !cooldowns.canDo(p.getUUID() + "=aureliumskills=compatibility");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/GrapplingHook.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.compatibility.Compatibility;
6 | import ai.idealistic.spartan.functionality.server.Config;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import ai.idealistic.spartan.utils.minecraft.server.PluginUtils;
9 | import com.snowgears.grapplinghook.api.HookAPI;
10 | import org.bukkit.Material;
11 | import org.bukkit.entity.Entity;
12 | import org.bukkit.entity.Player;
13 | import org.bukkit.event.EventHandler;
14 | import org.bukkit.event.EventPriority;
15 | import org.bukkit.event.Listener;
16 | import org.bukkit.event.player.PlayerFishEvent;
17 | import org.bukkit.inventory.ItemStack;
18 |
19 | public class GrapplingHook implements Listener {
20 |
21 | private final static String name = "grapplinghook";
22 |
23 | private static boolean isItem(ItemStack i) {
24 | if (Compatibility.CompatibilityType.GRAPPLING_HOOK.isFunctional()) {
25 | try {
26 | return PluginUtils.exists(name) ? HookAPI.isGrapplingHook(i) : i.getType() == Material.FISHING_ROD;
27 | } catch (Exception ignored) {
28 | }
29 | }
30 | return false;
31 | }
32 |
33 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
34 | private void Event(PlayerFishEvent e) {
35 | if (Compatibility.CompatibilityType.GRAPPLING_HOOK.isFunctional() && e.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) {
36 | Entity caught = e.getCaught();
37 |
38 | if (caught instanceof Player) {
39 | PlayerProtocol p = PluginBase.getProtocol((Player) caught),
40 | t = PluginBase.getProtocol(e.getPlayer());
41 |
42 | if (!p.equals(t) && isItem(t.getItemInHand())) {
43 | if (PluginUtils.exists(name)) {
44 | Config.compatibility.evadeFalsePositives(
45 | p,
46 | Compatibility.CompatibilityType.GRAPPLING_HOOK,
47 | new CheckEnums.HackCategoryType[]{
48 | CheckEnums.HackCategoryType.MOVEMENT,
49 | CheckEnums.HackCategoryType.COMBAT
50 | },
51 | 40
52 | );
53 | } else {
54 | Config.compatibility.evadeFalsePositives(
55 | p,
56 | Compatibility.CompatibilityType.GRAPPLING_HOOK,
57 | new CheckEnums.HackCategoryType[]{
58 | CheckEnums.HackCategoryType.MOVEMENT,
59 | CheckEnums.HackCategoryType.COMBAT
60 | },
61 | 10
62 | );
63 | }
64 | }
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/ItemsAdder.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.MultiVersion;
6 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
7 | import dev.lone.itemsadder.api.CustomBlock;
8 | import dev.lone.itemsadder.api.CustomMob;
9 | import dev.lone.itemsadder.api.CustomStack;
10 | import org.bukkit.block.Block;
11 | import org.bukkit.entity.Entity;
12 | import org.bukkit.inventory.ItemStack;
13 | import org.bukkit.inventory.PlayerInventory;
14 |
15 | public class ItemsAdder {
16 |
17 | private static final boolean classExists = ReflectionUtils.classExists("me.libraryaddict.disguise.DisguiseAPI");
18 |
19 | public static boolean is(PlayerProtocol protocol) {
20 | if (classExists && Compatibility.CompatibilityType.ITEMS_ADDER.isFunctional()) {
21 | PlayerInventory inventory = protocol.getInventory();
22 |
23 | for (ItemStack armor : inventory.getArmorContents()) {
24 | if (armor != null && is(armor)) {
25 | return true;
26 | }
27 | }
28 | return is(inventory.getItemInHand())
29 | || MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)
30 | && is(inventory.getItemInOffHand());
31 | }
32 | return false;
33 | }
34 |
35 | public static boolean is(Block block) {
36 | return classExists && Compatibility.CompatibilityType.ITEMS_ADDER.isFunctional()
37 | && CustomBlock.byAlreadyPlaced(block) != null;
38 | }
39 |
40 | private static boolean is(ItemStack itemStack) {
41 | return classExists && Compatibility.CompatibilityType.ITEMS_ADDER.isFunctional()
42 | && CustomStack.getInstance(itemStack.getType().toString()) != null;
43 | }
44 |
45 | public static boolean is(Entity entity) {
46 | return classExists && Compatibility.CompatibilityType.ITEMS_ADDER.isFunctional()
47 | && CustomMob.byAlreadySpawned(entity) != null;
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/MagicSpells.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.nisovin.magicspells.events.SpellCastEvent;
8 | import com.nisovin.magicspells.events.SpellCastedEvent;
9 | import org.bukkit.entity.LivingEntity;
10 | import org.bukkit.entity.Player;
11 | import org.bukkit.event.EventHandler;
12 | import org.bukkit.event.EventPriority;
13 | import org.bukkit.event.Listener;
14 |
15 | public class MagicSpells implements Listener {
16 |
17 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
18 | private void SpellCast(SpellCastEvent e) {
19 | if (Compatibility.CompatibilityType.MAGIC_SPELLS.isFunctional()) {
20 | LivingEntity caster = e.getCaster();
21 |
22 | if (caster instanceof Player) {
23 | Config.compatibility.evadeFalsePositives(
24 | PluginBase.getProtocol((Player) caster),
25 | Compatibility.CompatibilityType.MAGIC_SPELLS,
26 | new CheckEnums.HackCategoryType[]{
27 | CheckEnums.HackCategoryType.MOVEMENT,
28 | CheckEnums.HackCategoryType.COMBAT
29 | },
30 | 40
31 | );
32 | }
33 | }
34 | }
35 |
36 | @EventHandler
37 | private void SpellCasted(SpellCastedEvent e) {
38 | if (Compatibility.CompatibilityType.MAGIC_SPELLS.isFunctional()) {
39 | LivingEntity caster = e.getCaster();
40 |
41 | if (caster instanceof Player) {
42 | Config.compatibility.evadeFalsePositives(
43 | PluginBase.getProtocol((Player) caster),
44 | Compatibility.CompatibilityType.MAGIC_SPELLS,
45 | new CheckEnums.HackCategoryType[]{
46 | CheckEnums.HackCategoryType.MOVEMENT,
47 | CheckEnums.HackCategoryType.COMBAT
48 | },
49 | 40
50 | );
51 | }
52 | }
53 | }
54 |
55 | /*@EventHandler
56 | private void Spell(SpellEvent e) {
57 | }*/
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/MineTinker.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import de.flo56958.minetinker.events.MTPlayerInteractEvent;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | public class MineTinker implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
15 | private void Enter(MTPlayerInteractEvent e) {
16 | Compatibility.CompatibilityType compatibilityType = Compatibility.CompatibilityType.MINE_TINKER;
17 |
18 | if (compatibilityType.isFunctional()) {
19 | Config.compatibility.evadeFalsePositives(
20 | PluginBase.getProtocol(e.getPlayer()),
21 | compatibilityType,
22 | new CheckEnums.HackType[]{
23 | CheckEnums.HackType.KILL_AURA,
24 | CheckEnums.HackType.FAST_CLICKS,
25 | CheckEnums.HackType.HIT_REACH,
26 | CheckEnums.HackType.FAST_PLACE
27 | },
28 | 40
29 | );
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/abilities/ProjectKorra.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.abilities;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.compatibility.Compatibility;
6 | import ai.idealistic.spartan.functionality.server.Config;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import com.projectkorra.projectkorra.event.AbilityDamageEntityEvent;
9 | import com.projectkorra.projectkorra.event.AbilityProgressEvent;
10 | import com.projectkorra.projectkorra.event.AbilityStartEvent;
11 | import org.bukkit.entity.Entity;
12 | import org.bukkit.entity.Player;
13 | import org.bukkit.event.EventHandler;
14 | import org.bukkit.event.EventPriority;
15 | import org.bukkit.event.Listener;
16 |
17 | public class ProjectKorra implements Listener {
18 |
19 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
20 | private void AbilityStart(AbilityStartEvent e) {
21 | if (Compatibility.CompatibilityType.PROJECT_KORRA.isFunctional()) {
22 | evadeCombatFPs(PluginBase.getProtocol(e.getAbility().getPlayer()), 60);
23 | }
24 | }
25 |
26 | @EventHandler
27 | private void AbilityProgress(AbilityProgressEvent e) {
28 | if (Compatibility.CompatibilityType.PROJECT_KORRA.isFunctional()) {
29 | evadeCombatFPs(PluginBase.getProtocol(e.getAbility().getPlayer()), 40);
30 | }
31 | }
32 |
33 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
34 | private void AbilityDamageEvent(AbilityDamageEntityEvent e) {
35 | if (Compatibility.CompatibilityType.PROJECT_KORRA.isFunctional()) {
36 | Entity entity = e.getEntity();
37 |
38 | if (entity instanceof Player) {
39 | evadeCombatFPs(
40 | PluginBase.getProtocol((Player) entity),
41 | 60
42 | );
43 | }
44 | }
45 | }
46 |
47 | private static void evadeCombatFPs(PlayerProtocol protocol, int ticks) {
48 | Compatibility.CompatibilityType compatibilityType = Compatibility.CompatibilityType.PROJECT_KORRA;
49 | Config.compatibility.evadeFalsePositives(
50 | protocol,
51 | compatibilityType,
52 | new CheckEnums.HackCategoryType[]{
53 | CheckEnums.HackCategoryType.MOVEMENT,
54 | CheckEnums.HackCategoryType.COMBAT
55 | },
56 | ticks
57 | );
58 | Config.compatibility.evadeFalsePositives(
59 | protocol,
60 | compatibilityType,
61 | CheckEnums.HackType.NO_SWING,
62 | ticks
63 | );
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/MineBomb.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import org.bukkit.Material;
6 | import org.bukkit.configuration.file.YamlConfiguration;
7 |
8 | import java.io.File;
9 | import java.util.HashSet;
10 | import java.util.Set;
11 |
12 | public class MineBomb {
13 |
14 | private static final Set hs = new HashSet<>();
15 |
16 | public static void reload() {
17 | hs.clear();
18 | }
19 |
20 | public static boolean isUsing(PlayerProtocol p) {
21 | if (Compatibility.CompatibilityType.MINE_BOMB.isFunctional()) {
22 | if (cacheCanUse(p)) {
23 | return true;
24 | }
25 | File file = new File("plugins/MineBomb/config.yml");
26 |
27 | if (file.exists()) {
28 | boolean result = false;
29 | YamlConfiguration filea = YamlConfiguration.loadConfiguration(file);
30 |
31 | for (String key : filea.getKeys(true)) {
32 | if (key.endsWith(".item")) {
33 | Material m = Material.getMaterial(filea.getString(key));
34 |
35 | if (m != null) {
36 | hs.add(m);
37 | result = true;
38 | }
39 | }
40 | }
41 | return result;
42 | }
43 | }
44 | return false;
45 | }
46 |
47 | private static boolean cacheCanUse(PlayerProtocol p) {
48 | for (Material m : hs) {
49 | if (p.getItemInHand().getType() == m) {
50 | return true;
51 | }
52 | }
53 | return false;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/PrinterMode.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import me.gwndaan.printer.PrinterModeAPI;
6 |
7 | public class PrinterMode {
8 |
9 | public static boolean isUsing(PlayerProtocol p) {
10 | return Compatibility.CompatibilityType.PRINTER_MODE.isFunctional()
11 | && PrinterModeAPI.isInPrinterMode(p.bukkit());
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/RampenDrills.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import me.rampen88.drills.events.DrillBreakEvent;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | public class RampenDrills implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
15 | private void Event(DrillBreakEvent e) {
16 | Compatibility.CompatibilityType compatibilityType = Compatibility.CompatibilityType.RAMPEN_DRILLS;
17 |
18 | if (compatibilityType.isFunctional()) {
19 | Config.compatibility.evadeFalsePositives(
20 | PluginBase.getProtocol(e.getPlayer()),
21 | compatibilityType,
22 | new CheckEnums.HackType[]{
23 | CheckEnums.HackType.FAST_BREAK,
24 | CheckEnums.HackType.NO_SWING,
25 | CheckEnums.HackType.IMPOSSIBLE_ACTIONS,
26 | },
27 | 5
28 | );
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/SuperPickaxe.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.utils.minecraft.entity.PlayerUtils;
6 |
7 | public class SuperPickaxe {
8 |
9 | public static boolean isUsing(PlayerProtocol p) {
10 | return Compatibility.CompatibilityType.SUPER_PICKAXE.isFunctional()
11 | && PlayerUtils.isPickaxeItem(p.getItemInHand().getType());
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/TreeFeller.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.compatibility.Compatibility;
4 | import ai.idealistic.spartan.utils.minecraft.world.BlockUtils;
5 | import org.bukkit.block.Block;
6 |
7 | public class TreeFeller {
8 |
9 | public static boolean canCancel(Block b) {
10 | return Compatibility.CompatibilityType.TREE_FELLER.isFunctional()
11 | && BlockUtils.areWoods(b.getType());
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/VeinMiner.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
5 | import ai.idealistic.spartan.compatibility.Compatibility;
6 | import ai.idealistic.spartan.functionality.server.Config;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import ai.idealistic.spartan.functionality.server.TPS;
9 | import ai.idealistic.spartan.utils.math.AlgebraUtils;
10 | import org.bukkit.event.EventHandler;
11 | import org.bukkit.event.EventPriority;
12 | import org.bukkit.event.Listener;
13 | import wtf.choco.veinminer.api.event.player.PlayerClientActivateVeinMinerEvent;
14 | import wtf.choco.veinminer.api.event.player.PlayerVeinMineEvent;
15 |
16 | public class VeinMiner implements Listener {
17 |
18 | public static void reload() {
19 | Register.enable(new VeinMiner());
20 | }
21 |
22 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
23 | private void Event(PlayerVeinMineEvent e) {
24 | if (Compatibility.CompatibilityType.VEIN_MINER.isFunctional()) {
25 | Config.compatibility.evadeFalsePositives(
26 | PluginBase.getProtocol(e.getPlayer()),
27 | Compatibility.CompatibilityType.VEIN_MINER,
28 | new CheckEnums.HackType[]{
29 | CheckEnums.HackType.NO_SWING,
30 | CheckEnums.HackType.FAST_BREAK,
31 | CheckEnums.HackType.IMPOSSIBLE_ACTIONS,
32 | CheckEnums.HackType.BLOCK_REACH,
33 | CheckEnums.HackType.FAST_PLACE
34 | },
35 | AlgebraUtils.integerRound(TPS.maximum)
36 | );
37 | }
38 | }
39 |
40 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
41 | private void Event(PlayerClientActivateVeinMinerEvent e) {
42 | if (Compatibility.CompatibilityType.VEIN_MINER.isFunctional()) {
43 | Config.compatibility.evadeFalsePositives(
44 | PluginBase.getProtocol(e.getPlayer()),
45 | Compatibility.CompatibilityType.VEIN_MINER,
46 | new CheckEnums.HackType[]{
47 | CheckEnums.HackType.NO_SWING,
48 | CheckEnums.HackType.FAST_BREAK,
49 | CheckEnums.HackType.IMPOSSIBLE_ACTIONS,
50 | CheckEnums.HackType.BLOCK_REACH,
51 | CheckEnums.HackType.FAST_PLACE
52 | },
53 | AlgebraUtils.integerRound(TPS.maximum)
54 | );
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/building/WildTools.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.building;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.bgsoftware.wildtools.api.events.ToolUseEvent;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | public class WildTools implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST)
15 | private void Event(ToolUseEvent e) {
16 | Compatibility.CompatibilityType compatibilityType = Compatibility.CompatibilityType.WILD_TOOLS;
17 |
18 | if (compatibilityType.isFunctional()) {
19 | Config.compatibility.evadeFalsePositives(
20 | PluginBase.getProtocol(e.getPlayer()),
21 | compatibilityType,
22 | new CheckEnums.HackType[]{
23 | CheckEnums.HackType.FAST_BREAK,
24 | CheckEnums.HackType.BLOCK_REACH,
25 | CheckEnums.HackType.IMPOSSIBLE_ACTIONS,
26 | },
27 | 40
28 | );
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/damage/RealDualWield.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.damage;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.evill4mer.RealDualWield.Api.PlayerOffhandAnimationEvent;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 |
12 | public class RealDualWield implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
15 | private void Event(PlayerOffhandAnimationEvent e) {
16 | Compatibility.CompatibilityType compatibilityType = Compatibility.CompatibilityType.REAL_DUAL_WIELD;
17 |
18 | if (compatibilityType.isFunctional()) {
19 | Config.compatibility.evadeFalsePositives(
20 | PluginBase.getProtocol(e.getPlayer()),
21 | compatibilityType,
22 | new CheckEnums.HackType[]{
23 | CheckEnums.HackType.KILL_AURA,
24 | CheckEnums.HackType.HIT_REACH,
25 | CheckEnums.HackType.CRITICALS,
26 | },
27 | 5
28 | );
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/enchants/CustomEnchantsPlus.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.enchants;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.MultiVersion;
6 | import me.darrionat.CustomEnchantsAPI;
7 | import org.bukkit.enchantments.Enchantment;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | public class CustomEnchantsPlus {
12 |
13 | public static boolean has(PlayerProtocol protocol) {
14 | if (Compatibility.CompatibilityType.CUSTOM_ENCHANTS_PLUS.isFunctional()) {
15 | PlayerInventory inventory = protocol.getInventory();
16 |
17 | for (ItemStack armor : inventory.getArmorContents()) {
18 | if (armor != null && has(armor)) {
19 | return true;
20 | }
21 | }
22 | return has(inventory.getItemInHand())
23 | || MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)
24 | && has(inventory.getItemInOffHand());
25 | }
26 | return false;
27 | }
28 |
29 | private static boolean has(ItemStack item) {
30 | if (item.hasItemMeta()) {
31 | for (Enchantment enchantment : item.getItemMeta().getEnchants().keySet()) {
32 | if (CustomEnchantsAPI.isCustomEnchantment(enchantment)) {
33 | return true;
34 | }
35 | }
36 | }
37 | return false;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/enchants/EcoEnchants.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.enchants;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.functionality.server.MultiVersion;
6 | import com.willfp.ecoenchants.enchants.EcoEnchant;
7 | import org.bukkit.enchantments.Enchantment;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.PlayerInventory;
10 |
11 | public class EcoEnchants {
12 |
13 | public static boolean has(PlayerProtocol protocol) {
14 | if (Compatibility.CompatibilityType.ECO_ENCHANTS.isFunctional()) {
15 | PlayerInventory inventory = protocol.getInventory();
16 |
17 | for (ItemStack armor : inventory.getArmorContents()) {
18 | if (armor != null && has(armor)) {
19 | return true;
20 | }
21 | }
22 | return has(inventory.getItemInHand())
23 | || MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)
24 | && has(inventory.getItemInOffHand());
25 | }
26 | return false;
27 | }
28 |
29 | private static boolean has(ItemStack item) {
30 | if (item.hasItemMeta()) {
31 | for (Enchantment enchantment : item.getItemMeta().getEnchants().keySet()) {
32 | if (enchantment instanceof EcoEnchant) {
33 | return true;
34 | }
35 | }
36 | }
37 | return false;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/entity/CraftBook.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.entity;
2 |
3 | import ai.idealistic.spartan.compatibility.Compatibility;
4 | import org.bukkit.configuration.file.YamlConfiguration;
5 |
6 | import java.io.File;
7 |
8 | public class CraftBook {
9 |
10 | private static double limit = -1.0;
11 |
12 | public static void resetBoatLimit() {
13 | limit = -1.0;
14 | }
15 |
16 | public static double getBoatLimit() {
17 | if (limit != -1.0) {
18 | return limit;
19 | }
20 | if (Compatibility.CompatibilityType.CRAFT_BOOK.isFunctional()) {
21 | File file = new File("plugins/CraftBook/mechanisms.yml");
22 |
23 | if (file.exists()) {
24 | YamlConfiguration filea = YamlConfiguration.loadConfiguration(file);
25 | double value = filea.getDouble("mechanics.BoatSpeedModifiers.max-speed");
26 |
27 | if (value < 0.0) {
28 | value = 0.1;
29 | } else {
30 | value += 0.1;
31 | }
32 | limit = value;
33 | return value;
34 | }
35 | }
36 | return limit = 0.0;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/manual/entity/Vehicles.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.manual.entity;
2 |
3 | import ai.idealistic.spartan.abstraction.data.Cooldowns;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.compatibility.Compatibility;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import ai.idealistic.spartan.utils.java.OverflowMap;
8 | import es.pollitoyeye.vehicles.enums.VehicleType;
9 | import es.pollitoyeye.vehicles.events.VehicleEnterEvent;
10 | import es.pollitoyeye.vehicles.events.VehicleExitEvent;
11 | import org.bukkit.event.EventHandler;
12 | import org.bukkit.event.EventPriority;
13 | import org.bukkit.event.Listener;
14 |
15 | import java.util.LinkedHashMap;
16 |
17 | public class Vehicles implements Listener {
18 |
19 | private static final Cooldowns cooldowns = new Cooldowns(
20 | new OverflowMap<>(new LinkedHashMap<>(), 512)
21 | );
22 | private static final String key = Compatibility.CompatibilityType.VEHICLES + "=compatibility=";
23 | public static final String
24 | DRILL = "drill",
25 | TRACTOR = "tractor";
26 | private static final String[] types = new String[]{
27 | DRILL,
28 | TRACTOR
29 | };
30 |
31 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
32 | private void Enter(VehicleEnterEvent e) {
33 | if (Compatibility.CompatibilityType.VEHICLES.isFunctional()) {
34 | PlayerProtocol p = PluginBase.getProtocol(e.getPlayer());
35 | VehicleType vehicleType = e.getVehicleType();
36 |
37 | if (vehicleType == VehicleType.DRILL) {
38 | add(p, Vehicles.DRILL);
39 | } else if (vehicleType == VehicleType.TRACTOR) {
40 | add(p, Vehicles.TRACTOR);
41 | }
42 | }
43 | }
44 |
45 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
46 | private void Exit(VehicleExitEvent e) {
47 | if (Compatibility.CompatibilityType.VEHICLES.isFunctional()) {
48 | PlayerProtocol p = PluginBase.getProtocol(e.getPlayer());
49 |
50 | for (String type : types) {
51 | cooldowns.remove(key(p, type));
52 | }
53 | }
54 | }
55 |
56 | private static String key(PlayerProtocol p, String type) {
57 | return p.getUUID() + "=" + key + type;
58 | }
59 |
60 | private static void add(PlayerProtocol p, String type) {
61 | cooldowns.add(key(p, type), 20);
62 | }
63 |
64 | public static boolean has(PlayerProtocol p, String type) {
65 | return !cooldowns.canDo(key(p, type));
66 | }
67 |
68 | public static boolean has(PlayerProtocol p, String[] types) {
69 | for (String type : types) {
70 | if (has(p, type)) {
71 | return true;
72 | }
73 | }
74 | return false;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/necessary/BedrockCompatibility.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.necessary;
2 |
3 | import ai.idealistic.spartan.api.Permission;
4 | import ai.idealistic.spartan.compatibility.necessary.protocollib.ProtocolLib;
5 | import ai.idealistic.spartan.functionality.server.Config;
6 | import ai.idealistic.spartan.functionality.server.Permissions;
7 | import org.bukkit.entity.Player;
8 |
9 | public class BedrockCompatibility {
10 |
11 | public static boolean isPlayer(Player p) {
12 | return ProtocolSupport.isBedrockPlayer(p)
13 |
14 | || !ProtocolLib.isTemporary(p)
15 | && Floodgate.isBedrockPlayer(p.getUniqueId(), p.getName())
16 |
17 | || Config.settings.getBoolean("Important.bedrock_client_permission")
18 | && Permissions.onlyHas(p, Permission.BEDROCK);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/necessary/Floodgate.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.necessary;
2 |
3 | import ai.idealistic.spartan.compatibility.Compatibility;
4 | import ai.idealistic.spartan.functionality.server.Config;
5 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
6 | import org.geysermc.floodgate.api.FloodgateApi;
7 |
8 | import java.util.UUID;
9 |
10 | public class Floodgate {
11 |
12 | private static boolean classExists = false;
13 |
14 | public static void reload() {
15 | classExists = ReflectionUtils.classExists(
16 | "org.geysermc.floodgate.api.FloodgateApi"
17 | );
18 | }
19 |
20 | static boolean isBedrockPlayer(UUID uuid, String name) {
21 | return Compatibility.CompatibilityType.FLOODGATE.isFunctional()
22 | && classExists
23 | && FloodgateApi.getInstance().isFloodgatePlayer(uuid)
24 |
25 | || name != null && isBedrockPlayer(name);
26 | }
27 |
28 | private static boolean isBedrockPlayer(String name) {
29 | String prefix = Config.settings.getString("Important.bedrock_player_prefix");
30 | return !prefix.isEmpty() && name.startsWith(prefix);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/necessary/ProtocolSupport.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.necessary;
2 |
3 | import ai.idealistic.spartan.compatibility.Compatibility;
4 | import org.bukkit.entity.Player;
5 | import protocolsupport.api.Connection;
6 | import protocolsupport.api.ProtocolSupportAPI;
7 |
8 | public class ProtocolSupport {
9 |
10 | static boolean isBedrockPlayer(Player p) {
11 | if (Compatibility.CompatibilityType.PROTOCOL_SUPPORT.isFunctional()) {
12 | try {
13 | Connection c = ProtocolSupportAPI.getConnection(p);
14 | return c != null && c.getVersion().toString().contains("_PE_");
15 | } catch (Exception ignored) {
16 | }
17 | }
18 | return false;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/compatibility/necessary/protocollib/BackgroundProtocolLib.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.compatibility.necessary.protocollib;
2 |
3 | import ai.idealistic.spartan.functionality.server.MultiVersion;
4 | import ai.idealistic.spartan.listeners.protocol.*;
5 | import ai.idealistic.spartan.listeners.protocol.combat.CombatListener;
6 | import ai.idealistic.spartan.listeners.protocol.combat.LegacyCombatListener;
7 | import ai.idealistic.spartan.listeners.protocol.standalone.EntityActionListener;
8 | import ai.idealistic.spartan.listeners.protocol.standalone.JoinListener;
9 | import ai.idealistic.spartan.utils.minecraft.entity.PlayerUtils;
10 | import com.comphenix.protocol.PacketType;
11 | import com.comphenix.protocol.ProtocolLibrary;
12 | import com.comphenix.protocol.ProtocolManager;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 | public class BackgroundProtocolLib {
18 |
19 | private static final List packets = new ArrayList<>();
20 |
21 | static boolean isPacketSupported(String packet) {
22 | return packets.contains(packet);
23 | }
24 |
25 | private static void handle() {
26 | for (PacketType type : PacketType.Play.Client.getInstance()) {
27 | packets.add(type.name());
28 | }
29 | }
30 |
31 | static void run() {
32 | handle();
33 | ProtocolManager p = ProtocolLibrary.getProtocolManager();
34 | p.addPacketListener(new JoinListener());
35 | p.addPacketListener(new EntityActionListener());
36 | p.addPacketListener(new VelocityListener());
37 |
38 | if (MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_17)) {
39 | p.addPacketListener(new CombatListener());
40 | } else {
41 | p.addPacketListener(new LegacyCombatListener());
42 | }
43 |
44 | if (MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_13)) {
45 | p.addPacketListener(new MultiBlockListener());
46 | } else {
47 | p.addPacketListener(new MultiBlockLegacyListener());
48 | }
49 |
50 | p.addPacketListener(new MovementListener());
51 | p.addPacketListener(new TeleportListener());
52 | p.addPacketListener(new VehicleHandle());
53 | p.addPacketListener(new DeathListener());
54 | //p.addPacketListener(new BlockPlaceBalancerListener());
55 | p.addPacketListener(new BlockPlaceListener());
56 | p.addPacketListener(new ClicksListener());
57 | p.addPacketListener(new PacketPistonHandle());
58 | p.addPacketListener(new ExplosionListener());
59 | p.addPacketListener(new PacketServerBlockHandle());
60 | p.addPacketListener(new PacketLatencyHandler());
61 | p.addPacketListener(new AbilitiesListener());
62 | p.addPacketListener(new UseItemStatusHandle());
63 | p.addPacketListener(new UseEntityListener());
64 |
65 | if (PlayerUtils.trident) {
66 | p.addPacketListener(new TridentListener());
67 | }
68 | if (false) {
69 | p.addPacketListener(new PacketDebug());
70 | }
71 | }
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/connection/DiscordServer.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.connection;
2 |
3 | public class DiscordServer {
4 |
5 | public static final String url = "https://www.idealistic.ai/discord/spartan";
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/connection/IDs.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.connection;
2 |
3 | import ai.idealistic.spartan.utils.math.AlgebraUtils;
4 |
5 | import java.util.Objects;
6 |
7 | public class IDs {
8 |
9 | public static final String
10 | user = "%%__USER__%%",
11 | file = "%%__NONCE__%%",
12 | resource = "%%__RESOURCE__%%";
13 | public static final boolean
14 | enabled = AlgebraUtils.validInteger(resource),
15 | builtByBit = "%%__BUILTBYBIT__%%".length() != 18,
16 | polymart = "%%__POLYMART__%%".length() == 1,
17 | spigot = !builtByBit && !polymart && enabled;
18 | private static String
19 | userModified = null,
20 | fileModified = null;
21 |
22 | static void set(int user, int nonce) {
23 | IDs.userModified = Integer.toString(user);
24 | IDs.fileModified = Integer.toString(nonce);
25 | }
26 |
27 | public static String user() {
28 | return userModified != null ? userModified : user;
29 | }
30 |
31 | public static String file() {
32 | if (IDs.enabled) {
33 | String f = fileModified != null ? fileModified : file;
34 |
35 | if (!f.startsWith("%%__")
36 | && !AlgebraUtils.validInteger(f)) {
37 | f = String.valueOf(Objects.hash(f));
38 | }
39 | return f;
40 | } else {
41 | return user();
42 | }
43 | }
44 |
45 | static String platform() {
46 | return IDs.builtByBit ? "BuiltByBit" : IDs.polymart ? "Polymart" : IDs.spigot ? "SpigotMC" : "Free";
47 | }
48 |
49 | public static boolean canAdvertise() {
50 | return !IDs.enabled || IDs.builtByBit || IDs.polymart;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/connection/JarVerification.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.connection;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.moderation.AwarenessNotifications;
5 | import ai.idealistic.spartan.functionality.server.Permissions;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import ai.idealistic.spartan.utils.java.RequestUtils;
8 | import ai.idealistic.spartan.utils.java.StringUtils;
9 | import org.bukkit.Bukkit;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | import java.util.List;
13 |
14 | public class JarVerification {
15 |
16 | static final String website = "aHR0cHM6Ly93d3cudmFnZGVkZXMuY29tL21pbmVjcmFmdC9jbG91ZC8=";
17 | private static boolean valid = true;
18 |
19 | public static void run(Plugin plugin) {
20 | if (!IDs.enabled) {
21 | PluginBase.connectionThread.execute(() -> {
22 | int userID = CloudConnections.getUserIdentification();
23 |
24 | if (userID <= 0) {
25 | valid = false;
26 | }
27 | });
28 | }
29 |
30 | if (IDs.enabled) {
31 | if (isValid(plugin)) {
32 | PluginAddons.refresh();
33 | } else {
34 | Bukkit.getPluginManager().disablePlugin(plugin);
35 | }
36 | } else {
37 | PluginAddons.refresh();
38 |
39 | if (!isValid(plugin)) {
40 | String message = "This version of " + plugin.getName() + " does not have a license."
41 | + " If this download is pirated, please consider purchasing the plugin"
42 | + " when your server starts making enough money. We also sell on BuiltByBit"
43 | + " which supports many payment methods for all countries including yours.";
44 | List staff = Permissions.getStaff();
45 |
46 | if (!staff.isEmpty()) {
47 | for (PlayerProtocol protocol : staff) {
48 | protocol.sendImportantMessage(AwarenessNotifications.getNotification(message));
49 | }
50 | }
51 | AwarenessNotifications.forcefullySend(message);
52 | }
53 | }
54 | }
55 |
56 | private static boolean isValid(Plugin plugin) {
57 | boolean b = valid
58 | && plugin.getDescription().getAuthors().toString().startsWith("[Evangelos Dedes @Vagdedes");
59 |
60 | try {
61 | String[] results = RequestUtils.get(StringUtils.decodeBase64(website)
62 | + "?" + CloudBase.identification() + "&action=add&data=userVerification");
63 |
64 | if (results.length > 0) {
65 | String line = results[0];
66 |
67 | if (line.equalsIgnoreCase(String.valueOf(false))) {
68 | valid = false;
69 | return false;
70 | }
71 | }
72 | } catch (Exception e) {
73 | if (IDs.canAdvertise()) {
74 | AwarenessNotifications.forcefullySend(e.getMessage());
75 | }
76 | }
77 | return b;
78 | }
79 |
80 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/moderation/clickable/BackgroundClickableMessage.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.moderation.clickable;
2 |
3 | import net.md_5.bungee.api.chat.ClickEvent;
4 | import net.md_5.bungee.api.chat.ComponentBuilder;
5 | import net.md_5.bungee.api.chat.HoverEvent;
6 | import net.md_5.bungee.api.chat.TextComponent;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 |
10 | public class BackgroundClickableMessage {
11 |
12 | static boolean send(CommandSender p, String message, String preview, String command, boolean handle) {
13 | try {
14 | if (p instanceof Player) {
15 | TextComponent clickable = new TextComponent();
16 | clickable.setText(message);
17 | clickable.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(preview).create()));
18 |
19 | if (command != null) {
20 | clickable.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
21 | }
22 | ((Player) p).spigot().sendMessage(clickable);
23 | } else {
24 | p.sendMessage(message);
25 | }
26 | return true;
27 | } catch (Exception ex) {
28 | if (handle) {
29 | p.sendMessage(message);
30 | }
31 | }
32 | return false;
33 | }
34 |
35 | static boolean sendURL(CommandSender p, String message, String preview, String url, boolean handle) {
36 | try {
37 | if (p instanceof Player) {
38 | TextComponent clickable = new TextComponent();
39 | clickable.setText(message);
40 | clickable.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
41 | clickable.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(preview).create()));
42 | ((Player) p).spigot().sendMessage(clickable);
43 | } else {
44 | p.sendMessage(message);
45 | }
46 | return true;
47 | } catch (Exception ex) {
48 | if (handle) {
49 | p.sendMessage(message);
50 | }
51 | }
52 | return false;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/moderation/clickable/ClickableMessage.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.moderation.clickable;
2 |
3 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
4 | import org.bukkit.command.CommandSender;
5 |
6 | public class ClickableMessage {
7 |
8 | private static final boolean exists = ReflectionUtils.classExists(
9 | "net.md_5.bungee.api.chat.ClickEvent"
10 | );
11 |
12 | public static boolean sendDescription(CommandSender p, String message, String preview) {
13 | if (exists) {
14 | return BackgroundClickableMessage.send(p, message, preview, null, true);
15 | }
16 | return false;
17 | }
18 |
19 | public static boolean sendCommand(CommandSender p, String message, String preview, String command) {
20 | if (exists) {
21 | return BackgroundClickableMessage.send(p, message, preview, command, true);
22 | }
23 | return false;
24 | }
25 |
26 | public static boolean sendURL(CommandSender p, String message, String preview, String url) {
27 | if (exists) {
28 | return BackgroundClickableMessage.sendURL(p, message, preview, url, true);
29 | }
30 | return false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/server/TPS.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.server;
2 |
3 | public class TPS {
4 |
5 | public static final long tickTime = 50L;
6 | public static final int tickTimeInteger = (int) tickTime;
7 | public static final double maximum = 20.0;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/tracking/MovementProcessing.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.tracking;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.compatibility.Compatibility;
5 | import ai.idealistic.spartan.compatibility.manual.abilities.ItemsAdder;
6 | import ai.idealistic.spartan.compatibility.manual.building.MythicMobs;
7 | import ai.idealistic.spartan.compatibility.manual.vanilla.Attributes;
8 | import ai.idealistic.spartan.utils.minecraft.entity.CombatUtils;
9 | import org.bukkit.entity.Entity;
10 |
11 | import java.util.List;
12 |
13 | public class MovementProcessing {
14 |
15 | public static boolean canCheck(PlayerProtocol protocol,
16 | boolean vehicle,
17 | boolean elytra,
18 | boolean flight,
19 | boolean playerAttributes,
20 | boolean environmentalAttributes) {
21 | if ((elytra || !protocol.isGliding())
22 | && (flight || !protocol.wasFlying())
23 | && (vehicle || protocol.getVehicle() == null)
24 |
25 | && (playerAttributes
26 | || Attributes.getAmount(protocol, Attributes.GENERIC_MOVEMENT_SPEED) == Double.MIN_VALUE
27 | && Attributes.getAmount(protocol, Attributes.GENERIC_JUMP_STRENGTH) == Double.MIN_VALUE)
28 |
29 | && (environmentalAttributes
30 | || Attributes.getAmount(protocol, Attributes.GENERIC_STEP_HEIGHT) == Double.MIN_VALUE
31 | && Attributes.getAmount(protocol, Attributes.GENERIC_GRAVITY) == Double.MIN_VALUE)) {
32 | if (Compatibility.CompatibilityType.MYTHIC_MOBS.isFunctional()
33 | || Compatibility.CompatibilityType.ITEMS_ADDER.isFunctional()) {
34 | List entities = protocol.getNearbyEntities(
35 | CombatUtils.maxHitDistance,
36 | CombatUtils.maxHitDistance,
37 | CombatUtils.maxHitDistance
38 | );
39 |
40 | if (!entities.isEmpty()) {
41 | for (Entity entity : entities) {
42 | if (MythicMobs.is(entity) || ItemsAdder.is(entity)) {
43 | return false;
44 | }
45 | }
46 | }
47 | }
48 | return true;
49 | }
50 | return false;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/functionality/tracking/Piston.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.functionality.tracking;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import ai.idealistic.spartan.utils.math.AlgebraUtils;
6 | import ai.idealistic.spartan.utils.minecraft.entity.PlayerUtils;
7 | import org.bukkit.Location;
8 | import org.bukkit.World;
9 | import org.bukkit.block.Block;
10 |
11 | import java.util.Collection;
12 | import java.util.List;
13 |
14 | public class Piston {
15 |
16 | private static final double
17 | horizontalDistance = 3.0,
18 | verticalDistance = 2.0;
19 |
20 | public static void run(Block block, List blocks) {
21 | Collection protocols = PluginBase.getProtocols();
22 |
23 | if (!protocols.isEmpty()) {
24 | boolean runBlocks = !blocks.isEmpty();
25 | World world = block.getWorld();
26 |
27 | for (PlayerProtocol protocol : protocols) {
28 | if (protocol.getWorld().equals(world)) {
29 | Location location = protocol.getLocationOrVehicle();
30 | double preX = AlgebraUtils.getSquare(location.getX(), block.getX()),
31 | diffY = location.getY() - block.getY(),
32 | preZ = AlgebraUtils.getSquare(location.getZ(), block.getZ());
33 |
34 | if (!run(protocol, preX, diffY, preZ) // Check if the player is nearby to the piston
35 | && runBlocks
36 | && Math.sqrt(preX + (diffY * diffY) + preZ) <= PlayerUtils.chunk) { // Check if the player is nearby to the piston affected blocks
37 | for (Block affected : blocks) {
38 | preX = AlgebraUtils.getSquare(location.getX(), affected.getX());
39 | diffY = location.getY() - block.getY();
40 | preZ = AlgebraUtils.getSquare(location.getZ(), affected.getZ());
41 |
42 | if (run(protocol, preX, diffY, preZ)) { // Check if the player is nearby to the piston affected block
43 | break;
44 | }
45 | }
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
52 | private static boolean run(PlayerProtocol protocol, double preX, double diffY, double preZ) {
53 | if (Math.sqrt(preX + preZ) <= horizontalDistance
54 | && Math.abs(diffY) <= verticalDistance) {
55 | protocol.lastVelocity = System.currentTimeMillis();
56 | return true;
57 | }
58 | return false;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/DeathEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.entity.PlayerDeathEvent;
10 |
11 | public class DeathEvent implements Listener {
12 |
13 | @EventHandler(priority = EventPriority.HIGHEST)
14 | private void Event(PlayerDeathEvent e) {
15 | event(e.getEntity(), false, e);
16 | }
17 |
18 | public static void event(Player player, boolean packets, Object object) {
19 | PlayerProtocol protocol = PluginBase.getProtocol(player, true);
20 | protocol.timerBalancer.addBalance(50);
21 |
22 | if (protocol.packetsEnabled() == packets) {
23 | protocol.executeRunners(null, object);
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/MovementEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.event.PlayerTickEvent;
4 | import ai.idealistic.spartan.abstraction.event.PlayerTransactionEvent;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.abstraction.world.ServerLocation;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import org.bukkit.Location;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.player.PlayerMoveEvent;
13 |
14 | public class MovementEvent implements Listener {
15 |
16 | @EventHandler(priority = EventPriority.HIGHEST)
17 | private void MoveEvent(PlayerMoveEvent e) {
18 | event(e, false);
19 | }
20 |
21 | public static void event(PlayerMoveEvent e, boolean packets) {
22 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer());
23 |
24 | if (protocol.packetsEnabled() == packets) {
25 | Location nto = e.getTo();
26 |
27 | if (nto == null) {
28 | return;
29 | }
30 | Location vehicle = protocol.getVehicleLocation();
31 | ServerLocation to = vehicle != null
32 | ? new ServerLocation(vehicle)
33 | : new ServerLocation(nto);
34 |
35 | if (!protocol.processLastMoveEvent(
36 | nto,
37 | vehicle,
38 | to,
39 | e.getFrom(),
40 | packets
41 | )) {
42 | return;
43 | }
44 | protocol.executeRunners(e.isCancelled(), e);
45 | }
46 | }
47 |
48 | public static void tick(PlayerTickEvent tickEvent) {
49 | PlayerProtocol protocol = tickEvent.protocol;
50 | protocol.lastTickEvent = tickEvent;
51 | protocol.packetWorld.tick(tickEvent);
52 | protocol.timerBalancer.pushDelay(tickEvent);
53 | protocol.executeRunners(false, tickEvent);
54 | }
55 |
56 | public static void transaction(PlayerTransactionEvent event) {
57 | PlayerProtocol protocol = event.protocol;
58 | protocol.executeRunners(false, event);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/PlaceEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import ai.idealistic.spartan.abstraction.event.CBlockPlaceEvent;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.compatibility.manual.abilities.ItemsAdder;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import org.bukkit.block.Block;
9 | import org.bukkit.event.Cancellable;
10 | import org.bukkit.event.EventHandler;
11 | import org.bukkit.event.EventPriority;
12 | import org.bukkit.event.Listener;
13 | import org.bukkit.event.block.BlockPlaceEvent;
14 |
15 | public class PlaceEvent implements Listener {
16 |
17 | @EventHandler(priority = EventPriority.HIGHEST)
18 | public static void event(BlockPlaceEvent e) {
19 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer(), true);
20 |
21 | if (event(protocol, e.getBlock(), e.getBlockAgainst(), e, false)) {
22 | e.setCancelled(true);
23 | }
24 | }
25 |
26 | public static boolean event(
27 | PlayerProtocol protocol,
28 | Block block,
29 | Block blockAgainst,
30 | Object event,
31 | boolean packets
32 | ) {
33 | if (protocol.packetsEnabled() == packets) {
34 | if (protocol.getWorld() != block.getWorld()) {
35 | return false;
36 | }
37 | protocol.executeRunners(null, event);
38 |
39 | // Detections
40 | if (!ItemsAdder.is(block)) {
41 | protocol.executeRunners(
42 | event,
43 | new CBlockPlaceEvent(
44 | protocol.bukkit(),
45 | block,
46 | blockAgainst,
47 | event instanceof Cancellable && ((Cancellable) event).isCancelled()
48 | )
49 | );
50 | }
51 | }
52 | return protocol.getRunner(CheckEnums.HackType.FAST_PLACE).prevent()
53 | || protocol.getRunner(CheckEnums.HackType.BLOCK_REACH).prevent()
54 | || protocol.getRunner(CheckEnums.HackType.IMPOSSIBLE_ACTIONS).prevent();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/TeleportEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerRespawnEvent;
10 | import org.bukkit.event.player.PlayerTeleportEvent;
11 |
12 | public class TeleportEvent implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST)
15 | private void Teleport(PlayerTeleportEvent e) {
16 | teleport(e.getPlayer(), false, e);
17 | }
18 |
19 | public static void teleport(Player player, boolean packets, Object object) {
20 | PlayerProtocol protocol = PluginBase.getProtocol(player, true);
21 |
22 | if (protocol.packetsEnabled() == packets
23 | || object instanceof PlayerTeleportEvent) {
24 | protocol.executeRunners(null, object);
25 | }
26 | }
27 |
28 | @EventHandler(priority = EventPriority.HIGHEST)
29 | private void Respawn(PlayerRespawnEvent e) {
30 | respawn(e.getPlayer(), false, e);
31 | }
32 |
33 | public static void respawn(Player player, boolean packets, Object object) {
34 | PlayerProtocol protocol = PluginBase.getProtocol(player, true);
35 |
36 | if (protocol.packetsEnabled() == packets) {
37 | protocol.executeRunners(null, object);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/TridentEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.event.CPlayerRiptideEvent;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import org.bukkit.Material;
7 | import org.bukkit.enchantments.Enchantment;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.player.PlayerRiptideEvent;
11 | import org.bukkit.inventory.ItemStack;
12 | import org.bukkit.inventory.PlayerInventory;
13 |
14 | public class TridentEvent implements Listener {
15 |
16 | @EventHandler
17 | private void Event(PlayerRiptideEvent e) {
18 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer());
19 | event(
20 | new CPlayerRiptideEvent(
21 | protocol,
22 | e.getItem(),
23 | e.getPlayer().getVelocity()
24 | ), false);
25 | }
26 |
27 | public static void event(CPlayerRiptideEvent e, boolean packets) {
28 | PlayerProtocol p = e.protocol;
29 |
30 | if (p.packetsEnabled() == packets) {
31 | p.executeRunners(false, e);
32 | PlayerInventory inventory = e.protocol.getInventory();
33 |
34 | for (ItemStack item : new ItemStack[]{inventory.getItemInHand(), inventory.getItemInOffHand()}) {
35 | if (item.getType() == Material.TRIDENT) {
36 | int level = item.getEnchantmentLevel(Enchantment.RIPTIDE);
37 |
38 | if (level > 0) {
39 | p.lastVelocity = System.currentTimeMillis();
40 | break;
41 | }
42 | }
43 | }
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/VehicleEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Entity;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.vehicle.VehicleEnterEvent;
11 | import org.bukkit.event.vehicle.VehicleExitEvent;
12 |
13 | public class VehicleEvent implements Listener {
14 |
15 | @EventHandler(priority = EventPriority.HIGHEST)
16 | public static void enter(VehicleEnterEvent e) {
17 | if (!e.isCancelled()) {
18 | Entity entity = e.getEntered();
19 |
20 | if (entity instanceof Player) {
21 | PlayerProtocol p = PluginBase.getProtocol((Player) entity, true);
22 | p.executeRunners(e.isCancelled(), e);
23 | }
24 | }
25 | }
26 |
27 | @EventHandler(priority = EventPriority.HIGHEST)
28 | public static void exit(VehicleExitEvent e) {
29 | if (!e.isCancelled()) {
30 | Entity en = e.getExited();
31 |
32 | if (en instanceof Player) {
33 | PlayerProtocol p = PluginBase.getProtocol((Player) en, true);
34 | p.executeRunners(e.isCancelled(), e);
35 | }
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/VelocityEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit;
2 |
3 | import ai.idealistic.spartan.abstraction.event.CPlayerVelocityEvent;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerVelocityEvent;
10 |
11 | public class VelocityEvent implements Listener {
12 |
13 | @EventHandler(priority = EventPriority.HIGHEST)
14 | private void Event(PlayerVelocityEvent e) {
15 | event(
16 | new CPlayerVelocityEvent(
17 | e.getPlayer(),
18 | e.getVelocity()
19 | ),
20 | false
21 | );
22 | }
23 |
24 | public static void event(CPlayerVelocityEvent e, boolean packets) {
25 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer());
26 |
27 | if (protocol.packetsEnabled() == packets) {
28 | protocol.claimedVelocity = e;
29 | protocol.claimedVeloGravity.add(e);
30 |
31 | if (protocol.claimedVeloGravity.size() > 2) {
32 | protocol.claimedVeloGravity.remove(0);
33 | }
34 | protocol.claimedVeloSpeed.add(e);
35 |
36 | if (protocol.claimedVeloSpeed.size() > 2) {
37 | protocol.claimedVeloSpeed.remove(0);
38 | }
39 | protocol.executeRunners(e.isCancelled(), e);
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/BowEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Entity;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.entity.EntityShootBowEvent;
11 |
12 | public class BowEvent implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST)
15 | private void Event(EntityShootBowEvent e) {
16 | Entity entity = e.getEntity();
17 |
18 | if (entity instanceof Player) {
19 | PlayerProtocol p = PluginBase.getProtocol((Player) entity, true);
20 | p.executeRunners(e.isCancelled(), e);
21 | }
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/ChatEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.player.AsyncPlayerChatEvent;
9 |
10 | public class ChatEvent implements Listener {
11 |
12 | @EventHandler(priority = EventPriority.HIGHEST)
13 | private void Event(AsyncPlayerChatEvent e) {
14 | PlayerProtocol p = PluginBase.getProtocol(e.getPlayer());
15 | p.executeRunners(e.isCancelled(), e);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/ChunksEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.functionality.server.MultiVersion;
4 | import ai.idealistic.spartan.listeners.NPCManager;
5 | import org.bukkit.Chunk;
6 | import org.bukkit.Location;
7 | import org.bukkit.World;
8 | import org.bukkit.block.Block;
9 | import org.bukkit.event.EventHandler;
10 | import org.bukkit.event.EventPriority;
11 | import org.bukkit.event.Listener;
12 | import org.bukkit.event.world.ChunkLoadEvent;
13 | import org.bukkit.event.world.ChunkUnloadEvent;
14 | import org.bukkit.event.world.WorldUnloadEvent;
15 |
16 | import java.util.Map;
17 | import java.util.concurrent.ConcurrentHashMap;
18 |
19 | public class ChunksEvent implements Listener {
20 |
21 | private static final Map loaded = new ConcurrentHashMap<>();
22 | public static final boolean heightSupport = MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_17);
23 |
24 | private static long hash(World world, int x, int z) {
25 | return (((31L * x) + z) * 31L) + world.getName().hashCode();
26 | }
27 |
28 | public static boolean isLoaded(World world, int x, int z) {
29 | long hash = hash(world, x, z);
30 | Long time = loaded.get(hash);
31 |
32 | if (time != null) {
33 | if (time == -1L) {
34 | return true;
35 | } else if (time > System.currentTimeMillis()) {
36 | return false;
37 | }
38 | }
39 | for (Chunk chunk : world.getLoadedChunks()) {
40 | if (chunk.getX() == x && chunk.getZ() == z) {
41 | loaded.put(hash, -1L);
42 | return true;
43 | }
44 | }
45 | loaded.put(hash, System.currentTimeMillis() + 10_000L);
46 | return false;
47 | }
48 |
49 | // Separator
50 |
51 | @EventHandler(priority = EventPriority.HIGHEST)
52 | private void ChunkLoad(ChunkLoadEvent e) {
53 | Chunk chunk = e.getChunk();
54 | loaded.put(hash(chunk.getWorld(), chunk.getX(), chunk.getZ()), -1L);
55 | }
56 |
57 | @EventHandler(priority = EventPriority.HIGHEST)
58 | private void ChunkUnload(ChunkUnloadEvent e) {
59 | Chunk chunk = e.getChunk();
60 | loaded.remove(hash(chunk.getWorld(), chunk.getX(), chunk.getZ()));
61 | }
62 |
63 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
64 | private void WorldUnload(WorldUnloadEvent e) {
65 | World world = e.getWorld();
66 | NPCManager.clear(world);
67 |
68 | for (Chunk chunk : world.getLoadedChunks()) {
69 | loaded.remove(hash(world, chunk.getX(), chunk.getZ()));
70 | }
71 | }
72 |
73 | public static Block getBlockAsync(Location location) {
74 | if (ChunksEvent.isLoaded(
75 | location.getWorld(),
76 | location.getBlockX() >> 4,
77 | location.getBlockZ() >> 4
78 | )) {
79 | return location.getWorld().getBlockAt(location);
80 | } else {
81 | return null;
82 | }
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/ElytraEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Entity;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.entity.EntityToggleGlideEvent;
11 |
12 | public class ElytraEvent implements Listener {
13 |
14 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
15 | private void Event(EntityToggleGlideEvent e) {
16 | Entity entity = e.getEntity();
17 |
18 | if (entity instanceof Player) {
19 | PlayerProtocol protocol = PluginBase.getProtocol((Player) entity);
20 | protocol.executeRunners(e.isCancelled(), e);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/HealthEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import org.bukkit.entity.Entity;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.entity.EntityRegainHealthEvent;
11 | import org.bukkit.event.entity.FoodLevelChangeEvent;
12 |
13 | public class HealthEvent implements Listener {
14 |
15 | @EventHandler(priority = EventPriority.HIGHEST)
16 | private void Food(FoodLevelChangeEvent e) {
17 | Entity entity = e.getEntity();
18 |
19 | if (entity instanceof Player) {
20 | PlayerProtocol p = PluginBase.getProtocol((Player) entity);
21 | p.executeRunners(e.isCancelled(), e);
22 | }
23 | }
24 |
25 | @EventHandler(priority = EventPriority.HIGHEST)
26 | private void Regen(EntityRegainHealthEvent e) {
27 | Entity entity = e.getEntity();
28 |
29 | if (entity instanceof Player) {
30 | PlayerProtocol p = PluginBase.getProtocol((Player) entity);
31 | p.executeRunners(e.isCancelled(), e);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/InventoryEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.inventory.InventoryMenu;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.MultiVersion;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import ai.idealistic.spartan.utils.java.StringUtils;
8 | import ai.idealistic.spartan.utils.minecraft.world.BlockUtils;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.event.EventHandler;
11 | import org.bukkit.event.EventPriority;
12 | import org.bukkit.event.Listener;
13 | import org.bukkit.event.inventory.ClickType;
14 | import org.bukkit.event.inventory.InventoryClickEvent;
15 | import org.bukkit.event.player.PlayerDropItemEvent;
16 | import org.bukkit.inventory.ItemStack;
17 |
18 | public class InventoryEvent implements Listener {
19 |
20 | @EventHandler(priority = EventPriority.HIGHEST)
21 | private void ItemDrop(PlayerDropItemEvent e) {
22 | PlayerProtocol p = PluginBase.getProtocol(e.getPlayer(), true);
23 | p.executeRunners(e.isCancelled(), e);
24 | }
25 |
26 | @EventHandler(priority = EventPriority.HIGHEST)
27 | private void InventoryClick(InventoryClickEvent e) {
28 | ItemStack item = e.getCurrentItem();
29 |
30 | if (BlockUtils.hasMaterial(item)) {
31 | Player n = (Player) e.getWhoClicked();
32 | PlayerProtocol p = PluginBase.getProtocol(n, true);
33 | p.executeRunners(false, e);
34 |
35 | if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
36 | ClickType click = e.getClick();
37 | String title = MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_13)
38 | ? StringUtils.getClearColorString(n.getOpenInventory().getTitle())
39 | : n.getOpenInventory().getTitle();
40 | int slot = e.getSlot();
41 |
42 | for (InventoryMenu menu : PluginBase.menus) {
43 | if (menu.handle(p, title, item, click, slot)) {
44 | e.setCancelled(true);
45 | break;
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/JoinEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.connection.CloudBase;
6 | import ai.idealistic.spartan.functionality.connection.PluginAddons;
7 | import ai.idealistic.spartan.functionality.moderation.AwarenessNotifications;
8 | import ai.idealistic.spartan.functionality.server.Config;
9 | import ai.idealistic.spartan.functionality.server.Permissions;
10 | import ai.idealistic.spartan.functionality.server.PluginBase;
11 | import org.bukkit.entity.Player;
12 | import org.bukkit.event.EventHandler;
13 | import org.bukkit.event.EventPriority;
14 | import org.bukkit.event.Listener;
15 | import org.bukkit.event.player.PlayerJoinEvent;
16 |
17 | public class JoinEvent implements Listener {
18 |
19 | @EventHandler(priority = EventPriority.HIGHEST)
20 | private void Event(PlayerJoinEvent e) {
21 | Player n = e.getPlayer();
22 | PlayerProtocol protocol = PluginBase.getProtocol(n);
23 |
24 | if ((PluginAddons.isFreeEdition()
25 | || Config.settings.getBoolean("Important.enable_watermark"))
26 | && !Permissions.isStaff(n)) {
27 | n.sendMessage("");
28 | AwarenessNotifications.forcefullySend(
29 | protocol,
30 | "\nThis server is protected by the " + Register.pluginName + " AntiCheat",
31 | false
32 | );
33 | n.sendMessage("");
34 | }
35 |
36 | PluginBase.runDelayedTask(protocol, () -> {
37 | Config.settings.runOnLogin(protocol);
38 | CloudBase.announce(protocol);
39 | }, 10L);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/LeaveEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.moderation.DetectionNotifications;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerQuitEvent;
10 |
11 | public class LeaveEvent implements Listener {
12 |
13 | @EventHandler(priority = EventPriority.HIGHEST)
14 | private void Event(PlayerQuitEvent e) {
15 | PlayerProtocol protocol = PluginBase.deleteProtocol(e.getPlayer());
16 |
17 | if (protocol == null) {
18 | return;
19 | }
20 | DetectionNotifications.runOnLeave(protocol);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/PluginEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.functionality.server.Config;
4 | import org.bukkit.event.EventHandler;
5 | import org.bukkit.event.Listener;
6 | import org.bukkit.event.server.PluginDisableEvent;
7 | import org.bukkit.event.server.PluginEnableEvent;
8 |
9 | public class PluginEvent implements Listener {
10 |
11 | @EventHandler
12 | private void PluginEnable(PluginEnableEvent e) {
13 | Config.compatibility.fastRefresh();
14 | }
15 |
16 | @EventHandler
17 | private void PluginDisable(PluginDisableEvent e) {
18 | Config.compatibility.fastRefresh();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/VehicleDeathEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4 | import ai.idealistic.spartan.functionality.server.MultiVersion;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import org.bukkit.entity.Entity;
7 | import org.bukkit.entity.LivingEntity;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.entity.Vehicle;
10 | import org.bukkit.event.EventHandler;
11 | import org.bukkit.event.EventPriority;
12 | import org.bukkit.event.Listener;
13 | import org.bukkit.event.entity.EntityDeathEvent;
14 | import org.bukkit.event.vehicle.VehicleExitEvent;
15 |
16 | public class VehicleDeathEvent implements Listener {
17 |
18 | @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
19 | private void Event(EntityDeathEvent e) {
20 | LivingEntity entity = e.getEntity();
21 |
22 | if (entity instanceof Vehicle) {
23 | Entity[] passengers = MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_13)
24 | ? entity.getPassengers().toArray(new Entity[0])
25 | : new Entity[]{entity.getPassenger()};
26 |
27 | if (passengers.length > 0) {
28 | for (Entity passenger : passengers) {
29 | if (passenger instanceof Player) {
30 | PlayerProtocol p = PluginBase.getProtocol((Player) passenger, true);
31 | p.executeRunners(
32 | false,
33 | new VehicleExitEvent(
34 | (Vehicle) entity,
35 | (Player) passenger,
36 | false
37 | )
38 | );
39 | }
40 | }
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/standalone/WorldEvent.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.standalone;
2 |
3 | import ai.idealistic.spartan.abstraction.profiling.MiningHistory;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import ai.idealistic.spartan.functionality.tracking.Piston;
7 | import org.bukkit.block.Block;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.EventPriority;
10 | import org.bukkit.event.Listener;
11 | import org.bukkit.event.block.BlockBreakEvent;
12 | import org.bukkit.event.block.BlockPistonExtendEvent;
13 | import org.bukkit.event.block.SignChangeEvent;
14 | import org.bukkit.event.player.PlayerAnimationEvent;
15 | import org.bukkit.event.player.PlayerInteractEvent;
16 |
17 | public class WorldEvent implements Listener {
18 |
19 | @EventHandler(priority = EventPriority.HIGHEST)
20 | private void BlockBreak(BlockBreakEvent e) {
21 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer(), true);
22 | Block nb = e.getBlock();
23 | boolean cancelled = e.isCancelled();
24 | protocol.executeRunners(e.isCancelled(), e);
25 | MiningHistory.log(protocol, nb, cancelled);
26 | }
27 |
28 | @EventHandler(priority = EventPriority.HIGHEST)
29 | private void Sign(SignChangeEvent e) {
30 | PlayerProtocol p = PluginBase.getProtocol(e.getPlayer(), true);
31 | p.executeRunners(e.isCancelled(), e);
32 | }
33 |
34 | @EventHandler(priority = EventPriority.HIGHEST)
35 | private void Animation(PlayerAnimationEvent e) {
36 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer(), true);
37 | protocol.executeRunners(e.isCancelled(), e);
38 | }
39 |
40 | @EventHandler(priority = EventPriority.HIGHEST)
41 | private void Interact(PlayerInteractEvent e) {
42 | PlayerProtocol protocol = PluginBase.getProtocol(e.getPlayer(), true);
43 | protocol.executeRunners(false, e); // False because is cancelled is deprecated
44 | }
45 |
46 | @EventHandler(priority = EventPriority.HIGHEST)
47 | private void Piston(BlockPistonExtendEvent e) {
48 | if (!e.isCancelled()) {
49 | Piston.run(e.getBlock(), e.getBlocks());
50 | }
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/bukkit/test/GhostBlockTest.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.bukkit.test;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.Listener;
5 | import org.bukkit.event.block.BlockBreakEvent;
6 | import org.bukkit.event.block.BlockPlaceEvent;
7 |
8 | public class GhostBlockTest implements Listener {
9 |
10 | @EventHandler
11 | public void block(BlockPlaceEvent event) {
12 | event.setCancelled(true);
13 | }
14 |
15 | @EventHandler
16 | public void breAk(BlockBreakEvent event) {
17 | event.setCancelled(true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/AbilitiesListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.functionality.server.PluginBase;
5 | import com.comphenix.protocol.PacketType;
6 | import com.comphenix.protocol.events.ListenerPriority;
7 | import com.comphenix.protocol.events.PacketAdapter;
8 | import com.comphenix.protocol.events.PacketEvent;
9 | import org.bukkit.entity.Player;
10 |
11 | public class AbilitiesListener extends PacketAdapter {
12 |
13 | public AbilitiesListener() {
14 | super(Register.plugin, ListenerPriority.NORMAL,
15 | PacketType.Play.Client.ABILITIES);
16 | }
17 |
18 | @Override
19 | public void onPacketReceiving(PacketEvent event) {
20 | Player player = event.getPlayer();
21 | if (player.getAllowFlight()) {
22 | PluginBase.getProtocol(player).flyingTicks = 2;
23 | }
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/ClicksListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.event.PlayerLeftClickEvent;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketEvent;
11 | import org.bukkit.entity.Player;
12 |
13 | public class ClicksListener extends PacketAdapter {
14 |
15 | public ClicksListener() {
16 | super(
17 | Register.plugin,
18 | ListenerPriority.NORMAL,
19 | PacketType.Play.Client.ARM_ANIMATION,
20 | PacketType.Play.Client.BLOCK_DIG
21 | );
22 | }
23 |
24 | @Override
25 | public void onPacketReceiving(PacketEvent event) {
26 | Player player = event.getPlayer();
27 | PlayerProtocol protocol = PluginBase.getProtocol(player);
28 |
29 | synchronized (protocol) {
30 | if (event.getPacket().getType().equals(PacketType.Play.Client.ARM_ANIMATION)) {
31 | long delay = System.currentTimeMillis() - protocol.oldClickTime;
32 |
33 | if (delay > 150) {
34 | protocol.clickBlocker = false;
35 | }
36 | if (!protocol.clickBlocker) {
37 | protocol.executeRunners(
38 | false,
39 | new PlayerLeftClickEvent(
40 | player,
41 | delay
42 | )
43 | );
44 | }
45 | protocol.oldClickTime = System.currentTimeMillis();
46 | } else if (event.getPacket().getType().equals(PacketType.Play.Client.BLOCK_DIG)) {
47 | String s = event.getPacket().getStructures().getValues().toString();
48 | protocol.oldClickTime = System.currentTimeMillis();
49 | protocol.clickBlocker = !s.contains("ABORT");
50 | }
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/DeathListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import ai.idealistic.spartan.listeners.bukkit.DeathEvent;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 |
13 | public class DeathListener extends PacketAdapter {
14 |
15 | public static final PacketType[] packetTypes = new PacketType[]{
16 | PacketType.Play.Server.UPDATE_HEALTH
17 | };
18 |
19 | public DeathListener() {
20 | super(
21 | Register.plugin,
22 | ListenerPriority.HIGHEST,
23 | packetTypes
24 | );
25 | }
26 |
27 | @Override
28 | public void onPacketSending(PacketEvent event) {
29 | PlayerProtocol protocol = PluginBase.getProtocol(event.getPlayer());
30 |
31 | if (protocol.isBedrockPlayer()) {
32 | return;
33 | }
34 | PacketContainer packet = event.getPacket();
35 |
36 | if (packet.getType().equals(PacketType.Play.Server.UPDATE_HEALTH)
37 | && packet.getFloat().read(0) <= 0.0F) {
38 | DeathEvent.event(event.getPlayer(), true, event);
39 | protocol.useItemPacket = false;
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/ExplosionListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.abstraction.world.ServerLocation;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import org.bukkit.Location;
13 | import org.bukkit.entity.Player;
14 |
15 | import java.util.List;
16 |
17 | public class ExplosionListener extends PacketAdapter {
18 |
19 | public ExplosionListener() {
20 | super(Register.plugin, ListenerPriority.NORMAL,
21 | PacketType.Play.Server.EXPLOSION);
22 | }
23 |
24 | @Override
25 | public void onPacketSending(PacketEvent event) {
26 | PacketContainer packet = event.getPacket();
27 | List d = packet.getDoubles().getValues();
28 |
29 | if (d.size() >= 3) {
30 | Player player = event.getPlayer();
31 | PlayerProtocol protocol = PluginBase.getProtocol(player);
32 | Location l = new Location(player.getWorld(), d.get(0), d.get(1), d.get(2));
33 |
34 | if (ServerLocation.distanceSquared(l, protocol.getLocation()) < 10) {
35 | protocol.getComponentY().explosionTick = true;
36 | protocol.getComponentXZ().explosionTick = true;
37 | }
38 | }
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/MultiBlockLegacyListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
13 | import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
14 | import org.bukkit.Chunk;
15 | import org.bukkit.Material;
16 | import org.bukkit.World;
17 | import org.bukkit.entity.Player;
18 |
19 | import java.util.List;
20 |
21 | public class MultiBlockLegacyListener extends PacketAdapter {
22 | public MultiBlockLegacyListener() {
23 | super(Register.plugin, ListenerPriority.HIGHEST,
24 | PacketType.Play.Server.MULTI_BLOCK_CHANGE);
25 | }
26 | @Override
27 | public void onPacketSending(PacketEvent event) {
28 | Player player = event.getPlayer();
29 | PlayerProtocol protocol = PluginBase.getProtocol(player);
30 | World world = player.getWorld();
31 | PacketContainer packet = event.getPacket();
32 | if (packet.getMultiBlockChangeInfoArrays().getValues().isEmpty()) {
33 | return;
34 | }
35 | List mList = packet.getMultiBlockChangeInfoArrays().getValues();
36 | ChunkCoordIntPair c = packet.getMultiBlockChangeInfoArrays().getValues().get(0)[0].getChunk();
37 | Chunk chunk = player.getWorld().getChunkAt(c.getChunkX(), c.getChunkZ());
38 | CheckThread.run(() -> {
39 | for (MultiBlockChangeInfo[] m : mList) {
40 | for (MultiBlockChangeInfo info : m) {
41 | Material material = info.getData().getType();
42 | if (material.toString().equals("SLIME_BLOCK")) {
43 | if (info.getLocation(world).distance(protocol.getLocation()) < 6) {
44 | protocol.predictedSlimeTicks = 6;
45 | }
46 | }
47 | }
48 | }
49 | });
50 | }
51 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/MultiBlockListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import com.comphenix.protocol.wrappers.BlockPosition;
13 | import org.bukkit.Location;
14 | import org.bukkit.World;
15 | import org.bukkit.entity.Player;
16 |
17 | public class MultiBlockListener extends PacketAdapter {
18 | public MultiBlockListener() {
19 | super(Register.plugin, ListenerPriority.HIGHEST, PacketType.Play.Server.MULTI_BLOCK_CHANGE);
20 | }
21 | @Override
22 | public void onPacketSending(PacketEvent event) {
23 | Player player = event.getPlayer();
24 | PlayerProtocol protocol = PluginBase.getProtocol(player);
25 | World world = player.getWorld();
26 | PacketContainer packet = event.getPacket();
27 |
28 | BlockPosition b = packet.getSectionPositions().read(0);
29 | int chunkX = b.getX();
30 | int chunkZ = b.getZ();
31 | int chunkY = b.getY();
32 | short[] records = packet.getShortArrays().read(0);
33 | Object[] blockData = packet.getSpecificModifier(Object[].class).read(0);
34 |
35 | CheckThread.run(() -> {
36 | for (int i = 0; i < records.length; i++) {
37 | short record = records[i];
38 | int relX = (record >> 8) & 0xF;
39 | int relY = (record) & 0xF;
40 | int relZ = (record >> 4) & 0xF;
41 |
42 | int worldX = (chunkX << 4) | relX;
43 | int worldY = (chunkY << 4) | relY;
44 | int worldZ = (chunkZ << 4) | relZ;
45 |
46 | final Location loc = new Location(
47 | world,
48 | ((chunkX * 16) + worldX) / 2.0,
49 | worldY,
50 | ((chunkZ * 16) + worldZ) / 2.0
51 | );
52 |
53 | final Object nmsData = blockData[i];
54 | if (nmsData.toString().toLowerCase().contains("slime_block")) {
55 | //player.sendMessage("p: " + loc.distance(protocol.getLocation()));
56 | if (loc.distance(protocol.getLocation()) < 14) {
57 | protocol.predictedSlimeTicks = 6;
58 | }
59 | }
60 | }
61 | });
62 | }
63 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/PacketDebug.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import com.comphenix.protocol.PacketType;
5 | import com.comphenix.protocol.events.ListenerPriority;
6 | import com.comphenix.protocol.events.PacketAdapter;
7 | import com.comphenix.protocol.events.PacketContainer;
8 | import com.comphenix.protocol.events.PacketEvent;
9 | import org.bukkit.Bukkit;
10 | import org.bukkit.entity.Player;
11 |
12 | public class PacketDebug extends PacketAdapter {
13 |
14 | public PacketDebug() {
15 | super(
16 | Register.plugin,
17 | ListenerPriority.MONITOR,
18 | PacketType.Play.Client.getInstance()
19 | );
20 | }
21 |
22 | @Override
23 | public void onPacketReceiving(PacketEvent event) {
24 | Player player = event.getPlayer();
25 | PacketContainer packet = event.getPacket();
26 | if (event.getPlayer().getName().equals("pawsashatoy")) display(player, "i: " + packet.getType().name() + " " + packet.getStructures().getValues());
27 | }
28 |
29 | private void display(Player player, String display) {
30 | player.sendMessage(display);
31 | Bukkit.getLogger().info(display);
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/PacketPistonHandle.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import com.comphenix.protocol.PacketType;
7 | import com.comphenix.protocol.events.ListenerPriority;
8 | import com.comphenix.protocol.events.PacketAdapter;
9 | import com.comphenix.protocol.events.PacketContainer;
10 | import com.comphenix.protocol.events.PacketEvent;
11 | import org.bukkit.Location;
12 |
13 | public class PacketPistonHandle extends PacketAdapter {
14 |
15 | public PacketPistonHandle() {
16 | super(Register.plugin, ListenerPriority.NORMAL, PacketType.Play.Server.BLOCK_ACTION);
17 | }
18 |
19 | @Override
20 | public void onPacketSending(PacketEvent event) {
21 | PacketContainer packet = event.getPacket();
22 |
23 | if (packet.getStructures().getValues().toString().contains("piston")) {
24 | PlayerProtocol protocol = PluginBase.getProtocol(event.getPlayer());
25 | protocol.getComponentY().pistonHandle = true;
26 | Location blockLocation = packet.getBlockPositionModifier()
27 | .read(0)
28 | .toLocation(protocol.getWorld());
29 |
30 | if (isPlayerInBox(protocol.getLocation(), blockLocation, 5)) {
31 | protocol.getComponentY().pistonTick = true;
32 | protocol.getComponentXZ().pistonTick = true;
33 | protocol.pistonTick = true;
34 | }
35 | }
36 | }
37 |
38 | private boolean isPlayerInBox(Location playerLocation, Location centerLocation, int boxSize) {
39 | return Math.abs(playerLocation.getX() - centerLocation.getX()) <= boxSize
40 | && Math.abs(playerLocation.getY() - centerLocation.getY()) <= boxSize
41 | && Math.abs(playerLocation.getZ() - centerLocation.getZ()) <= boxSize;
42 | }
43 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/PacketServerBlockHandle.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.event.ServerBlockChange;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import com.comphenix.protocol.wrappers.BlockPosition;
13 | import com.comphenix.protocol.wrappers.WrappedBlockData;
14 | import org.bukkit.entity.Player;
15 |
16 | public class PacketServerBlockHandle extends PacketAdapter {
17 |
18 | public PacketServerBlockHandle() {
19 | super(Register.plugin, ListenerPriority.NORMAL, PacketType.Play.Server.BLOCK_CHANGE);
20 | }
21 |
22 | @Override
23 | public void onPacketSending(PacketEvent event) {
24 | Player player = event.getPlayer();
25 | PlayerProtocol protocol = PluginBase.getProtocol(player);
26 | PacketContainer packet = event.getPacket();
27 | BlockPosition blockPosition = packet.getBlockPositionModifier().read(0);
28 | WrappedBlockData blockData = packet.getBlockData().read(0);
29 | ServerBlockChange serverBlockChange = new ServerBlockChange(blockPosition, blockData.getType());
30 | protocol.packetWorld.worldChange(serverBlockChange);
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/TeleportListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import ai.idealistic.spartan.listeners.bukkit.TeleportEvent;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketEvent;
11 | import org.bukkit.Location;
12 | import org.bukkit.entity.Player;
13 |
14 | public class TeleportListener extends PacketAdapter {
15 |
16 | public static final PacketType[] packetTypes = new PacketType[]{
17 | PacketType.Play.Server.POSITION,
18 | PacketType.Play.Server.RESPAWN
19 | };
20 |
21 | public TeleportListener() {
22 | super(
23 | Register.plugin,
24 | ListenerPriority.HIGHEST,
25 | packetTypes
26 | );
27 | }
28 |
29 | @Override
30 | public void onPacketSending(PacketEvent event) {
31 | Player player = event.getPlayer();
32 | PlayerProtocol protocol = PluginBase.getProtocol(player);
33 |
34 | if (protocol.isBedrockPlayer()) {
35 | return;
36 | }
37 | PacketType packetType = event.getPacket().getType();
38 |
39 | if (packetType.equals(PacketType.Play.Server.POSITION)) {
40 | TeleportEvent.teleport(player, true, event);
41 |
42 | } else if (packetType.equals(PacketType.Play.Server.RESPAWN)) {
43 | TeleportEvent.respawn(player, true, event);
44 | }
45 | }
46 |
47 | public static Location add(Location f, Location t) {
48 | return new Location(
49 | t.getWorld(),
50 | f.getX() + t.getX(),
51 | f.getY() + t.getY(),
52 | f.getZ() + t.getZ()
53 | );
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/TridentListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.event.CPlayerRiptideEvent;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import ai.idealistic.spartan.listeners.bukkit.TridentEvent;
9 | import com.comphenix.protocol.PacketType;
10 | import com.comphenix.protocol.events.ListenerPriority;
11 | import com.comphenix.protocol.events.PacketAdapter;
12 | import com.comphenix.protocol.events.PacketEvent;
13 | import org.bukkit.Material;
14 | import org.bukkit.entity.Player;
15 | import org.bukkit.inventory.ItemStack;
16 | import org.bukkit.util.Vector;
17 |
18 | public class TridentListener extends PacketAdapter {
19 |
20 | public TridentListener() {
21 | super(
22 | Register.plugin,
23 | ListenerPriority.LOWEST,
24 | PacketType.Play.Client.USE_ITEM,
25 | PacketType.Play.Client.BLOCK_DIG
26 | );
27 | }
28 |
29 | @Override
30 | public void onPacketReceiving(PacketEvent event) {
31 | if (!event.isCancelled()) { // PlayerRiptideEvent does not implement cancellable
32 | Player player = event.getPlayer();
33 | PlayerProtocol protocol = PluginBase.getProtocol(player);
34 | if (protocol.isBedrockPlayer()) {
35 | return;
36 | }
37 | ItemStack item = protocol.getInventory().getItemInMainHand();
38 |
39 | if (item.getType().equals(Material.TRIDENT)) {
40 | double r = Math.toRadians(protocol.getLocation().getYaw());
41 |
42 | CheckThread.run(() -> TridentEvent.event(
43 | new CPlayerRiptideEvent(
44 | protocol,
45 | item,
46 | new Vector(-Math.sin(r), protocol.getLocation().getPitch() / 90, Math.cos(r))
47 | ),
48 | true
49 | ));
50 | }
51 | }
52 | }
53 |
54 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/UseEntityListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketContainer;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import com.comphenix.protocol.wrappers.EnumWrappers;
13 | import org.bukkit.entity.Entity;
14 | import org.bukkit.entity.Player;
15 | import org.bukkit.entity.Vehicle;
16 | import org.bukkit.event.vehicle.VehicleEnterEvent;
17 |
18 | public class UseEntityListener extends PacketAdapter {
19 |
20 | public UseEntityListener() {
21 | super(Register.plugin, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY);
22 | }
23 |
24 | @Override
25 | public void onPacketReceiving(PacketEvent event) {
26 | Player player = event.getPlayer();
27 | PlayerProtocol protocol = PluginBase.getProtocol(player);
28 | PacketContainer packet = event.getPacket();
29 | int entityId = packet.getIntegers().read(0);
30 |
31 | CheckThread.run(() -> {
32 | if ((!packet.getEntityUseActions().getValues().isEmpty())
33 | ? !packet.getEntityUseActions().read(0).equals(EnumWrappers.EntityUseAction.ATTACK)
34 | : !packet.getEnumEntityUseActions().read(0).getAction().equals(
35 | EnumWrappers.EntityUseAction.ATTACK)) {
36 | Entity t = null;
37 | for (Entity entity : protocol.getNearbyEntities(5)) {
38 | if (entity.getEntityId() == entityId) {
39 | t = entity;
40 | break;
41 | }
42 | }
43 | if (t instanceof Vehicle) {
44 | protocol.executeRunners(
45 | false,
46 | new VehicleEnterEvent(null, player)
47 | );
48 | }
49 | }
50 | });
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/VelocityListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.event.CPlayerVelocityEvent;
5 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
6 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import ai.idealistic.spartan.listeners.bukkit.VelocityEvent;
9 | import com.comphenix.protocol.PacketType;
10 | import com.comphenix.protocol.events.ListenerPriority;
11 | import com.comphenix.protocol.events.PacketAdapter;
12 | import com.comphenix.protocol.events.PacketContainer;
13 | import com.comphenix.protocol.events.PacketEvent;
14 | import org.bukkit.entity.Player;
15 | import org.bukkit.util.Vector;
16 |
17 | public class VelocityListener extends PacketAdapter {
18 |
19 |
20 | public VelocityListener() {
21 | super(
22 | Register.plugin,
23 | ListenerPriority.MONITOR,
24 | PacketType.Play.Server.ENTITY_VELOCITY
25 | );
26 | }
27 |
28 | @Override
29 | public void onPacketSending(PacketEvent event) {
30 | Player player = event.getPlayer();
31 | PlayerProtocol protocol = PluginBase.getProtocol(player);
32 |
33 | if (protocol.isBedrockPlayer()) {
34 | return;
35 | }
36 | PacketContainer packet = event.getPacket();
37 |
38 | if (!packet.getIntegers().getValues().isEmpty()) {
39 | int id = packet.getIntegers().getValues().get(0);
40 | if (protocol.getEntityId() == id) {
41 | CheckThread.run(() -> {
42 | double x = packet.getIntegers().read(1).doubleValue() / 8000.0D,
43 | y = packet.getIntegers().read(2).doubleValue() / 8000.0D,
44 | z = packet.getIntegers().read(3).doubleValue() / 8000.0D;
45 | CPlayerVelocityEvent velocityEvent = new CPlayerVelocityEvent(player, new Vector(x, y, z));
46 | velocityEvent.setCancelled(event.isCancelled());
47 | VelocityEvent.event(velocityEvent, true);
48 | });
49 | }
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/standalone/BlockPlaceBalancerListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol.standalone;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.compatibility.necessary.protocollib.ProtocolLib;
6 | import ai.idealistic.spartan.functionality.server.MultiVersion;
7 | import ai.idealistic.spartan.functionality.server.PluginBase;
8 | import com.comphenix.protocol.PacketType;
9 | import com.comphenix.protocol.events.ListenerPriority;
10 | import com.comphenix.protocol.events.PacketAdapter;
11 | import com.comphenix.protocol.events.PacketEvent;
12 | import org.bukkit.entity.Player;
13 |
14 | /*
15 | That's not mean event after block place...
16 | That's mean just Block place packet.
17 | Need to fix timer falsest.
18 | Minecraft's developers mixed up the names of packets,
19 | and BLOCK_PLACE = USE_ITEM
20 | */
21 | public class BlockPlaceBalancerListener extends PacketAdapter {
22 |
23 | public BlockPlaceBalancerListener() {
24 | super(
25 | Register.plugin,
26 | ListenerPriority.HIGHEST,
27 | resolvePacketTypes()
28 | );
29 | }
30 |
31 | @Override
32 | public void onPacketReceiving(PacketEvent event) {
33 | Player player = event.getPlayer();
34 | PlayerProtocol protocol = PluginBase.getProtocol(player);
35 | protocol.timerBalancer.addBalance(50);
36 | }
37 |
38 | private static PacketType[] resolvePacketTypes() {
39 | if (MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_9)) {
40 | return new PacketType[]{PacketType.Play.Client.USE_ITEM,
41 | ProtocolLib.isPacketSupported("USE_ITEM_ON")
42 | ? PacketType.Play.Client.USE_ITEM_ON
43 | : PacketType.Play.Client.BLOCK_PLACE};
44 | } else {
45 | return new PacketType[]{
46 | ProtocolLib.isPacketSupported("USE_ITEM_ON")
47 | ? PacketType.Play.Client.USE_ITEM_ON
48 | : PacketType.Play.Client.BLOCK_PLACE};
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/standalone/EntityActionListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol.standalone;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.concurrent.CheckThread;
6 | import ai.idealistic.spartan.functionality.server.PluginBase;
7 | import com.comphenix.protocol.PacketType;
8 | import com.comphenix.protocol.events.ListenerPriority;
9 | import com.comphenix.protocol.events.PacketAdapter;
10 | import com.comphenix.protocol.events.PacketEvent;
11 |
12 | public class EntityActionListener extends PacketAdapter {
13 |
14 | private enum AbilitiesEnum {
15 | START_SPRINTING,
16 | STOP_SPRINTING,
17 | PRESS_SHIFT_KEY,
18 | RELEASE_SHIFT_KEY
19 | }
20 |
21 | public EntityActionListener() {
22 | super(
23 | Register.plugin,
24 | ListenerPriority.HIGHEST,
25 | PacketType.Play.Client.ENTITY_ACTION
26 | );
27 | }
28 |
29 | @Override
30 | public void onPacketReceiving(PacketEvent event) {
31 | PlayerProtocol protocol = PluginBase.getProtocol(event.getPlayer());
32 |
33 | if (protocol.isBedrockPlayer()) {
34 | return;
35 | }
36 | CheckThread.run(() -> {
37 | if (event.getPacket().getModifier().getValues().size() > 1) {
38 | String typeString = event.getPacket().getModifier().getValues().get(1).toString();
39 | AbilitiesEnum type = getEnum(typeString);
40 |
41 | if (typeString != null) {
42 | if (type == AbilitiesEnum.PRESS_SHIFT_KEY) {
43 | protocol.sneaking = true;
44 | } else if (type == AbilitiesEnum.RELEASE_SHIFT_KEY) {
45 | protocol.sneaking = false;
46 | } else if (type == AbilitiesEnum.START_SPRINTING) {
47 | protocol.sprinting = true;
48 | } else if (type == AbilitiesEnum.STOP_SPRINTING) {
49 | protocol.sprinting = false;
50 | }
51 | }
52 | }
53 | });
54 | }
55 |
56 | private AbilitiesEnum getEnum(String s) {
57 | for (AbilitiesEnum type : AbilitiesEnum.values()) {
58 | if (type.toString().equals(s)) {
59 | return type;
60 | }
61 | }
62 | return null;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/standalone/JoinListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol.standalone;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
5 | import ai.idealistic.spartan.functionality.server.PluginBase;
6 | import com.comphenix.protocol.PacketType;
7 | import com.comphenix.protocol.events.ListenerPriority;
8 | import com.comphenix.protocol.events.PacketAdapter;
9 | import com.comphenix.protocol.events.PacketEvent;
10 | import org.bukkit.Bukkit;
11 | import org.bukkit.entity.Player;
12 |
13 | public class JoinListener extends PacketAdapter {
14 |
15 | public JoinListener() {
16 | super(
17 | Register.plugin,
18 | ListenerPriority.HIGHEST,
19 | PacketType.Play.Server.LOGIN
20 | );
21 | }
22 |
23 | @Override
24 | public void onPacketSending(PacketEvent event) {
25 | Player player = event.getPlayer();
26 | PlayerProtocol protocol = PluginBase.getProtocol(player);
27 |
28 | if (protocol.isBedrockPlayer()) {
29 | return;
30 | }
31 | LegacyLagCompensationListener.newPacket(protocol.getEntityId());
32 | protocol.transactionBoot = true;
33 | Bukkit.getScheduler().runTaskLater(Register.plugin, () -> {
34 | if (protocol.getVehicle() != null) {
35 | protocol.entityHandle = true;
36 | }
37 | }, 1L);
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/listeners/protocol/standalone/LegacyLagCompensationListener.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.listeners.protocol.standalone;
2 |
3 | import ai.idealistic.spartan.functionality.server.TPS;
4 | import ai.idealistic.spartan.utils.java.OverflowMap;
5 | import org.bukkit.Location;
6 |
7 | import java.util.*;
8 | import java.util.concurrent.ConcurrentHashMap;
9 |
10 | public class LegacyLagCompensationListener {
11 |
12 | private static final Map> cache =
13 | new OverflowMap<>(new ConcurrentHashMap<>(), 1_024);
14 | private static final Map lastPacket =
15 | new OverflowMap<>(new ConcurrentHashMap<>(), 1_024);
16 | private static final Map> delays =
17 | new OverflowMap<>(new ConcurrentHashMap<>(), 1_024);
18 |
19 | public static void add(int id, Location location) {
20 | cache.computeIfAbsent(
21 | id,
22 | k -> new LinkedList<>()
23 | ).addFirst(location);
24 | List delaysList = delays.computeIfAbsent(
25 | id,
26 | k -> Collections.synchronizedList(new LinkedList<>())
27 | );
28 | delaysList.add((int) (System.currentTimeMillis() - lastPacket.getOrDefault(id, System.currentTimeMillis())));
29 | lastPacket.put(id, System.currentTimeMillis());
30 | newPacket(id);
31 |
32 | if (delaysList.size() == 10) {
33 | List l = Collections.synchronizedList(new LinkedList<>());
34 | l.add(Collections.max(delaysList) / 2);
35 | delays.put(id, l);
36 | }
37 | }
38 |
39 | public static void newPacket(int id) {
40 | lastPacket.put(id, System.currentTimeMillis());
41 | }
42 |
43 | public static Location getLocationWithTickRollback(int id, int ticks) {
44 | LinkedList locationStack = cache.get(id);
45 |
46 | if (locationStack == null || locationStack.isEmpty()) {
47 | return null;
48 | } else {
49 | return locationStack.get((ticks >= locationStack.size()) ? locationStack.size() - 1 : ticks);
50 | }
51 | }
52 |
53 | public static int getPlayerTicksDelay(int id) {
54 | List delaysList = delays.get(id);
55 |
56 | if (delaysList != null) {
57 | List snapshot;
58 |
59 | synchronized (delaysList) {
60 | snapshot = new ArrayList<>(delaysList);
61 | }
62 | return Collections.max(snapshot) / TPS.tickTimeInteger;
63 | }
64 | return 0;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/java/Pair.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.java;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 |
6 | @Data
7 | @AllArgsConstructor
8 | public final class Pair {
9 | private X x;
10 | private Y y;
11 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/java/ReflectionUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.java;
2 |
3 | import lombok.experimental.UtilityClass;
4 |
5 | import java.io.File;
6 | import java.lang.reflect.Field;
7 | import java.lang.reflect.Method;
8 | import java.net.URL;
9 | import java.net.URLClassLoader;
10 |
11 | @UtilityClass
12 | public class ReflectionUtils {
13 |
14 | public static Class> getClass(String s) {
15 | try {
16 | return Class.forName(s);
17 | } catch (Exception e) {
18 | return null;
19 | }
20 | }
21 |
22 | public static boolean classExists(String s) {
23 | try {
24 | Class.forName(s);
25 | } catch (ClassNotFoundException e) {
26 | return false;
27 | }
28 | return true;
29 | }
30 |
31 | public static Object getFieldFromJar(String jarFilePath, String className, String fieldName) {
32 | try {
33 | // Convert the file path to a URL
34 | File jarFile = new File(jarFilePath);
35 | URL jarURL = jarFile.toURI().toURL();
36 |
37 | // Create a URLClassLoader to load the JAR file
38 | try (URLClassLoader classLoader = new URLClassLoader(new URL[]{jarURL})) {
39 | // Load the class dynamically
40 | Class> clazz = classLoader.loadClass(className);
41 |
42 | // Get the field from the class
43 | Field field = clazz.getDeclaredField(fieldName);
44 | field.setAccessible(true); // In case the field is private or protected
45 |
46 | // Return the value of the field (static or instance-based)
47 | return field.get(null); // For static fields, pass 'null'
48 | }
49 | } catch (Exception e) {
50 | return null;
51 | }
52 | }
53 |
54 | public static Object invokeMethodFromJar(String jarFilePath, String className, String methodName,
55 | Class>[] parameterTypes, Object[] args) {
56 | try {
57 | // Convert the file path to a URL
58 | File jarFile = new File(jarFilePath);
59 | URL jarURL = jarFile.toURI().toURL();
60 |
61 | // Create a URLClassLoader to load the JAR file
62 | try (URLClassLoader classLoader = new URLClassLoader(new URL[]{jarURL})) {
63 | // Load the class dynamically
64 | Class> clazz = classLoader.loadClass(className);
65 |
66 | // Get the method from the class
67 | Method method = clazz.getDeclaredMethod(methodName, parameterTypes);
68 | method.setAccessible(true); // In case the method is private or protected
69 |
70 | // Invoke the method (pass 'null' for static methods or an instance for instance methods)
71 | // For static methods, use 'null'
72 | // Return the result (casting to the expected return type)
73 | return method.invoke(null, args);
74 | }
75 | } catch (Exception e) {
76 | return null;
77 | }
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/java/RequestUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.java;
2 |
3 | import lombok.experimental.UtilityClass;
4 |
5 | import javax.net.ssl.HttpsURLConnection;
6 | import java.io.BufferedReader;
7 | import java.io.DataOutputStream;
8 | import java.io.InputStreamReader;
9 | import java.net.URL;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | @UtilityClass
14 | public class RequestUtils {
15 |
16 | public static final int defaultTimeOut = 30_000;
17 |
18 | public static String[] get(String link, String method, String message, int timeOut) throws Exception {
19 | boolean isPost = method.equals("POST");
20 | String[] split = link.split(" ");
21 |
22 | URL url = new URL(split[0]);
23 | HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
24 | connection.addRequestProperty("User-Agent",
25 | "1" + (message != null ? " (" + message + ")" : ""));
26 | connection.setRequestMethod(method);
27 | connection.setReadTimeout(timeOut);
28 | connection.setDoOutput(true);
29 | connection.connect();
30 |
31 | if (isPost && split.length > 1) {
32 | DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
33 | wr.writeBytes(split[1]);
34 | wr.flush();
35 | wr.close();
36 | }
37 |
38 | BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
39 | List array = new ArrayList<>(50);
40 | String line;
41 |
42 | while ((line = in.readLine()) != null) {
43 | array.add(line);
44 | }
45 | in.close();
46 | return array.toArray(new String[0]);
47 | }
48 |
49 | public static String[] get(String link, String method) throws Exception {
50 | return get(link, method, null, defaultTimeOut);
51 | }
52 |
53 | public static String[] get(String link, int timeOut) throws Exception {
54 | return get(link, "GET", null, timeOut);
55 | }
56 |
57 | public static String[] get(String link) throws Exception {
58 | return get(link, "GET", null, defaultTimeOut);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/java/TimeUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.java;
2 |
3 | import lombok.experimental.UtilityClass;
4 |
5 | @UtilityClass
6 | public class TimeUtils {
7 |
8 | public static String convertMilliseconds(long milliseconds) {
9 | final long millisecondsPerSecond = 1000;
10 | final long millisecondsPerMinute = millisecondsPerSecond * 60;
11 | final long millisecondsPerHour = millisecondsPerMinute * 60;
12 | final long millisecondsPerDay = millisecondsPerHour * 24;
13 | final long millisecondsPerWeek = millisecondsPerDay * 7;
14 |
15 | // Average time calculations
16 | final double daysPerMonth = 30.44;
17 | final double daysPerYear = 365.25;
18 | final long millisecondsPerMonth = (long) (millisecondsPerDay * daysPerMonth);
19 | final long millisecondsPerYear = (long) (millisecondsPerDay * daysPerYear);
20 |
21 | long remainingMilliseconds = milliseconds;
22 |
23 | long years = remainingMilliseconds / millisecondsPerYear;
24 | remainingMilliseconds %= millisecondsPerYear;
25 |
26 | long months = remainingMilliseconds / millisecondsPerMonth;
27 | remainingMilliseconds %= millisecondsPerMonth;
28 |
29 | long weeks = remainingMilliseconds / millisecondsPerWeek;
30 | remainingMilliseconds %= millisecondsPerWeek;
31 |
32 | long days = remainingMilliseconds / millisecondsPerDay;
33 | remainingMilliseconds %= millisecondsPerDay;
34 |
35 | long hours = remainingMilliseconds / millisecondsPerHour;
36 | remainingMilliseconds %= millisecondsPerHour;
37 |
38 | long minutes = remainingMilliseconds / millisecondsPerMinute;
39 | remainingMilliseconds %= millisecondsPerMinute;
40 |
41 | long seconds = remainingMilliseconds / millisecondsPerSecond;
42 |
43 | StringBuilder timeBuilder = new StringBuilder();
44 |
45 | if (years > 0) timeBuilder.append(years).append("y ");
46 | if (months > 0) timeBuilder.append(months).append("m ");
47 | if (weeks > 0) timeBuilder.append(weeks).append("w ");
48 | if (days > 0) timeBuilder.append(days).append("d ");
49 | if (hours > 0) timeBuilder.append(hours).append("h ");
50 | if (minutes > 0) timeBuilder.append(minutes).append("m ");
51 | if (seconds > 0 || timeBuilder.length() == 0)
52 | timeBuilder.append(seconds).append("s ");
53 |
54 | return timeBuilder.toString().trim();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/java/TryIgnore.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.java;
2 |
3 | import lombok.experimental.UtilityClass;
4 |
5 | import java.util.Optional;
6 | import java.util.function.Consumer;
7 | import java.util.function.Predicate;
8 |
9 | @UtilityClass
10 | public class TryIgnore {
11 |
12 | public static ThrowableHandler throwableHandler = Throwable::printStackTrace;
13 | public static T unchecked(SupplierThrows supplier) {
14 | try {
15 | return supplier.get();
16 | } catch(Exception e) {
17 | doThrow0(e);
18 | throw new AssertionError();
19 | }
20 | }
21 | public static void unchecked(RunnableThrows runnable) {
22 | try {
23 | runnable.run();
24 | } catch(Exception e) {
25 | doThrow0(e);
26 | throw new AssertionError();
27 | }
28 | }
29 | public static Predicate unchecked(PredicateThrows predicate) {
30 | return t -> {
31 | try {
32 | return predicate.test(t);
33 | } catch(Exception e) {
34 | doThrow0(e);
35 | throw new AssertionError();
36 | }
37 | };
38 | }
39 |
40 | public static T ignore(SupplierThrows supplier, T def) {
41 | try {
42 | return supplier.get();
43 | } catch(Throwable e) {
44 | throwableHandler.handle(e);
45 | return def;
46 | }
47 | }
48 | public static Optional ignore(RunnableThrows runnable) {
49 | try {
50 | runnable.run();
51 | } catch(Throwable e) {
52 | throwableHandler.handle(e);
53 | return Optional.of(e);
54 | }
55 | return Optional.empty();
56 | }
57 |
58 | public static Optional ignore(RunnableThrows runnable, Consumer consumer) {
59 | try {
60 | runnable.run();
61 | } catch(Throwable e) {
62 | consumer.accept(e);
63 | throwableHandler.handle(e);
64 | return Optional.of(e);
65 | }
66 | return Optional.empty();
67 | }
68 |
69 | public static Predicate ignore(PredicateThrows predicate, boolean def) {
70 | return t -> {
71 | try {
72 | return predicate.test(t);
73 | } catch(Throwable e) {
74 | throwableHandler.handle(e);
75 | return def;
76 | }
77 | };
78 | }
79 |
80 | @SuppressWarnings("unchecked")
81 | public static void doThrow0(Throwable e) throws E {
82 | throw (E) e;
83 | }
84 |
85 | public interface SupplierThrows {
86 |
87 | T get() throws Exception;
88 | }
89 |
90 | public interface RunnableThrows {
91 |
92 | void run() throws Exception;
93 | }
94 |
95 | public interface PredicateThrows {
96 |
97 | boolean test(T val) throws Exception;
98 | }
99 |
100 | public interface ThrowableHandler {
101 |
102 | void handle(Throwable throwable);
103 | }
104 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/ClientMath.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math;
2 |
3 | public interface ClientMath {
4 | float sin(float value);
5 |
6 | float cos(float value);
7 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/OptifineMath.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math;
2 |
3 | public class OptifineMath implements ClientMath {
4 | private static final float[] SIN_TABLE_FAST = new float[4096];
5 | private static final float radToIndex = roundToFloat(651.8986469044033D);
6 |
7 | static {
8 | for (int j = 0; j < SIN_TABLE_FAST.length; ++j) {
9 | SIN_TABLE_FAST[j] = roundToFloat(Math.sin((double) j * Math.PI * 2.0D / 4096.0D));
10 | }
11 | }
12 |
13 | @Override
14 | public float sin(float value) {
15 | return SIN_TABLE_FAST[(int) (value * radToIndex) & 4095];
16 | }
17 |
18 | @Override
19 | public float cos(float value) {
20 | return SIN_TABLE_FAST[(int) (value * radToIndex + 1024.0F) & 4095];
21 | }
22 |
23 | public static float roundToFloat(double d) {
24 | return (float) ((double) Math.round(d * 1.0E8D) / 1.0E8D);
25 | }
26 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/RayLine.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 |
6 | @Data
7 | @AllArgsConstructor
8 | public class RayLine { public final double x, z;}
9 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/Sensitivity.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math;
2 |
3 | public class Sensitivity {
4 | public static float getGCD() {
5 | float f1 = (float) (0.5F * 0.6 + 0.2);
6 | return f1 * f1 * f1 * 8.0F;
7 | }
8 | public static float getGCDValue(int m) {
9 | return (getGCD() * 0.15F) * (float) m;
10 | }
11 | public static int calculateSensitivity(float deltaYaw) {
12 | for (int i = 1; i <= 200; i++) {
13 | float gcdValue = getGCDValue(i);
14 | float sensitivityRaw = deltaYaw / gcdValue;
15 | int sensitivity = (int) sensitivityRaw;
16 | if (Math.abs(sensitivityRaw - sensitivity) < 0.001) {
17 | return i;
18 | }
19 | }
20 | return -1;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/VanillaMath.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math;
2 |
3 | public class VanillaMath implements ClientMath {
4 | @Override
5 | public float sin(float value) {
6 | return MathHelper.sin(value);
7 | }
8 |
9 | @Override
10 | public float cos(float value) {
11 | return MathHelper.cos(value);
12 | }
13 |
14 | public static float sqrt(float f) {
15 | return (float) Math.sqrt(f);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/math/statistics/LinearRegression.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.math.statistics;
2 |
3 |
4 | import java.util.Collection;
5 |
6 | public class LinearRegression {
7 |
8 | private static double[] collectionToArray(Collection collection) {
9 | double[] array = new double[collection.size()];
10 | int counter = 0;
11 |
12 | for (Object dbl : collection) {
13 | array[counter] = (double) dbl;
14 | counter++;
15 | }
16 | return array;
17 | }
18 |
19 | public final double intercept, slope, r2, error;
20 | public final int observations;
21 |
22 | // y = b0 + b1 * x
23 | // b0 = intercept
24 | // b1 = slope
25 | // x = predictor
26 |
27 | public LinearRegression(double[] x, double[] y) {
28 | int n = x.length;
29 |
30 | if (n != y.length) {
31 | throw new IllegalArgumentException("Array lengths must be equal to each other");
32 | }
33 | observations = n;
34 | double meanY = 0.0,
35 | meanX = 0.0;
36 |
37 | // First: Calculate summaries & means
38 | for (int i = 0; i < n; i++) {
39 | meanY += y[i];
40 | meanX += x[i];
41 | }
42 | meanY /= n;
43 | meanX /= n;
44 |
45 | // Second: Find slope
46 | double xMinusBarX_sumPowered = 0.0,
47 | yMinusBarY_MultipliedBy_xMinusBarX_sum = 0.0;
48 |
49 | for (int i = 0; i < n; i++) {
50 | double yMinusBarY = y[i] - meanY,
51 | xMinusBarX = x[i] - meanX;
52 | yMinusBarY_MultipliedBy_xMinusBarX_sum += yMinusBarY * xMinusBarX;
53 | xMinusBarX_sumPowered += xMinusBarX * xMinusBarX;
54 | }
55 | this.slope = yMinusBarY_MultipliedBy_xMinusBarX_sum / xMinusBarX_sumPowered;
56 | this.intercept = meanY - (this.slope * meanX);
57 |
58 | // Third: Find R-Squared
59 | double yPredictedMinusBarY_sumPowered = 0.0,
60 | yMinusBarY_sumPowered = 0.0,
61 | yPredictedMinusY_sumPowered = 0.0;
62 |
63 | for (int i = 0; i < n; i++) {
64 | double yCurrent = y[i],
65 | yPredicted = predictY(x[i]),
66 | yPredictedMinusY = yPredicted - yCurrent,
67 | yPredictedMinusBarY = yPredicted - meanY,
68 | yMinusBarY = yCurrent - meanY;
69 | yPredictedMinusBarY_sumPowered += yPredictedMinusBarY * yPredictedMinusBarY;
70 | yMinusBarY_sumPowered += yMinusBarY * yMinusBarY;
71 | yPredictedMinusY_sumPowered += yPredictedMinusY * yPredictedMinusY;
72 | }
73 | this.r2 = yPredictedMinusBarY_sumPowered / yMinusBarY_sumPowered;
74 | this.error = Math.sqrt(yPredictedMinusY_sumPowered / (n - 2));
75 | }
76 |
77 | public LinearRegression(Collection x, Collection y) {
78 | this(collectionToArray(x), collectionToArray(y));
79 | }
80 |
81 | public double predictY(double x) {
82 | return intercept + (slope * x);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/entity/EntityUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.entity;
2 |
3 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
4 |
5 | public class EntityUtils {
6 |
7 | public static final boolean abstractHorseClass = ReflectionUtils.classExists(
8 | "org.bukkit.entity.AbstractHorse"
9 | );
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/entity/MovingObjectPosition.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.entity;
2 |
3 | import ai.idealistic.spartan.utils.minecraft.vector.Vec3;
4 | import ai.idealistic.spartan.utils.minecraft.world.BlockPos;
5 | import ai.idealistic.spartan.utils.minecraft.world.EnumFacing;
6 |
7 | public class MovingObjectPosition {
8 | private BlockPos blockPos;
9 |
10 | /**
11 | * What type of ray trace hit was this? 0 = block, 1 = entity
12 | */
13 | public MovingObjectType typeOfHit;
14 | public EnumFacing sideHit;
15 |
16 | /**
17 | * The vector position of the hit
18 | */
19 | public Vec3 hitVec;
20 |
21 | /**
22 | * The hit entity
23 | */
24 | // public Entity entityHit;
25 | public MovingObjectPosition(Vec3 hitVecIn, EnumFacing facing, BlockPos blockPosIn) {
26 | this(MovingObjectType.BLOCK, hitVecIn, facing, blockPosIn);
27 | }
28 |
29 | public MovingObjectPosition(Vec3 p_i45552_1_, EnumFacing facing) {
30 | this(MovingObjectType.BLOCK, p_i45552_1_, facing, BlockPos.ORIGIN);
31 | }
32 |
33 | // public MovingObjectPosition(Entity p_i2304_1_)
34 | // {
35 | // this(p_i2304_1_, new Vec3(p_i2304_1_.locX, p_i2304_1_.locY, p_i2304_1_.locZ));
36 | // }
37 |
38 | public MovingObjectPosition(MovingObjectType typeOfHitIn, Vec3 hitVecIn, EnumFacing sideHitIn, BlockPos blockPosIn) {
39 | this.typeOfHit = typeOfHitIn;
40 | this.blockPos = blockPosIn;
41 | this.sideHit = sideHitIn;
42 | this.hitVec = new Vec3(hitVecIn.xCoord, hitVecIn.yCoord, hitVecIn.zCoord);
43 | }
44 |
45 | // public MovingObjectPosition(Entity entityHitIn, Vec3 hitVecIn)
46 | // {
47 | // this.typeOfHit = MovingObjectType.ENTITY;
48 | // this.entityHit = entityHitIn;
49 | // this.hitVec = hitVecIn;
50 | // }
51 |
52 | public MovingObjectPosition(Vec3 hitVecIn) {
53 | this.typeOfHit = MovingObjectType.ENTITY;
54 | // this.entityHit = null;
55 | this.hitVec = hitVecIn;
56 | }
57 |
58 | public BlockPos getBlockPos() {
59 | return this.blockPos;
60 | }
61 |
62 | public String toString() {
63 | return "HitResult{type=" + this.typeOfHit + ", blockpos=" + this.blockPos + ", f=" + this.sideHit + ", pos=" + this.hitVec + '}';
64 | }
65 |
66 | public static enum MovingObjectType {
67 | MISS,
68 | BLOCK,
69 | ENTITY;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/entity/PotionEffectUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.entity;
2 |
3 | import org.bukkit.potion.PotionEffectType;
4 |
5 | public class PotionEffectUtils {
6 |
7 | public static final PotionEffectType
8 | JUMP,
9 | FAST_DIGGING,
10 | SLOW_DIGGING;
11 |
12 | static {
13 | PotionEffectType effect = PotionEffectType.getByName("JUMP");
14 |
15 | if (effect == null) {
16 | effect = PotionEffectType.JUMP_BOOST;
17 | }
18 | JUMP = effect;
19 |
20 | effect = PotionEffectType.getByName("FAST_DIGGING");
21 |
22 | if (effect == null) {
23 | effect = PotionEffectType.HASTE;
24 | }
25 | FAST_DIGGING = effect;
26 |
27 | effect = PotionEffectType.getByName("SLOW_DIGGING");
28 |
29 | if (effect == null) {
30 | effect = PotionEffectType.MINING_FATIGUE;
31 | }
32 | SLOW_DIGGING = effect;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/inventory/BackgroundInventoryUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.inventory;
2 |
3 | import ai.idealistic.spartan.functionality.server.MultiVersion;
4 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.Material;
7 | import org.bukkit.OfflinePlayer;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.meta.SkullMeta;
10 | import org.bukkit.profile.PlayerProfile;
11 |
12 | public class BackgroundInventoryUtils {
13 |
14 | private static final boolean paperProfile = ReflectionUtils.classExists(
15 | "com.destroystokyo.paper.profile.PlayerProfile"
16 | );
17 |
18 | static ItemStack getSkull_v1_13(OfflinePlayer offlinePlayer, String backupName, boolean create) {
19 | ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
20 |
21 | if (offlinePlayer != null) {
22 | SkullMeta meta = (SkullMeta) skull.getItemMeta();
23 |
24 | if (create
25 | && !offlinePlayer.hasPlayedBefore()
26 | && MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_18)) {
27 | String name = offlinePlayer.getName();
28 |
29 | if (name == null) {
30 | name = backupName;
31 | PlayerProfile profile;
32 |
33 | if (paperProfile) {
34 | if (name == null) {
35 | profile = Bukkit.createProfile(offlinePlayer.getUniqueId());
36 | } else {
37 | profile = Bukkit.createProfileExact(offlinePlayer.getUniqueId(), name);
38 | }
39 | } else if (name == null) {
40 | profile = Bukkit.createPlayerProfile(offlinePlayer.getUniqueId());
41 | } else {
42 | profile = Bukkit.createPlayerProfile(offlinePlayer.getUniqueId(), name);
43 | }
44 | meta.setOwnerProfile(profile);
45 | }
46 | } else {
47 | meta.setOwningPlayer(offlinePlayer);
48 | }
49 | skull.setItemMeta(meta);
50 | }
51 | return skull;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/inventory/EnchantmentUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.inventory;
2 |
3 | import org.bukkit.enchantments.Enchantment;
4 |
5 | public class EnchantmentUtils {
6 |
7 | public static final Enchantment
8 | ARROW_KNOCKBACK,
9 | DURABILITY,
10 | WATER_WORKER,
11 | DIG_SPEED;
12 |
13 | static {
14 | Enchantment enchantment = findEnchantment("ARROW_KNOCKBACK");
15 |
16 | if (enchantment == null) {
17 | enchantment = Enchantment.PUNCH;
18 | }
19 | ARROW_KNOCKBACK = enchantment;
20 |
21 | enchantment = findEnchantment("DURABILITY");
22 |
23 | if (enchantment == null) {
24 | enchantment = Enchantment.UNBREAKING;
25 | }
26 | DURABILITY = enchantment;
27 |
28 | enchantment = findEnchantment("WATER_WORKER");
29 |
30 | if (enchantment == null) {
31 | enchantment = Enchantment.AQUA_AFFINITY;
32 | }
33 | WATER_WORKER = enchantment;
34 |
35 | enchantment = findEnchantment("DIG_SPEED");
36 |
37 | if (enchantment == null) {
38 | enchantment = Enchantment.EFFICIENCY;
39 | }
40 | DIG_SPEED = enchantment;
41 | }
42 |
43 | private static Enchantment findEnchantment(String string) {
44 | for (Enchantment enchantment : Enchantment.values()) {
45 | if (enchantment.getName().equalsIgnoreCase(string)) {
46 | return enchantment;
47 | }
48 | }
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/inventory/InventoryUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.inventory;
2 |
3 | import ai.idealistic.spartan.functionality.server.MultiVersion;
4 | import ai.idealistic.spartan.utils.java.ReflectionUtils;
5 | import org.bukkit.Material;
6 | import org.bukkit.OfflinePlayer;
7 | import org.bukkit.SkullType;
8 | import org.bukkit.inventory.Inventory;
9 | import org.bukkit.inventory.ItemStack;
10 | import org.bukkit.inventory.meta.ItemMeta;
11 | import org.bukkit.inventory.meta.SkullMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class InventoryUtils {
17 |
18 | private static final boolean bukkitProfile =
19 | MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_13)
20 | && ReflectionUtils.classExists("org.bukkit.profile.PlayerProfile");
21 |
22 | public static void add(Inventory inv, String name, List lore, ItemStack item, int slot) {
23 | ItemMeta am = item.getItemMeta();
24 | am.setDisplayName(name);
25 |
26 | if (lore != null) {
27 | am.setLore(lore);
28 | }
29 | item.setItemMeta(am);
30 |
31 | if (slot != -1) {
32 | inv.setItem(slot, item);
33 | } else {
34 | inv.addItem(item);
35 | }
36 | }
37 |
38 | public static ItemStack get(String name, ArrayList lore, ItemStack item) {
39 | ItemMeta am = item.getItemMeta();
40 | am.setDisplayName(name);
41 |
42 | if (lore != null) {
43 | am.setLore(lore);
44 | }
45 | item.setItemMeta(am);
46 | return item;
47 | }
48 |
49 | public static ItemStack getHead() {
50 | return new ItemStack(
51 | MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_13)
52 | ? Material.PLAYER_HEAD
53 | : Material.getMaterial("SKULL_ITEM"), 1, (short) SkullType.PLAYER.ordinal()
54 | );
55 | }
56 |
57 | public static ItemStack getSkull(OfflinePlayer offlinePlayer, String backupName, boolean create) {
58 | if (bukkitProfile) {
59 | return BackgroundInventoryUtils.getSkull_v1_13(offlinePlayer, backupName, create);
60 | } else {
61 | ItemStack skull = getHead();
62 | SkullMeta meta = (SkullMeta) skull.getItemMeta();
63 | String name = null;
64 |
65 | if (offlinePlayer != null) {
66 | name = offlinePlayer.getName();
67 | }
68 | if (name != null) {
69 | meta.setOwner(name);
70 | } else if (backupName != null) {
71 | meta.setOwner(backupName);
72 | }
73 | skull.setItemMeta(meta);
74 | return skull;
75 | }
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/protocol/ProtocolTools.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.protocol;
2 |
3 | import ai.idealistic.spartan.compatibility.necessary.protocollib.ProtocolLib;
4 | import ai.idealistic.spartan.functionality.server.MultiVersion;
5 | import ai.idealistic.spartan.listeners.protocol.MovementListener;
6 | import com.comphenix.protocol.PacketType;
7 | import com.comphenix.protocol.events.PacketContainer;
8 | import com.comphenix.protocol.events.PacketEvent;
9 | import org.bukkit.Location;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.HashSet;
13 | import java.util.Set;
14 |
15 | public class ProtocolTools {
16 |
17 | public static Location readLocation(PacketEvent event) {
18 | PacketContainer packet = event.getPacket();
19 |
20 | if (packet.getDoubles().size() >= 3) {
21 | return new Location(
22 | ProtocolLib.getWorld(event.getPlayer()),
23 | packet.getDoubles().read(0),
24 | packet.getDoubles().read(1),
25 | packet.getDoubles().read(2)
26 | );
27 | } else {
28 | return null;
29 | }
30 | }
31 |
32 | public static boolean isFlying(PacketEvent event, Location to, Location from) {
33 | PacketType p = event.getPacket().getType();
34 |
35 | if (p.equals(PacketType.Play.Client.POSITION)
36 | && to.toVector().equals(from.toVector())) {
37 | return true;
38 | } else {
39 | return p.equals(MultiVersion.isOrGreater(MultiVersion.MCVersion.V1_17)
40 | ? PacketType.Play.Client.GROUND
41 | : PacketType.Play.Client.FLYING);
42 | }
43 | }
44 |
45 | public static boolean onGroundPacketLevel(PacketEvent event) {
46 | PacketContainer packet = event.getPacket();
47 | return packet.getBooleans().size() > 0
48 | && packet.getBooleans().read(0);
49 | }
50 |
51 | public static Set getTeleportFlags(PacketEvent event) {
52 | String s = event.getPacket().getStructures().getValues().get(0).toString();
53 | Set flags = new HashSet<>(3);
54 | s = s.replace("X_ROT", "").replace("Y_ROT", "");
55 | if (s.contains("X")) flags.add(MovementListener.tpFlags.X);
56 | if (s.contains("Y")) flags.add(MovementListener.tpFlags.Y);
57 | if (s.contains("Z")) flags.add(MovementListener.tpFlags.Z);
58 | return flags;
59 | }
60 |
61 | public static boolean isLoadLocation(Location location) {
62 | return (location.getX() == 1 && location.getY() == 1 && location.getZ() == 1);
63 | }
64 |
65 | public static Location getLoadLocation(Player player) {
66 | return new Location(ProtocolLib.getWorld(player), 1, 1, 1);
67 | }
68 |
69 | public static boolean hasPosition(PacketType type) {
70 | return (type.equals(PacketType.Play.Client.POSITION)
71 | || type.equals(PacketType.Play.Client.POSITION_LOOK));
72 | }
73 |
74 | public static boolean hasRotation(PacketType type) {
75 | return (type.equals(PacketType.Play.Client.LOOK)
76 | || type.equals(PacketType.Play.Client.POSITION_LOOK));
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/server/PluginUtils.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.server;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.plugin.Plugin;
5 | import org.bukkit.plugin.PluginDescriptionFile;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | public class PluginUtils {
11 |
12 | public static List getDependentPlugins(String independent) {
13 | Plugin[] plugins = Bukkit.getPluginManager().getPlugins();
14 | List results = new ArrayList<>(plugins.length);
15 |
16 | for (Plugin p : plugins) {
17 | if (!p.getName().equals(independent)) {
18 | PluginDescriptionFile descriptionFile = p.getDescription();
19 | List dependentList = new ArrayList<>(descriptionFile.getDepend());
20 | dependentList.addAll(descriptionFile.getSoftDepend());
21 |
22 | if (!dependentList.isEmpty()) {
23 | for (String dependent : dependentList) {
24 | if (independent.equals(dependent)) {
25 | results.add(p);
26 | break;
27 | }
28 | }
29 | }
30 | }
31 | }
32 | return results;
33 | }
34 |
35 | public static boolean contains(String key) {
36 | String[] split = key.toLowerCase().split(" ");
37 |
38 | for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
39 | if (p.isEnabled()) {
40 | String plugin = p.getName().toLowerCase();
41 |
42 | for (String name : split) {
43 | if (plugin.contains(name)) {
44 | return true;
45 | }
46 | }
47 | }
48 | }
49 | return false;
50 | }
51 |
52 | public static boolean exists(String name) {
53 | for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
54 | if (p.isEnabled() && p.getName().equalsIgnoreCase(name)) {
55 | return true;
56 | }
57 | }
58 | return false;
59 | }
60 |
61 | public static Plugin get(String name) {
62 | for (Plugin p : Bukkit.getPluginManager().getPlugins()) {
63 | if (p.isEnabled() && p.getName().equalsIgnoreCase(name)) {
64 | return p;
65 | }
66 | }
67 | return null;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/vector/CVector2D.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.vector;
2 |
3 | public class CVector2D {
4 |
5 | public double x, y;
6 |
7 | public CVector2D(double x, double y) {
8 | this.x = x;
9 | this.y = y;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/ai/idealistic/spartan/utils/minecraft/vector/CVector2F.java:
--------------------------------------------------------------------------------
1 | package ai.idealistic.spartan.utils.minecraft.vector;
2 |
3 | public class CVector2F {
4 |
5 | public float x, y;
6 |
7 | public CVector2F(float x, float y) {
8 | this.x = x;
9 | this.y = y;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/CheckCancelEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class CheckCancelEvent extends Event implements Cancellable {
12 |
13 | private final Player p;
14 | private final HackType h;
15 | @Setter
16 | @Getter
17 | private boolean cancelled;
18 |
19 | public CheckCancelEvent(Player player, HackType HackType) {
20 | p = player;
21 | h = HackType;
22 | cancelled = false;
23 | }
24 |
25 | public Player getPlayer() {
26 | return p;
27 | }
28 |
29 | public HackType getHackType() {
30 | return h;
31 | }
32 |
33 | private static final HandlerList handlers = new HandlerList();
34 |
35 | public HandlerList getHandlers() {
36 | return handlers;
37 | }
38 |
39 | public static HandlerList getHandlerList() {
40 | return handlers;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/CheckPunishmentToggleEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class CheckPunishmentToggleEvent extends Event implements Cancellable {
12 |
13 | private final CheckEnums.HackType ht;
14 | private final Enums.ToggleAction ta;
15 | @Setter
16 | @Getter
17 | private boolean cancelled;
18 |
19 | public CheckPunishmentToggleEvent(CheckEnums.HackType hackType, Enums.ToggleAction toggleAction) {
20 | ht = hackType;
21 | ta = toggleAction;
22 | cancelled = false;
23 | }
24 |
25 | public CheckEnums.HackType getHackType() {
26 | return ht;
27 | }
28 |
29 | public Enums.ToggleAction getToggleAction() {
30 | return ta;
31 | }
32 |
33 | private static final HandlerList handlers = new HandlerList();
34 |
35 | public HandlerList getHandlers() {
36 | return handlers;
37 | }
38 |
39 | public static HandlerList getHandlerList() {
40 | return handlers;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/CheckSilentToggleEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class CheckSilentToggleEvent extends Event implements Cancellable {
12 |
13 | private final CheckEnums.HackType ht;
14 | private final Enums.ToggleAction ta;
15 | @Setter
16 | @Getter
17 | private boolean cancelled;
18 |
19 | public CheckSilentToggleEvent(CheckEnums.HackType hackType, Enums.ToggleAction toggleAction) {
20 | ht = hackType;
21 | ta = toggleAction;
22 | cancelled = false;
23 | }
24 |
25 | public CheckEnums.HackType getHackType() {
26 | return ht;
27 | }
28 |
29 | public Enums.ToggleAction getToggleAction() {
30 | return ta;
31 | }
32 |
33 | private static final HandlerList handlers = new HandlerList();
34 |
35 | public HandlerList getHandlers() {
36 | return handlers;
37 | }
38 |
39 | public static HandlerList getHandlerList() {
40 | return handlers;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/CheckToggleEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import me.vagdedes.spartan.api.system.Enums;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class CheckToggleEvent extends Event implements Cancellable {
12 |
13 | private final CheckEnums.HackType ht;
14 | private final Enums.ToggleAction ta;
15 | @Setter
16 | @Getter
17 | private boolean cancelled;
18 |
19 | public CheckToggleEvent(CheckEnums.HackType hackType, Enums.ToggleAction toggleAction) {
20 | ht = hackType;
21 | ta = toggleAction;
22 | cancelled = false;
23 | }
24 |
25 | public CheckEnums.HackType getHackType() {
26 | return ht;
27 | }
28 |
29 | public Enums.ToggleAction getToggleAction() {
30 | return ta;
31 | }
32 |
33 | private static final HandlerList handlers = new HandlerList();
34 |
35 | public HandlerList getHandlers() {
36 | return handlers;
37 | }
38 |
39 | public static HandlerList getHandlerList() {
40 | return handlers;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/LEGACY:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CheatSolutions/Spartan-AntiCheat/302d29982ffd495193cb89659e84255b2ee94091/src/main/java/me/vagdedes/spartan/api/LEGACY
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/PlayerFoundOreEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import lombok.Getter;
4 | import lombok.Setter;
5 | import org.bukkit.Location;
6 | import org.bukkit.Material;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.Cancellable;
9 | import org.bukkit.event.Event;
10 | import org.bukkit.event.HandlerList;
11 |
12 | public class PlayerFoundOreEvent extends Event implements Cancellable {
13 |
14 | private final Player p;
15 | private final String me;
16 | private final Location l;
17 | private final Material ma;
18 | @Setter
19 | @Getter
20 | private boolean cancelled;
21 |
22 | public PlayerFoundOreEvent(Player player, String message, Location location, Material material) {
23 | p = player;
24 | me = message;
25 | l = location;
26 | ma = material;
27 | cancelled = false;
28 | }
29 |
30 | public Player getPlayer() {
31 | return p;
32 | }
33 |
34 | public String getMessage() {
35 | return me;
36 | }
37 |
38 | public Location getLocation() {
39 | return l;
40 | }
41 |
42 | public Material getMaterial() {
43 | return ma;
44 | }
45 |
46 | private static final HandlerList handlers = new HandlerList();
47 |
48 | public HandlerList getHandlers() {
49 | return handlers;
50 | }
51 |
52 | public static HandlerList getHandlerList() {
53 | return handlers;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/PlayerViolationCommandEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class PlayerViolationCommandEvent extends Event implements Cancellable {
12 |
13 | private final Player p;
14 | private final HackType h;
15 | private final String c;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public PlayerViolationCommandEvent(Player player, HackType HackType, String command) {
21 | p = player;
22 | h = HackType;
23 | c = command;
24 | cancelled = false;
25 | }
26 |
27 | public Player getPlayer() {
28 | return p;
29 | }
30 |
31 | public HackType getHackType() {
32 | return h;
33 | }
34 |
35 | public String getCommand() {
36 | return c;
37 | }
38 |
39 | private static final HandlerList handlers = new HandlerList();
40 |
41 | public HandlerList getHandlers() {
42 | return handlers;
43 | }
44 |
45 | public static HandlerList getHandlerList() {
46 | return handlers;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/PlayerViolationEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.abstraction.check.CheckEnums.HackType;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.Cancellable;
8 | import org.bukkit.event.Event;
9 | import org.bukkit.event.HandlerList;
10 |
11 | public class PlayerViolationEvent extends Event implements Cancellable {
12 |
13 | private final Player p;
14 | private final HackType h;
15 | private final String m;
16 | @Setter
17 | @Getter
18 | private boolean cancelled;
19 |
20 | public PlayerViolationEvent(Player player, HackType HackType, String message) {
21 | p = player;
22 | h = HackType;
23 | m = message;
24 | cancelled = false;
25 | }
26 |
27 | public Player getPlayer() {
28 | return p;
29 | }
30 |
31 | public HackType getHackType() {
32 | return h;
33 | }
34 |
35 | public String getMessage() {
36 | return m;
37 | }
38 |
39 | private static final HandlerList handlers = new HandlerList();
40 |
41 | public HandlerList getHandlers() {
42 | return handlers;
43 | }
44 |
45 | public static HandlerList getHandlerList() {
46 | return handlers;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/me/vagdedes/spartan/api/SpartanReloadEvent.java:
--------------------------------------------------------------------------------
1 | package me.vagdedes.spartan.api;
2 |
3 | import ai.idealistic.spartan.Register;
4 | import org.bukkit.event.Cancellable;
5 | import org.bukkit.event.Event;
6 | import org.bukkit.event.HandlerList;
7 | import org.bukkit.plugin.Plugin;
8 |
9 | public class SpartanReloadEvent extends Event implements Cancellable {
10 |
11 | private boolean cancelled;
12 |
13 | public SpartanReloadEvent() {
14 | cancelled = false;
15 | }
16 |
17 | public Plugin getPlugin() {
18 | return Register.plugin;
19 | }
20 |
21 | public boolean isCancelled() {
22 | return cancelled;
23 | }
24 |
25 | public void setCancelled(boolean b) {
26 | this.cancelled = b;
27 | }
28 |
29 | private static final HandlerList handlers = new HandlerList();
30 |
31 | public HandlerList getHandlers() {
32 | return handlers;
33 | }
34 |
35 | public static HandlerList getHandlerList() {
36 | return handlers;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: Spartan
2 | authors: [Evangelos Dedes @Vagdedes - Since 2016, pawsashatoy - Since 2024]
3 | main: ai.idealistic.spartan.Register
4 | version: 4.0.4.0
5 | website: https://www.idealistic.ai
6 | description: The intuitive solution when it comes to anti-cheat protection
7 | api-version: 1.13
8 | softdepend: [mcMMO, ProtocolSupport, VeinMiner, EcoEnchants, CustomEnchantsPlus,
9 | aSkyBlock, AdvancedAbilities, CrackShot, CrackShotPlus, CraftBook, GrapplingHook, ProtocolLib,
10 | MagicSpells, MineBomb, MineTinker, MythicMobs, PrinterMode, ProjectKorra, RealDualWield,
11 | SuperPickaxe, TreeFeller, Vehicles, WildTools, floodgate-bukkit]
12 | load: POSTWORLD
13 | folia-supported: true
14 | commands:
15 | spartan:
--------------------------------------------------------------------------------