-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Finished region interface & selection events
* Optimized PaginatedList to completely ignore duplicate values * Added new utility for precise time elapsing
- Loading branch information
Showing
18 changed files
with
220 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 39 additions & 5 deletions
44
src/main/java/com/github/sanctum/labyrinth/event/CuboidSelectionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,59 @@ | ||
package com.github.sanctum.labyrinth.event; | ||
|
||
import org.bukkit.event.Event; | ||
import com.github.sanctum.labyrinth.library.Cuboid; | ||
import java.util.Optional; | ||
import org.bukkit.Location; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.player.PlayerEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class CuboidSelectionEvent extends Event { | ||
public class CuboidSelectionEvent extends PlayerEvent { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
|
||
private final Cuboid.Selection selection; | ||
|
||
public CuboidSelectionEvent() { | ||
|
||
public CuboidSelectionEvent(Cuboid.Selection selection) { | ||
super(selection.getPlayer()); | ||
this.selection = selection; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
public @NotNull HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public Optional<Location> getPos1() { | ||
return Optional.ofNullable(selection.getPos1()); | ||
} | ||
|
||
public Optional<Location> getPos2() { | ||
return Optional.ofNullable(selection.getPos2()); | ||
} | ||
|
||
public void setPos1(Location loc) { | ||
selection.setPos1(loc); | ||
} | ||
|
||
public void setPos2(Location loc) { | ||
selection.setPos2(loc); | ||
} | ||
|
||
public ItemStack getWand() { | ||
return selection.getWand(); | ||
} | ||
|
||
public void expand(Cuboid.Selection.Direction direction) { | ||
selection.expand(direction); | ||
} | ||
|
||
public void expand(Cuboid.Selection.Direction direction, int amount) { | ||
selection.expand(direction, amount); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/github/sanctum/labyrinth/event/RegionInteractionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.github.sanctum.labyrinth.event; | ||
|
||
import com.github.sanctum.labyrinth.data.Region; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class RegionInteractionEvent extends RegionInteractEvent { | ||
|
||
private static final HandlerList handlers = new HandlerList(); | ||
|
||
private final Block block; | ||
|
||
private final ClickType clickType; | ||
|
||
public RegionInteractionEvent(Player player, Region region, Block block, ClickType type) { | ||
super(type == ClickType.LEFT ? Type.LEFT_CLICK : Type.RIGHT_CLICK, player, region); | ||
this.block = block; | ||
this.clickType = type; | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
public ClickType getClickType() { | ||
return clickType; | ||
} | ||
|
||
public Block getBlock() { | ||
return block; | ||
} | ||
|
||
public enum ClickType { | ||
RIGHT, LEFT | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/main/java/com/github/sanctum/labyrinth/formatting/ComponentCompliment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.github.sanctum.labyrinth.formatting; | ||
|
||
public interface ComponentCompliment { | ||
public interface ComponentCompliment<T> { | ||
|
||
void apply(int page, int max); | ||
void apply(PaginatedList<T> pagination, int page, int max); | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/com/github/sanctum/labyrinth/formatting/FinishingCompliment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.github.sanctum.labyrinth.formatting; | ||
|
||
public interface FinishingCompliment<T> extends ComponentCompliment { | ||
public interface FinishingCompliment<T> extends ComponentCompliment<T> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/github/sanctum/labyrinth/formatting/StartingCompliment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.github.sanctum.labyrinth.formatting; | ||
|
||
public interface StartingCompliment<T> extends ComponentCompliment { | ||
public interface StartingCompliment<T> extends ComponentCompliment<T> { | ||
|
||
} |
Oops, something went wrong.