Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Drawethree committed Jul 31, 2022
0 parents commit 04dc10a
Show file tree
Hide file tree
Showing 8 changed files with 396 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Common working directory
run/
48 changes: 48 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>dev.drawethree</groupId>
<artifactId>UltraBombsAPI</artifactId>
<name>UltraBombsAPI</name>
<packaging>jar</packaging>
<version>1.0</version>

<build>
<finalName>UltraBombsAPI-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>


<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
78 changes: 78 additions & 0 deletions src/main/java/dev/drawethree/ultrabombs/api/UltraBombsAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package dev.drawethree.ultrabombs.api;

import dev.drawethree.ultrabombs.api.handler.BlockHandler;
import dev.drawethree.ultrabombs.api.handler.SellHandler;
import dev.drawethree.ultrabombs.api.model.Bomb;
import dev.drawethree.ultrabombs.api.service.BackendAPI;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Optional;

public final class UltraBombsAPI extends JavaPlugin {


private UltraBombsAPI() {
throw new UnsupportedOperationException("Cannot instantiate UltraBombsAPI!");
}

/**
* Gives a player specific bomb
*
* @param bomb {@link Bomb}
* @param amount amount
* @param player Player
*/
public static void giveBomb(Bomb bomb, int amount, Player player) {
BackendAPI.getImplementation().giveBomb(bomb, amount, player);
}

/**
* Returns optional of Bomb based on given name
*
* @param name name
* @return Optional of Bomb
*/
public static Optional<Bomb> getBombByName(String name) {
return BackendAPI.getImplementation().getBombByName(name);
}

/**
* Set the BlockHandler implementation
*
* @param handler Implementation of {@link BlockHandler}
*/
public static void setBlockHandler(BlockHandler handler) {
BackendAPI.getImplementation().setBlockHandler(handler);

}

/**
* Set the SellHandler implementation
*
* @param handler Implementation of {@link SellHandler}
*/
public static void setSellHandler(SellHandler handler) {
BackendAPI.getImplementation().setSellHandler(handler);
}

/**
* Gets the current BlockHandler implementation
*
* @return {@link BlockHandler}
*/
public static BlockHandler getBlockHandler() {
return BackendAPI.getImplementation().getBlockHandler();

}

/**
* Gets the current SellHandler implementation
*
* @return {@link BlockHandler}
*/
public static SellHandler getSellHandler() {
return BackendAPI.getImplementation().getSellHandler();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package dev.drawethree.ultrabombs.api.events;

import dev.drawethree.ultrabombs.api.model.Bomb;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import java.util.List;

public final class BombExplodeEvent extends Event implements Cancellable {

private static final HandlerList handlers = new HandlerList();

private final Bomb bomb;
private final Player player;
private final Location location;
private List<Block> affectedBlocks;
private boolean cancelled;

public BombExplodeEvent(Bomb bomb, Player player, Location location, List<Block> affectedBlocks) {
this.bomb = bomb;
this.player = player;
this.location = location;
this.affectedBlocks = affectedBlocks;
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

public Bomb getBomb() {
return bomb;
}

public Player getPlayer() {
return player;
}

public Location getLocation() {
return location;
}

public List<Block> getAffectedBlocks() {
return affectedBlocks;
}

public void setAffectedBlocks(List<Block> affectedBlocks) {
this.affectedBlocks = affectedBlocks;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.drawethree.ultrabombs.api.handler;

import org.bukkit.block.Block;

import java.util.List;

public interface BlockHandler {

List<Block> handle(List<Block> originalBlocks);

String getRequiredPlugin();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.drawethree.ultrabombs.api.handler;

import org.bukkit.block.Block;
import org.bukkit.entity.Player;

import java.util.List;

public interface SellHandler {

void sell(Player player, List<Block> blocks);

default double getPriceForBlocks(List<Block> blocks) {
return blocks.stream().mapToDouble(this::getPriceForBlock).sum();
}

double getPriceForBlock(Block block);

String getRequiredPlugin();

}
19 changes: 19 additions & 0 deletions src/main/java/dev/drawethree/ultrabombs/api/model/Bomb.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.drawethree.ultrabombs.api.model;

import org.bukkit.Sound;
import org.bukkit.inventory.ItemStack;

public interface Bomb {

String getName();

int getRadius();

ItemStack getItem();

Sound getDropSound();

Sound getExplodeSound();

int getExplosionDelay();
}
Loading

0 comments on commit 04dc10a

Please sign in to comment.