-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added an interface for Mode and removed getters
- Loading branch information
Showing
18 changed files
with
187 additions
and
40 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
api/src/main/java/me/tofpu/speedbridge/api/island/Island.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,23 @@ | ||
package me.tofpu.speedbridge.api.island; | ||
|
||
import me.tofpu.speedbridge.api.user.User; | ||
import me.tofpu.speedbridge.api.util.Identifier; | ||
import org.bukkit.Location; | ||
|
||
import java.util.List; | ||
|
||
public interface Island extends Identifier { | ||
boolean isAvailable(); | ||
|
||
User takenBy(); | ||
void takenBy(final User takenBy); | ||
|
||
Location location(); | ||
void location(final Location location); | ||
boolean hasLocation(); | ||
|
||
int slot(); | ||
Mode mode(); | ||
List<Location> placedBlocks(); | ||
IslandProperties properties(); | ||
} |
19 changes: 19 additions & 0 deletions
19
api/src/main/java/me/tofpu/speedbridge/api/island/IslandProperties.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,19 @@ | ||
package me.tofpu.speedbridge.api.island; | ||
|
||
import me.tofpu.speedbridge.api.island.point.Point; | ||
|
||
import java.util.List; | ||
|
||
public interface IslandProperties { | ||
/** | ||
* @param identifier point identifier | ||
* | ||
* @return the island's point, otherwise null | ||
*/ | ||
Point get(final String identifier); | ||
|
||
/** | ||
* @return the island points | ||
*/ | ||
List<Point> points(); | ||
} |
24 changes: 24 additions & 0 deletions
24
api/src/main/java/me/tofpu/speedbridge/api/island/IslandService.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,24 @@ | ||
package me.tofpu.speedbridge.api.island; | ||
|
||
import me.tofpu.speedbridge.api.user.User; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
public interface IslandService { | ||
void addIsland(final Island island); | ||
|
||
void removeIsland(final Island island); | ||
|
||
Island getIslandBySlot(final int slot); | ||
|
||
Island getIslandByUser(final User takenBy); | ||
|
||
List<Island> getAvailableIslands(); | ||
|
||
List<Island> getAvailableIslands(final Mode mode); | ||
|
||
void saveAll(final File directory, final boolean emptyList); | ||
|
||
void loadAll(final File directory); | ||
} |
25 changes: 25 additions & 0 deletions
25
api/src/main/java/me/tofpu/speedbridge/api/island/point/Point.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,25 @@ | ||
package me.tofpu.speedbridge.api.island.point; | ||
|
||
import org.bukkit.Location; | ||
|
||
public interface Point { | ||
/** | ||
* @return the point identifier | ||
*/ | ||
String identifier(); | ||
|
||
/** | ||
* @return the point location | ||
*/ | ||
Location pointA(); | ||
|
||
/** | ||
* @param location new location | ||
*/ | ||
void pointA(final Location location); | ||
|
||
/** | ||
* @return true if the location is not null, otherwise false | ||
*/ | ||
boolean hasPointA(); | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/java/me/tofpu/speedbridge/api/island/point/TwoSection.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,22 @@ | ||
package me.tofpu.speedbridge.api.island.point; | ||
|
||
import org.bukkit.Location; | ||
|
||
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(); | ||
} |
5 changes: 5 additions & 0 deletions
5
api/src/main/java/me/tofpu/speedbridge/api/util/Identifier.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,5 @@ | ||
package me.tofpu.speedbridge.api.util; | ||
|
||
public interface Identifier { | ||
String getIdentifier(); | ||
} |
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
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
1 change: 1 addition & 0 deletions
1
spigot/src/main/java/me/tofpu/speedbridge/island/IslandImpl.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
41 changes: 9 additions & 32 deletions
41
spigot/src/main/java/me/tofpu/speedbridge/island/mode/Mode.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,40 +1,17 @@ | ||
package me.tofpu.speedbridge.island.mode; | ||
|
||
import com.google.common.collect.Lists; | ||
import me.tofpu.speedbridge.util.Identifier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Mode implements Identifier { | ||
private final String identifier; | ||
private final List<Integer> slots; | ||
private final boolean aDefault; | ||
public interface Mode extends Identifier { | ||
/** | ||
* @return the mode initial selected slots | ||
*/ | ||
List<Integer> slots(); | ||
|
||
public Mode(final String identifier, final boolean aDefault) { | ||
this(identifier, Lists.newArrayList(), aDefault); | ||
} | ||
|
||
public Mode(final String identifier, final List<Integer> slots, final boolean aDefault) { | ||
this.identifier = identifier; | ||
this.slots = new ArrayList<>(slots); | ||
this.aDefault = aDefault; | ||
} | ||
|
||
public Mode(final String identifier, final List<Integer> slots) { | ||
this(identifier, slots, false); | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public List<Integer> getSlots() { | ||
return slots; | ||
} | ||
|
||
public boolean isDefault() { | ||
return aDefault; | ||
} | ||
/** | ||
* @return true if the settings was set to this, otherwise false | ||
*/ | ||
boolean isDefault(); | ||
} |
7 changes: 7 additions & 0 deletions
7
spigot/src/main/java/me/tofpu/speedbridge/island/mode/ModeFactory.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,7 @@ | ||
package me.tofpu.speedbridge.island.mode; | ||
|
||
public class ModeFactory { | ||
public static Mode of(final String identifier, final boolean isDefault){ | ||
return new ModeImpl(identifier, isDefault); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
spigot/src/main/java/me/tofpu/speedbridge/island/mode/ModeImpl.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,38 @@ | ||
package me.tofpu.speedbridge.island.mode; | ||
|
||
import com.google.common.collect.Lists; | ||
import me.tofpu.speedbridge.util.Identifier; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ModeImpl implements Mode { | ||
private final String identifier; | ||
private final List<Integer> slots; | ||
private final boolean aDefault; | ||
|
||
public ModeImpl(final String identifier, final boolean aDefault) { | ||
this(identifier, Lists.newArrayList(), aDefault); | ||
} | ||
|
||
public ModeImpl(final String identifier, final List<Integer> slots, final boolean aDefault) { | ||
this.identifier = identifier; | ||
this.slots = new ArrayList<>(slots); | ||
this.aDefault = aDefault; | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
@Override | ||
public List<Integer> slots() { | ||
return slots; | ||
} | ||
|
||
@Override | ||
public boolean isDefault() { | ||
return aDefault; | ||
} | ||
} |
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
spigot/src/main/java/me/tofpu/speedbridge/island/service/IslandService.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
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