mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-05 21:41:31 +00:00
Added setting toggle-on-combat-include-mobs, fix reload error with GUIs
This commit is contained in:
parent
46fc435a96
commit
94e1aa6b66
6 changed files with 36 additions and 24 deletions
12
build.gradle
12
build.gradle
|
@ -10,7 +10,7 @@ sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
group = 'dev.esophose'
|
group = 'dev.esophose'
|
||||||
version = '8.0-DEV-2-SNAPSHOT'
|
version = '8.0-SNAPSHOT'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
|
@ -27,12 +27,12 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
|
||||||
compileOnly 'org.jetbrains:annotations:16.0.2'
|
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||||
compileOnly 'me.clip:placeholderapi:2.10.4'
|
compileOnly 'me.clip:placeholderapi:2.10.4'
|
||||||
compileOnly 'org.xerial:sqlite-jdbc:3.23.1'
|
compileOnly 'org.xerial:sqlite-jdbc:3.36.0.3'
|
||||||
api 'org.slf4j:slf4j-api:1.7.25'
|
api 'org.slf4j:slf4j-api:1.7.36'
|
||||||
api 'org.slf4j:slf4j-nop:1.7.25'
|
api 'org.slf4j:slf4j-nop:1.7.36'
|
||||||
api 'com.zaxxer:HikariCP:3.2.0'
|
api 'com.zaxxer:HikariCP:3.2.0'
|
||||||
api 'org.bstats:bstats-bukkit-lite:1.7'
|
api 'org.bstats:bstats-bukkit-lite:1.7'
|
||||||
api 'org.codemc.worldguardwrapper:worldguardwrapper:1.2.0-SNAPSHOT'
|
api 'org.codemc.worldguardwrapper:worldguardwrapper:1.2.0-SNAPSHOT'
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
=== v8.0 ===
|
||||||
|
+ Added support for Particle Packs
|
||||||
|
+ Added setting toggle-on-combat-include-mobs
|
||||||
|
* Fixed particle effects now save the pitch/yaw of the player when they are created
|
||||||
|
* Fixed an error when doing /pp reload if a player has the GUI open
|
||||||
|
* The icosphere style now fades between dust colors when using the dust_color_transition effect
|
||||||
=== v7.24 ===
|
=== v7.24 ===
|
||||||
* Fixed configs not generating properly on newer versions of 1.18.1
|
* Fixed configs not generating properly on newer versions of 1.18.1
|
||||||
=== v7.23 ===
|
=== v7.23 ===
|
||||||
|
|
|
@ -23,6 +23,7 @@ import dev.esophose.playerparticles.command.ToggleCommandModule;
|
||||||
import dev.esophose.playerparticles.command.UseCommandModule;
|
import dev.esophose.playerparticles.command.UseCommandModule;
|
||||||
import dev.esophose.playerparticles.command.VersionCommandModule;
|
import dev.esophose.playerparticles.command.VersionCommandModule;
|
||||||
import dev.esophose.playerparticles.command.WorldsCommandModule;
|
import dev.esophose.playerparticles.command.WorldsCommandModule;
|
||||||
|
import dev.esophose.playerparticles.hook.PlaceholderAPIHook;
|
||||||
import dev.esophose.playerparticles.particles.PPlayer;
|
import dev.esophose.playerparticles.particles.PPlayer;
|
||||||
import dev.esophose.playerparticles.util.ParticleUtils;
|
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -178,7 +179,11 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
|
} else if (cmd.getName().equalsIgnoreCase("ppo")) {
|
||||||
Bukkit.getScheduler().runTask(this.playerParticles, () -> this.ppoCommand.onCommandExecute(sender, args));
|
String[] replacedArgs = new String[args.length];
|
||||||
|
Player player = sender instanceof Player ? (Player) sender : null;
|
||||||
|
for (int i = 0; i < args.length; i++)
|
||||||
|
replacedArgs[i] = PlaceholderAPIHook.applyPlaceholders(player, args[i]);
|
||||||
|
Bukkit.getScheduler().runTask(this.playerParticles, () -> this.ppoCommand.onCommandExecute(sender, replacedArgs));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class ConfigurationManager extends Manager {
|
||||||
TOGGLE_ON_MOVE_DELAY("toggle-on-move-delay", 9, "The time (in ticks) a player has to be standing still before they are considered to be stopped", "This setting has no effect if toggle-on-move is set to false", "The value must be a positive whole number"),
|
TOGGLE_ON_MOVE_DELAY("toggle-on-move-delay", 9, "The time (in ticks) a player has to be standing still before they are considered to be stopped", "This setting has no effect if toggle-on-move is set to false", "The value must be a positive whole number"),
|
||||||
TOGGLE_ON_COMBAT("toggle-on-combat", false, "If true, particles will be completely disabled while the player is in combat", "Note: You can change what styles follow this setting in their individual setting files"),
|
TOGGLE_ON_COMBAT("toggle-on-combat", false, "If true, particles will be completely disabled while the player is in combat", "Note: You can change what styles follow this setting in their individual setting files"),
|
||||||
TOGGLE_ON_COMBAT_DELAY("toggle-on-combat-delay", 15, "The time (in seconds) a player has to not be damaged/attacked to be considered out of combat", "This setting has no effect if toggle-on-combat is set to false", "The value must be a positive whole number"),
|
TOGGLE_ON_COMBAT_DELAY("toggle-on-combat-delay", 15, "The time (in seconds) a player has to not be damaged/attacked to be considered out of combat", "This setting has no effect if toggle-on-combat is set to false", "The value must be a positive whole number"),
|
||||||
|
TOGGLE_ON_COMBAT_INCLUDE_MOBS("toggle-on-combat-include-mobs", false, "If true, mobs will be included in the combat check in addition to players"),
|
||||||
DISABLED_WORLDS("disabled-worlds", Collections.singletonList("disabled_world_name"), "A list of worlds that the plugin is disabled in"),
|
DISABLED_WORLDS("disabled-worlds", Collections.singletonList("disabled_world_name"), "A list of worlds that the plugin is disabled in"),
|
||||||
CHECK_PERMISSIONS_ON_LOGIN("check-permissions-on-login", false, "Should particles a player no longer has permission to use be removed on login?"),
|
CHECK_PERMISSIONS_ON_LOGIN("check-permissions-on-login", false, "Should particles a player no longer has permission to use be removed on login?"),
|
||||||
MAX_PARTICLES("max-particles", 3, "The maximum number of particles a player can apply at once", "The GUI will only display up to 21, don't set this any higher than that"),
|
MAX_PARTICLES("max-particles", 3, "The maximum number of particles a player can apply at once", "The GUI will only display up to 21, don't set this any higher than that"),
|
||||||
|
|
|
@ -94,22 +94,21 @@ public class GuiManager extends Manager implements Listener, Runnable {
|
||||||
* Used for when the plugin unloads so players can't take items from the GUI
|
* Used for when the plugin unloads so players can't take items from the GUI
|
||||||
*/
|
*/
|
||||||
public void forceCloseAllOpenGUIs() {
|
public void forceCloseAllOpenGUIs() {
|
||||||
Runnable task = () -> {
|
List<Player> toClose = new ArrayList<>();
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
for (GuiInventory inventory : this.guiInventories) {
|
for (GuiInventory inventory : this.guiInventories) {
|
||||||
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()) && inventory.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
if (inventory.getPPlayer().getUniqueId().equals(player.getUniqueId()) && inventory.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||||
player.closeInventory();
|
toClose.add(player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.guiInventories.clear();
|
this.guiInventories.clear();
|
||||||
};
|
|
||||||
|
|
||||||
if (Bukkit.isPrimaryThread()) {
|
if (Bukkit.isPrimaryThread()) {
|
||||||
task.run();
|
toClose.forEach(Player::closeInventory);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTask(this.playerParticles, task);
|
Bukkit.getScheduler().runTask(this.playerParticles, x -> toClose.forEach(Player::closeInventory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
public class PPlayerCombatListener implements Listener {
|
public class PPlayerCombatListener implements Listener {
|
||||||
|
|
||||||
private static final int CHECK_INTERVAL = 20;
|
private static final int CHECK_INTERVAL = 20;
|
||||||
private Map<UUID, Integer> timeSinceCombat = new HashMap<>();
|
private final Map<UUID, Integer> timeSinceCombat = new HashMap<>();
|
||||||
|
|
||||||
public PPlayerCombatListener() {
|
public PPlayerCombatListener() {
|
||||||
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
|
||||||
|
@ -31,7 +31,6 @@ public class PPlayerCombatListener implements Listener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<UUID> toRemove = new ArrayList<>();
|
List<UUID> toRemove = new ArrayList<>();
|
||||||
|
|
||||||
for (UUID uuid : this.timeSinceCombat.keySet()) {
|
for (UUID uuid : this.timeSinceCombat.keySet()) {
|
||||||
PPlayer pplayer = dataManager.getPPlayer(uuid);
|
PPlayer pplayer = dataManager.getPPlayer(uuid);
|
||||||
if (pplayer == null) {
|
if (pplayer == null) {
|
||||||
|
@ -50,13 +49,15 @@ public class PPlayerCombatListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to detect if the player is moving
|
* Used to detect if the player is in combat
|
||||||
*
|
*
|
||||||
* @param event The event
|
* @param event The event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerAttack(EntityDamageByEntityEvent event) {
|
public void onPlayerAttack(EntityDamageByEntityEvent event) {
|
||||||
if (event.getEntity().getType() != EntityType.PLAYER)
|
boolean attackedIsPlayer = event.getEntity().getType() == EntityType.PLAYER;
|
||||||
|
boolean includeMobs = Setting.TOGGLE_ON_COMBAT_INCLUDE_MOBS.getBoolean();
|
||||||
|
if (!attackedIsPlayer && !includeMobs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player attacker;
|
Player attacker;
|
||||||
|
@ -70,10 +71,10 @@ public class PPlayerCombatListener implements Listener {
|
||||||
attacker = (Player) event.getDamager();
|
attacker = (Player) event.getDamager();
|
||||||
} else return;
|
} else return;
|
||||||
|
|
||||||
Player damaged = (Player) event.getEntity();
|
if (attackedIsPlayer)
|
||||||
|
this.markInCombat((Player) event.getEntity());
|
||||||
|
|
||||||
this.markInCombat(attacker);
|
this.markInCombat(attacker);
|
||||||
this.markInCombat(damaged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue