Skip to content

Commit

Permalink
a lot of interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofpu committed Sep 5, 2021
1 parent cfb6bb8 commit c71ea85
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 16 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# 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*
*.iml
.idea
\target
48 changes: 48 additions & 0 deletions api/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>me.tofpu</groupId>
<artifactId>speedbridge-api</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</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>
37 changes: 37 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/game/GameService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package me.tofpu.speedbridge.api.game;

import me.tofpu.speedbridge.api.island.Island;
import me.tofpu.speedbridge.api.island.mode.Mode;
import me.tofpu.speedbridge.api.user.User;
import me.tofpu.speedbridge.api.user.timer.Timer;
import org.bukkit.entity.Player;

public interface GameService {
Result join(final Player player);

Result join(final Player player, final int slot);

Result join(final Player player, final Mode mode);

Result join(final User user, final Island island);

Result leave(final Player player);

boolean isPlaying(final Player player);

void addTimer(final User user);

boolean hasTimer(final User user);

Timer getTimer(final User user);

void updateTimer(final User user);

void resetTimer(final User user);

void reset(final User user);

void resetBlocks(final Island island);

void resetIsland(final int slot);
}
5 changes: 5 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/game/Result.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package me.tofpu.speedbridge.api.game;

public enum Result {
SUCCESS, DENY, FULL, NONE, INVALID_LOBBY, INVALID_ISLAND
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.tofpu.speedbridge.api.island;

import me.tofpu.speedbridge.api.island.mode.Mode;
import me.tofpu.speedbridge.api.user.User;
import me.tofpu.speedbridge.api.util.Identifier;
import org.bukkit.Location;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.tofpu.speedbridge.api.island;

import me.tofpu.speedbridge.api.island.mode.Mode;
import me.tofpu.speedbridge.api.user.User;

import java.io.File;
Expand Down
17 changes: 17 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/island/mode/Mode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package me.tofpu.speedbridge.api.island.mode;

import me.tofpu.speedbridge.api.util.Identifier;

import java.util.List;

public interface Mode extends Identifier {
/**
* @return the mode initial selected slots
*/
List<Integer> slots();

/**
* @return true if the settings was set to this, otherwise false
*/
boolean isDefault();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public interface Point {
Location pointA();

/**
* @param location new location
* @return true if the location is not null, otherwise false
*/
void pointA(final Location location);
boolean hasPointA();

/**
* @return true if the location is not null, otherwise false
* @param location new location
*/
boolean hasPointA();
void pointA(final Location location);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
public interface TwoSection extends Point {
String identifier();

@Override
Location pointA();

@Override
void pointA(final Location pointA);

@Override
boolean hasPointA();

Location pointB();

void pointB(final Location pointB);

boolean hasPointB();
void pointB(final Location pointB);
}
8 changes: 8 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/user/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package me.tofpu.speedbridge.api.user;

import java.util.UUID;

public interface User {
UUID uniqueId();
UserProperties properties();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package me.tofpu.speedbridge.api.user;

import me.tofpu.speedbridge.api.user.timer.Timer;

public interface UserProperties {
/**
* @return the player's island slot they're in, otherwise null
*/
Integer islandSlot();

/**
* @param slot setting the player island slot
*/
void islandSlot(final Integer slot);

/**
* @return the player's personal best timer, otherwise null
*/
Timer timer();


/**
* @param timer the new personal best timer
*/
void timer(final Timer timer);
}
20 changes: 20 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/user/UserService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package me.tofpu.speedbridge.api.user;

import java.io.File;
import java.util.UUID;

public interface UserService {
User createUser(final UUID uuid);

void removeUser(final User user);

User getOrDefault(final UUID uuid);

User searchForUUID(final UUID uuid);

void saveAll(final File directory, final boolean emptyList);

void save(final User user, final File directory);

User load(final UUID uuid, final File directory);
}
32 changes: 32 additions & 0 deletions api/src/main/java/me/tofpu/speedbridge/api/user/timer/Timer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package me.tofpu.speedbridge.api.user.timer;

public interface Timer {
/**
* @return the island slot
*/
int slot();

/**
* @return the total result if the end timestamp has been provided, otherwise 0
*/
double result();

/**
* The start timestamp when it has started
*
* @return the start timestamp
*/
long start();

/**
* This will set the end timestamp and provide the result
*
* @param end the end timestamp
*/
void end(final long end);

/**
* @return the end timestamp
*/
long end();
}
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>me.tofpu</groupId>
<artifactId>speedbridge</artifactId>
<version>1.0.3</version>
<packaging>pom</packaging>

<modules>
<module>spigot</module>
<module>api</module>
</modules>
</project>

0 comments on commit c71ea85

Please sign in to comment.