Skip to content

Commit

Permalink
Merge pull request #496 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho authored Aug 1, 2024
2 parents 146fb29 + e113874 commit 655f235
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/volmit/adapt/Adapt.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void stop() {
services.values().forEach(AdaptService::onDisable);
sqlManager.closeConnection();
stopSim();
glowingEntities.disable();
protectorRegistry.unregisterAll();
services.clear();
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/volmit/adapt/api/adaptation/Adaptation.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ default boolean openGui(Player player, boolean checkPermissions) {
}

default void openGui(Player player) {
if (!Bukkit.isPrimaryThread()) {
J.s(() -> openGui(player));
return;
}

player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1.1f, 1.255f);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.7f, 0.655f);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.3f, 0.855f);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/volmit/adapt/api/skill/Skill.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.volmit.adapt.api.xp.XP;
import com.volmit.adapt.content.gui.SkillsGui;
import com.volmit.adapt.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
Expand Down Expand Up @@ -199,6 +200,11 @@ default void openGui(Player player) {
if (!player.getClass().getSimpleName().equals("CraftPlayer")) {
return;
}
if (!Bukkit.isPrimaryThread()) {
J.s(() -> openGui(player));
return;
}

player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 1.1f, 1.255f);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.7f, 1.455f);
player.getWorld().playSound(player.getLocation(), Sound.ITEM_BOOK_PAGE_TURN, 0.3f, 1.855f);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/volmit/adapt/command/CommandAdapt.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public void gui(
return;
}

if (guiTarget.startsWith("[Skill]")) {
if (guiTarget.startsWith("[Skill]-")) {
for (Skill<?> skill : SkillRegistry.skills.sortV()) {
if (guiTarget.equals("[Skill]" + skill.getName())) {
if (guiTarget.equals("[Skill]-" + skill.getName())) {
if (force || skill.openGui(targetPlayer, true)) {
FConst.success("Opened GUI for " + skill.getName() + " for " + targetPlayer.getName()).send(sender());
} else {
Expand All @@ -85,10 +85,10 @@ public void gui(
}
}

if (guiTarget.startsWith("[Adaptation]")) {
if (guiTarget.startsWith("[Adaptation]-")) {
for (Skill<?> skill : SkillRegistry.skills.sortV()) {
for (Adaptation<?> adaptation : skill.getAdaptations()) {
if (guiTarget.equals("[Adaptation]" + adaptation.getName())) {
if (guiTarget.equals("[Adaptation]-" + adaptation.getName())) {
if (force || adaptation.openGui(targetPlayer, true)) {
FConst.success("Opened GUI for " + adaptation.getName() + " for " + targetPlayer.getName()).send(sender());
} else {
Expand Down Expand Up @@ -141,7 +141,7 @@ public void experience(
return;
}

Skill<?> skill = SkillRegistry.skills.get(skillName.toString());
Skill<?> skill = SkillRegistry.skills.get(skillName.name());
if (skill != null) {
targetPlayer.getInventory().addItem(ExperienceOrb.with(skill.getName(), amount));
FConst.success("Giving " + skill.getName() + " orb").send(sender());
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/volmit/adapt/content/gui/SkillsGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@
import com.volmit.adapt.api.world.PlayerSkillLine;
import com.volmit.adapt.api.xp.XP;
import com.volmit.adapt.util.*;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

public class SkillsGui {
public static void open(Player player) {
if (!Bukkit.isPrimaryThread()) {
J.s(() -> open(player));
return;
}

Window w = new UIWindow(player);
w.setTag("/");
w.setDecorator((window, position, row) -> new UIElement("bg")
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/volmit/adapt/nms/GlowingEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,6 @@ private enum ProtocolMappings {
"id",
"packedItems"
),
// remapping not complete: should also use remapped class names
V1_21(
21,
0,
Expand All @@ -1032,6 +1031,23 @@ private enum ProtocolMappings {
null,
null,
null
),
V1_21_REMAPPED(
21,
0,
true,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public static KList<AdaptationList> getAdaptionListings() {
adaptationLists.add(main);

for (Skill<?> skill : SkillRegistry.skills.sortV()) {
AdaptationList skillList = new AdaptationList("[Skill] " + skill.getName());
AdaptationList skillList = new AdaptationList("[Skill]-" + skill.getName());
adaptationLists.add(skillList);

for (Adaptation<?> adaptation : skill.getAdaptations()) {
AdaptationList adaptationList = new AdaptationList("[Adaptation] " + adaptation.getName());
AdaptationList adaptationList = new AdaptationList("[Adaptation]-" + adaptation.getName());
adaptationLists.add(adaptationList);
}
}
Expand All @@ -46,7 +46,7 @@ public static KList<AdaptationList> getAdaptionListings() {
public static KList<AdaptationSkillList> getAdaptionSkillListings() {
if (adaptationSkillLists.isNotEmpty()) return adaptationSkillLists;

AdaptationSkillList t1 = new AdaptationSkillList("[All]");
AdaptationSkillList t1 = new AdaptationSkillList("[all]");
adaptationSkillLists.add(t1);
AdaptationSkillList t2 = new AdaptationSkillList("[random]");
adaptationSkillLists.add(t2);
Expand Down Expand Up @@ -85,7 +85,7 @@ public boolean startsWith(String prefix) {
}

public boolean equals(String prefix) {
return name.startsWith(prefix);
return name.equalsIgnoreCase(prefix);
}
}

Expand All @@ -95,7 +95,7 @@ public boolean startsWith(String prefix) {
}

public boolean equals(String prefix) {
return name.startsWith(prefix);
return name.equalsIgnoreCase(prefix);
}
}

Expand All @@ -105,7 +105,7 @@ public boolean startsWith(String prefix) {
}

public boolean equals(String prefix) {
return name.startsWith(prefix);
return name.equalsIgnoreCase(prefix);
}
}

Expand All @@ -115,7 +115,7 @@ public boolean startsWith(String prefix) {
}

public boolean equals(String prefix) {
return name.startsWith(prefix);
return name.equalsIgnoreCase(prefix);
}
}
}

0 comments on commit 655f235

Please sign in to comment.