Skip to content

Commit

Permalink
* Updated to 1.20
Browse files Browse the repository at this point in the history
* Refactored the regions api making it cleaner and more efficient.
* Refactored naming scheme for skull api.
* Updated version
  • Loading branch information
Hempfest committed Jun 20, 2023
1 parent 442aea0 commit aeec6cc
Show file tree
Hide file tree
Showing 31 changed files with 601 additions and 565 deletions.
2 changes: 1 addition & 1 deletion labyrinth-common/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion labyrinth-gui/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion labyrinth-loci/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion labyrinth-perms/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion labyrinth-plugin/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Expand Up @@ -2,14 +2,14 @@

import com.github.sanctum.labyrinth.Labyrinth;
import com.github.sanctum.labyrinth.LabyrinthProvider;
import com.github.sanctum.labyrinth.data.container.Region;
import com.github.sanctum.labyrinth.event.CuboidSelectEvent;
import com.github.sanctum.labyrinth.event.LabyrinthVentCall;
import com.github.sanctum.labyrinth.event.RegionBuildEvent;
import com.github.sanctum.labyrinth.event.RegionDestroyEvent;
import com.github.sanctum.labyrinth.event.RegionInteractionEvent;
import com.github.sanctum.labyrinth.event.RegionPVPEvent;
import com.github.sanctum.labyrinth.event.DefaultEvent;
import com.github.sanctum.labyrinth.library.Cuboid;
import com.github.sanctum.labyrinth.library.Items;
import com.github.sanctum.labyrinth.task.TaskScheduler;
import com.github.sanctum.panther.container.ImmutablePantherCollection;
Expand All @@ -25,6 +25,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.block.Action;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.ServicePriority;
import org.jetbrains.annotations.NotNull;

Expand All @@ -34,7 +35,8 @@
public final class RegionServicesManagerImpl extends RegionServicesManager {

final PantherCollection<Region> cache = new PantherList<>();
final Cuboid.FlagManager flagManager = new Cuboid.FlagManager(this);
final FlagManager flagManager = new FlagManager(this);
private ItemStack wand = new ItemStack(Material.STICK);

public static void initialize(Labyrinth instance) {

Expand Down Expand Up @@ -102,7 +104,7 @@ public static void initialize(Labyrinth instance) {
if (!e.getPlayer().hasPermission("labyrinth.selection"))
return;

Cuboid.Selection selection = Cuboid.Selection.source(e.getPlayer());
CuboidSelection selection = CuboidSelection.get(e.getPlayer());

if (e.getItem().getType() == selection.getWand().getType()) {
if (e.getResult() != Event.Result.DENY) {
Expand Down Expand Up @@ -144,7 +146,7 @@ public static void initialize(Labyrinth instance) {
}

if (e.getItem().getType() == mat) {
Cuboid.Selection selection = Cuboid.Selection.source(e.getPlayer());
CuboidSelection selection = CuboidSelection.get(e.getPlayer());
if (e.getResult() != Event.Result.DENY) {
e.setResult(Event.Result.DENY);
}
Expand Down Expand Up @@ -213,17 +215,17 @@ public Region get(@NotNull String name) {

@Override
public Region get(@NotNull Location location, boolean passthrough) {
return cache.stream().filter(region -> region.contains(location) && region.isPassthrough() == passthrough).findFirst().orElse(null);
return cache.stream().filter(region -> region.contains(location) && region.isDominant() == passthrough).findFirst().orElse(null);
}

@Override
public Region get(@NotNull Player player, boolean passthrough) {
return cache.stream().filter(region -> region.contains(player) && region.isPassthrough() == passthrough).findFirst().orElse(null);
return cache.stream().filter(region -> region.contains(player) && region.isDominant() == passthrough).findFirst().orElse(null);
}

@Override
public Region get(@NotNull String name, boolean passthrough) {
return cache.stream().filter(region -> region.getName().equals(name) && region.isPassthrough() == passthrough).findFirst().orElse(null);
return cache.stream().filter(region -> region.getName().equals(name) && region.isDominant() == passthrough).findFirst().orElse(null);
}

@Override
Expand All @@ -239,7 +241,17 @@ public boolean unload(@NotNull Region region) {
}

@Override
public Cuboid.FlagManager getFlagManager() {
public FlagManager getFlagManager() {
return flagManager;
}

@Override
public ItemStack getWand() {
return wand;
}

@Override
public void setWand(@NotNull ItemStack itemStack) {
this.wand = itemStack;
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion labyrinth-regions/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>labyrinth</artifactId>
<groupId>com.github.the-h-team</groupId>
<version>1.9.1</version>
<version>1.9.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
@@ -0,0 +1,69 @@
package com.github.sanctum.labyrinth.data;

public class CuboidAxis {

private final int xMin;
private final int xMax;
private final int yMin;
private final int yMax;
private final int zMin;
private final int zMax;
private final int height;
private final int zWidth;
private final int xWidth;
private final int totalSize;

public CuboidAxis(int x1, int x2, int y1, int y2, int z1, int z2) {
this.xMin = Math.min(x1, x2);
this.xMax = Math.max(x1, x2);
this.yMin = Math.min(y1, y2);
this.yMax = Math.max(y1, y2);
this.zMin = Math.min(z1, z2);
this.zMax = Math.max(z1, z2);
this.height = this.yMax - this.yMin + 1;
this.xWidth = this.xMax - this.xMin + 1;
this.zWidth = this.zMax - this.zMin + 1;
this.totalSize = height * xWidth * zWidth;
}

public int getTotalSize() {
return totalSize;
}

public int getHeight() {
return height;
}

public int getxWidth() {
return xWidth;
}

public int getzWidth() {
return zWidth;
}

public int getxMax() {
return xMax;
}

public int getxMin() {
return xMin;
}

public int getyMax() {
return yMax;
}

public int getyMin() {
return yMin;
}

public int getzMax() {
return zMax;
}

public int getzMin() {
return zMin;
}

}
@@ -0,0 +1,34 @@
package com.github.sanctum.labyrinth.data;

import java.util.Random;
import org.bukkit.Location;
import org.bukkit.World;

public class CuboidLocation {

private final World world;
private final CuboidAxis axis;
private final Location center;

public CuboidLocation(CuboidAxis axis, World world) {
this.world = world;
this.axis = axis;
this.center = new Location(getWorld(), (double) (this.axis.getxMax() - this.axis.getxMin()) / 2 + this.axis.getxMin(), (double) (this.axis.getyMax() - this.axis.getyMin()) / 2 + this.axis.getyMin(), (double) (this.axis.getzMax() - this.axis.getzMin()) / 2 + this.axis.getzMin());
}

public Location getCenter() {
return center;
}

public Location getRandom() {
Random r = new Random();
int x = r.nextInt(Math.abs(this.axis.getxMax() - this.axis.getxMin()) + 1) + this.axis.getxMin();
int y = r.nextInt(Math.abs(this.axis.getyMax() - this.axis.getyMin()) + 1) + this.axis.getyMin();
int z = r.nextInt(Math.abs(this.axis.getzMax() - this.axis.getzMin()) + 1) + this.axis.getzMin();
return new Location(getWorld(), x, y, z);
}

public World getWorld() {
return world;
}
}

0 comments on commit aeec6cc

Please sign in to comment.