forked from SteamWar/SteamWar
Add DynamicRegion
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bausystem.region;
|
||||
|
||||
import de.steamwar.core.Core;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -39,11 +40,6 @@ public interface RegionSystem {
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* Saves anything that should be written to file on either CRIUSleepEvent or plugin disable.
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Returns the Location to teleport players to when they first join or Warp to "WorldSpawn"
|
||||
*/
|
||||
@@ -77,52 +73,51 @@ public interface RegionSystem {
|
||||
Stream<Region> getRegions();
|
||||
|
||||
private static RegionSystem init() {
|
||||
try {
|
||||
return (RegionSystem) Class.forName("de.steamwar.bausystem.region.DynamicRegionSystem").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
// Ignore
|
||||
if (Core.getVersion() >= 21) {
|
||||
// TODO: Add some kind of detection if the DynamicRegionSystem should be used!
|
||||
try {
|
||||
return (RegionSystem) Class.forName("de.steamwar.bausystem.region.DynamicRegionSystem").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
try {
|
||||
return (RegionSystem) Class.forName("de.steamwar.bausystem.region.FixedRegionSystem").getConstructor().newInstance();
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
return new RegionSystem() {
|
||||
@Override
|
||||
public void load() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Location getWorldSpawn() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getGlobalRegion() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(UUID id) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
// Ignore
|
||||
}
|
||||
return new RegionSystem() {
|
||||
@Override
|
||||
public void load() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Location getWorldSpawn() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getGlobalRegion() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region get(Location location) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Region> getRegion(UUID id) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Region> getRegions() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user