Skip to content

Commit

Permalink
Implanted external dependency onto own code and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Grafnus committed Nov 23, 2024
1 parent 931ceca commit 64e67c5
Show file tree
Hide file tree
Showing 11 changed files with 373 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@
<url>https://repo.dmulloy2.net/repository/public/</url>
</repository>
<repository>
<id>skullcreator-repo</id>
<url>https://github.com/deanveloper/SkullCreator/raw/mvn-repo/</url>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -102,9 +102,9 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>dev.dbassett</groupId>
<artifactId>skullcreator</artifactId>
<version>3.0.1</version>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>compile</scope>
</dependency>
<!-- SQLite JDBC driver -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,16 @@ private void tryPortalUpgrade(PlayerInteractEvent event, ItemStack itemInHand, I
int newLevel = requiredLevel + 1;

connection.setLevel(newLevel);
// Recharge when upgraded
connection.setCharges(20);
ConnectionDAO.saveConnection(connection);

String actionbar = ChatColor.LIGHT_PURPLE + "Upgraded! Portal Level: " + ChatColor.GOLD + (newLevel);
event.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionbar));

event.getPlayer().getInventory().getItemInMainHand().setAmount((event.getPlayer().getInventory().getItemInMainHand().getAmount() - 1));

TaskFactory.createTask(new UpdatePortalCharges(loc));
}

private boolean doChecks(PlayerInteractEvent event) {
Expand Down Expand Up @@ -187,8 +191,8 @@ private void openMenu(PlayerInteractEvent event) {
HibernatePortal portal = PortalDAO.getPortalByLocation(loc);
if (portal == null)
return;
event.setCancelled(true);
PortalOverviewUI ui = new PortalOverviewUI(event.getPlayer(), portal);
ui.openMenu();
event.setCancelled(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public void run() {
upperOrientable.setAxis(Axis.Z);
}
upperPortal.setBlockData(upperOrientable);

TaskFactory.createTask(new UpdatePortalCharges(location));
}
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/grafnus/portalshard/gui/PortalOverviewUI.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package grafnus.portalshard.gui;

import dev.dbassett.skullcreator.SkullCreator;
import grafnus.portalshard.PERMISSION;
import grafnus.portalshard.data.HibernateDO.HibernateConnection;
import grafnus.portalshard.data.HibernateDO.HibernatePortal;
import grafnus.portalshard.util.skulls.SKULL_SYMBOLS;
import grafnus.portalshard.util.skulls.SkullCreator;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grafnus.portalshard.gui;

import dev.dbassett.skullcreator.SkullCreator;
import grafnus.portalshard.util.skulls.SkullCreator;
import grafnus.portalshard.data.DAO.PlayerPermissionDAO;
import grafnus.portalshard.data.HibernateDO.HibernateConnection;
import grafnus.portalshard.data.HibernateDO.HibernatePlayerPermission;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grafnus.portalshard.gui;

import dev.dbassett.skullcreator.SkullCreator;
import grafnus.portalshard.util.skulls.SkullCreator;
import grafnus.portalshard.data.DAO.PlayerPermissionDAO;
import grafnus.portalshard.data.HibernateDO.HibernateConnection;
import grafnus.portalshard.data.HibernateDO.HibernatePlayerPermission;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/grafnus/portalshard/gui/PortalPlayerUI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package grafnus.portalshard.gui;

import dev.dbassett.skullcreator.SkullCreator;
import grafnus.portalshard.util.skulls.SkullCreator;
import grafnus.portalshard.PERMISSION;
import grafnus.portalshard.data.DAO.PlayerPermissionDAO;
import grafnus.portalshard.data.HibernateDO.HibernateConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import org.bukkit.block.Block;
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.EntityPortalEnterEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityPortalExitEvent;
import org.bukkit.event.player.PlayerPortalEvent;

Expand All @@ -37,10 +39,32 @@ public void onEntityPortalTouch(EntityPortalEnterEvent event) {
}
}

@EventHandler
public void onPlayerTeleport(PlayerPortalEvent event) {
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerPortalFix(PlayerPortalEvent event) {
Bukkit.getLogger().log(Level.INFO, "Event Called");

Pair<Location, Boolean> resultsLocationFix = fixNetherPortalExitLocation(event.getSearchRadius(), event.getTo());
Location fixedLocation = resultsLocationFix.getFirst();
boolean isPlayerPortalInRange = resultsLocationFix.getSecond();

if (isPlayerPortalInRange && Objects.isNull(fixedLocation)) {
event.setSearchRadius(1);
return;
}

event.setTo(fixedLocation);
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityPortalFix(EntityPortalEvent event) {
Bukkit.getLogger().log(Level.INFO, "Event Called");

if (!(event.getEntity() instanceof Player)) {
if (RelativePosition.getLocationAboveN(event.getEntity().getLocation(), 2).getBlock().getType().equals(Material.RESPAWN_ANCHOR)) {
event.setCancelled(true);
}
}

Pair<Location, Boolean> resultsLocationFix = fixNetherPortalExitLocation(event.getSearchRadius(), event.getTo());
Location fixedLocation = resultsLocationFix.getFirst();
boolean isPlayerPortalInRange = resultsLocationFix.getSecond();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package grafnus.portalshard.listeners;

public class PortalInterceptFixListener {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import grafnus.portalshard.data.HibernateDO.HibernatePortal;
import grafnus.portalshard.engine.task.CreatePortalITask;
import grafnus.portalshard.engine.task.TaskFactory;
import grafnus.portalshard.engine.task.UpdatePortalCharges;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand Down
Loading

0 comments on commit 64e67c5

Please sign in to comment.