Skip to content
This repository has been archived by the owner on May 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from Zyphicx/add-f-skill-combos
Browse files Browse the repository at this point in the history
Add F click to combos
  • Loading branch information
Sentropic authored Nov 28, 2020
2 parents ace0778 + 0555d8f commit 8f4097f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion editor/js/skill.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function Skill(name)
new AttributeValue('Mana', 'mana', 0, 0).setTooltip('The amount of mana it takes to cast the skill (only works with the Cast trigger)'),
new AttributeValue('Min Spent', 'points-spent-req', 0, 0).setTooltip('The amount of skill points that need to be spent before upgrading this skill'),
new StringValue('Cast Message', 'msg', '&6{player} &2has cast &6{skill}').setTooltip('The message to display to players around the caster when the skill is cast. The radius of the area is in the config.yml options'),
new StringValue('Combo', 'combo', '').setTooltip('The click combo to assign the skill (if enabled). Use L, R, S, LS, RS, P, and Q for the types of clicks separated by spaces. For example, "L L R R" would work for 4 click combos.'),
new StringValue('Combo', 'combo', '').setTooltip('The click combo to assign the skill (if enabled). Use L, R, S, LS, RS, P, Q and F for the types of clicks separated by spaces. For example, "L L R R" would work for 4 click combos.'),
new ListValue('Indicator', 'indicator', [ '2D', '3D', 'None' ], '2D').setTooltip('[PREMIUM] What sort of display to use for cast previews. This applies to the "hover bar" in the casting bars setup.'),
new ListValue('Icon', 'icon', getMaterials, 'Jack O Lantern').setTooltip('The item used to represent the skill in skill trees'),
new IntValue('Icon Data', 'icon-data', 0).setTooltip('The data/durability value (under 1.14) or the CustomModelData (in 1.14+) of the icon.'),
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/sucy/skill/data/Click.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public enum Click
LEFT_SHIFT(4, "LS"),
RIGHT_SHIFT(5, "RS"),
SPACE(6, "P"),
Q(7, "Q");
Q(7, "Q"),
F(8, "F");

public static final int BITS = 3;
public static final int BITS = 4;
public static final int BIT_MASK = (1 << BITS) - 1;
public static final int MAX_COMBO_SIZE = 30 / BITS;
public static final int MAX_COMBO_SIZE = 32 / BITS;

private static final Click[] CLICKS = new Click[] { null, LEFT, RIGHT, SHIFT, LEFT_SHIFT, RIGHT_SHIFT, SPACE, Q };
private static final Click[] CLICKS = new Click[] { null, LEFT, RIGHT, SHIFT, LEFT_SHIFT, RIGHT_SHIFT, SPACE, Q, F };

private int id;
private String key;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/sucy/skill/data/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@ private void loadComboSettings() {
final String key = COMBO_CLICK + Click.getById(i).name().toLowerCase().replace('_', '-');
clicks[i] = config.getBoolean(key);
}

if (clicks[Click.RIGHT_SHIFT.getId()] || clicks[Click.LEFT_SHIFT.getId()]) {
clicks[Click.SHIFT.getId()] = false;
}
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/sucy/skill/listener/ComboListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
import com.sucy.skill.api.event.KeyPressEvent;
import com.sucy.skill.api.player.PlayerCombos;
import com.sucy.skill.data.Click;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.event.player.*;

import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -131,5 +130,14 @@ public void onJump(final PlayerMoveEvent event) {
}
}

@EventHandler
public void onFClick(final PlayerSwapHandItemsEvent event) {
SkillAPI.getPlayerData(event.getPlayer()).getComboData().applyClick(Click.F);

if(SkillAPI.getComboManager().isClickEnabled(Click.F.getId())) {
event.setCancelled(true);
}
}

private HashSet<UUID> onGround = new HashSet<UUID>();
}
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ Click Combos:
# Enabling this disables dropping items via Q outside of menus.
use-click-q: false
#
# Whether or not F clicks are allowed at all.
# Enabling this disables swapping items between main and off hand via F.
use-click-f: false
#
# How many clicks are needed to perform a combo
combo-size: 4
#
Expand Down

0 comments on commit 8f4097f

Please sign in to comment.