Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Rosewood-Development/PlayerParticles
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: firestarter/PlayerParticles
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Dec 8, 2022

  1. merge tweaks

    nkomarn committed Dec 8, 2022
    Copy the full SHA
    f1f3231 View commit details
  2. Copy the full SHA
    faafc70 View commit details

Commits on Feb 26, 2023

  1. Copy the full SHA
    e204610 View commit details

Commits on Jul 23, 2023

  1. merge upstream (1.20)

    nkomarn committed Jul 23, 2023
    Copy the full SHA
    50eb7c2 View commit details
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ plugins {
id 'java-library'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 17
targetCompatibility = 17
compileJava.options.encoding = 'UTF-8'
group = 'dev.esophose'
version = '8.4'
@@ -20,14 +20,14 @@ java {
repositories {
mavenCentral()

maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://repo.codemc.org/repository/maven-public' }
maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url = 'https://repo.rosewooddev.io/repository/public/' }
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
compileOnly 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'
compileOnly 'org.jetbrains:annotations:23.0.0'
compileOnly 'me.clip:placeholderapi:2.10.4'
api 'org.bstats:bstats-bukkit-lite:1.7'
Original file line number Diff line number Diff line change
@@ -122,6 +122,7 @@ public GuiInventoryManageParticles(PPlayer pplayer) {
});
this.actionButtons.add(resetParticles);

/*
// Back Button
GuiActionButton backButton = new GuiActionButton(
INVENTORY_SIZE - 1,
@@ -130,6 +131,7 @@ public GuiInventoryManageParticles(PPlayer pplayer) {
new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryDefault(pplayer)));
this.actionButtons.add(backButton);
*/

this.populate();
}
Original file line number Diff line number Diff line change
@@ -26,6 +26,13 @@ public static void initialize() {
return;

worldGuardWrapper = WorldGuardWrapper.getInstance();
Optional<IWrappedFlag<WrappedState>> flag = worldGuardWrapper.getFlag("player-particles", WrappedState.class);

if (flag.isPresent()) {
flagPlayerParticles = flag.get();
return;
}

flagPlayerParticles = worldGuardWrapper.registerFlag("player-particles", WrappedState.class, WrappedState.ALLOW).orElse(null);
}

Original file line number Diff line number Diff line change
@@ -127,7 +127,7 @@ public void openDefault(PPlayer pplayer) {
}

Bukkit.getScheduler().runTask(this.rosePlugin, () ->
this.openGui(pplayer, new GuiInventoryDefault(pplayer)));
this.openGui(pplayer, new GuiInventoryManageParticles(pplayer)));
}

/**
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public class DefaultStyles implements Listener {
public static final ParticleStyle SPHERE = new ParticleStyleSphere();
public static final ParticleStyle SPIN = new ParticleStyleSpin();
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
public static final ParticleStyle SWORDS = new ParticleStyleSwords();
public static final ParticleStyle SWORDS = new ParticleStyleHit();
public static final ParticleStyle TELEPORT = new ParticleStyleTeleport();
public static final ParticleStyle THICK = new ParticleStyleThick();
public static final ParticleStyle TRAIL = new ParticleStyleTrail();
Original file line number Diff line number Diff line change
@@ -7,36 +7,26 @@
import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import dev.rosewood.rosegarden.utils.NMSUtil;
import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;

public class ParticleStyleSwords extends ConfiguredParticleStyle implements Listener {
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

private static final List<String> DEFAULT_SWORD_NAMES;
public class ParticleStyleHit extends ConfiguredParticleStyle implements Listener {

private int multiplier;
private List<String> swordNames;

static {
DEFAULT_SWORD_NAMES = new ArrayList<>();
DEFAULT_SWORD_NAMES.addAll(Arrays.asList("WOOD_SWORD", "WOODEN_SWORD", "STONE_SWORD", "IRON_SWORD", "GOLD_SWORD", "GOLDEN_SWORD", "DIAMOND_SWORD", "NETHERITE_SWORD", "TRIDENT"));
}

protected ParticleStyleSwords() {
super("swords", false, false, 0);
protected ParticleStyleHit() {
super("hit", false, false, 0);
}

@Override
@@ -56,7 +46,7 @@ public void updateTimers() {

@Override
protected List<String> getGuiIconMaterialNames() {
return Collections.singletonList("IRON_SWORD");
return Collections.singletonList("AMETHYST_SHARD");
}

@Override
@@ -67,49 +57,39 @@ public boolean hasLongRangeVisibility() {
@Override
protected void setDefaultSettings(CommentedFileConfiguration config) {
this.setIfNotExists("multiplier", 15, "The multiplier for the number of particles to spawn", "This style uses the same spawning as the 'normal' style");
this.setIfNotExists("sword-materials", DEFAULT_SWORD_NAMES, "The materails that are considered swords", "Set to [] to allow everything to be considered a sword", "Use AIR to allow a bare hand to be considered a sword");
}

@Override
protected void loadSettings(CommentedFileConfiguration config) {
this.multiplier = config.getInt("multiplier");
this.swordNames = config.getStringList("sword-materials");
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void preAttack(PrePlayerAttackEntityEvent event) {
handleInteraction(event.getPlayer(), event.getAttacked());
}

@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player attacker) {
handleInteraction(attacker, event.getEntity());
}
}

private void handleInteraction(Player attacker, Entity attacked) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);

if (event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity) {
Player player = (Player) event.getDamager();
LivingEntity entity = (LivingEntity) event.getEntity();
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId());
if (pplayer == null)
return;
if (attacked instanceof LivingEntity entity) {
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(attacker.getUniqueId());

if (NMSUtil.getVersionNumber() > 8) {
if (!this.isSword(player.getInventory().getItemInMainHand()))
return;
} else {
if (!this.isSword(player.getInventory().getItemInHand()))
return;
if (pplayer == null) {
return;
}

for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.SWORDS)) {
Location loc = entity.getLocation().add(0, 1, 0);
particleManager.displayParticles(pplayer, player.getWorld(), particle, DefaultStyles.SWORDS.getParticles(particle, loc), false);
particleManager.displayParticles(pplayer, attacker.getWorld(), particle, DefaultStyles.SWORDS.getParticles(particle, loc), false);
}
}
}

private boolean isSword(ItemStack itemStack) {
if (this.swordNames.isEmpty())
return true;

if (itemStack == null)
return this.swordNames.contains("AIR");

return this.swordNames.contains(itemStack.getType().name());
}

}
}