Skip to content

Commit

Permalink
Split interact into ClickInteract and PhysicalInteract
Browse files Browse the repository at this point in the history
Move to Intellij Idea Community since JetBrains didn't renew my OSS License
Split interact such that physical interactions can be toggled separately
Closes #79
  • Loading branch information
Dart2112 committed Jan 18, 2025
1 parent 06d9cb3 commit 46b0172
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 11 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/benja.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/modules/AFKPlus.main~1.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/modules/AFKPlus.main~2.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/main/java/net/lapismc/afkplus/AFKPlus.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Benjamin Martin
* Copyright 2025 Benjamin Martin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,7 +49,7 @@ public final class AFKPlus extends LapisCorePlugin {
@Override
public void onEnable() {
saveDefaultConfig();
registerConfiguration(new AFKPlusConfiguration(this, 16, 5));
registerConfiguration(new AFKPlusConfiguration(this, 17, 5));
registerPermissions(new AFKPlusPermissions(this));
registerLuckPermsContext();
update();
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/net/lapismc/afkplus/AFKPlusListeners.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Benjamin Martin
* Copyright 2025 Benjamin Martin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.*;
Expand Down Expand Up @@ -120,8 +121,16 @@ public void onPlayerCommand(PlayerCommandPreprocessEvent e) {

@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (plugin.getConfig().getBoolean("EnabledDetections.Interact")) {
plugin.getPlayer(e.getPlayer()).interact();
if (e.getAction() == Action.PHYSICAL) {
//Physical Actions include stepping on redstone ore, pressure plates, trip wire or jumping on soil
if (plugin.getConfig().getBoolean("EnabledDetections.PhysicalInteract")) {
plugin.getPlayer(e.getPlayer()).interact();
}
} else {
//All other action are click based, e.g. Left/Right Clicking Air/Blocks
if (plugin.getConfig().getBoolean("EnabledDetections.ClickInteract")) {
plugin.getPlayer(e.getPlayer()).interact();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Benjamin Martin
* Copyright 2025 Benjamin Martin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -343,7 +343,7 @@ public void takeAction() {
AFKActionEvent event = new AFKActionEvent(this, command);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
forceStopAFK();
stopAFK(true);
runCommand(event.getCommand());
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ConfigVersion: 16
ConfigVersion: 17

#Should the plugin check for new updates, UpdateDownload will not work if this is set to false
UpdateCheck: true
Expand Down Expand Up @@ -51,8 +51,10 @@ EnabledDetections:
Attack: true
#Running commands
Command: true
#Right-clicking blocks
Interact: true
#Clicking (air or block)
ClickInteract: true
#Stepping on things (redstone ore, tripwire, pressure plate or jumping on soil)
PhysicalInteract: true
#Intertacting with an inventory or entity GUI
GUI: true
#Placing blocks
Expand Down

0 comments on commit 46b0172

Please sign in to comment.