forked from andrei1058/HandyOrbs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f4c2c5
commit efa59ff
Showing
39 changed files
with
1,360 additions
and
146 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
17 changes: 17 additions & 0 deletions
17
handyorbs-api/src/main/java/com/andrei1058/handyorbs/api/HandyOrbs.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,4 +1,21 @@ | ||
package com.andrei1058.handyorbs.api; | ||
|
||
import com.andrei1058.handyorbs.core.OrbBase; | ||
import org.bukkit.Location; | ||
|
||
public interface HandyOrbs { | ||
|
||
/** | ||
* Register a new orb. | ||
* | ||
* @param identifier unique identifier. | ||
* @param orb orb class. | ||
* @param category orb category. | ||
*/ | ||
boolean registerOrb(String identifier, Class<? extends OrbBase> orb, OrbCategory category); | ||
|
||
/** | ||
* Spawn a new orb. | ||
*/ | ||
OrbBase spawnOrb(String identifier, OrbCategory category, Location location, int radius); | ||
} |
9 changes: 9 additions & 0 deletions
9
handyorbs-api/src/main/java/com/andrei1058/handyorbs/api/OrbCategory.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,9 @@ | ||
package com.andrei1058.handyorbs.api; | ||
|
||
public enum OrbCategory { | ||
|
||
FARMING, | ||
SPECIAL, | ||
PVP, | ||
OTHER; | ||
} |
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
56 changes: 41 additions & 15 deletions
56
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/OrbBase.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,30 +1,56 @@ | ||
package com.andrei1058.handyorbs.core; | ||
|
||
import org.bukkit.Location; | ||
|
||
public class OrbBase { | ||
import com.andrei1058.handyorbs.core.region.IRegion; | ||
import com.andrei1058.handyorbs.core.version.OrbEntity; | ||
import com.andrei1058.handyorbs.core.version.OrbEntityFactory; | ||
import org.bukkit.*; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class OrbBase { | ||
|
||
private int orbId = -1; | ||
private String world; | ||
private IRegion region; | ||
private OrbEntity orbEntity; | ||
|
||
protected OrbBase(Location location, IRegion region) { | ||
this.world = location.getWorld() == null ? "null" : location.getWorld().getName(); | ||
this.region = region; | ||
World world = Bukkit.getWorld(this.world); | ||
if (world == null) throw new IllegalStateException("World is not loaded!"); | ||
orbEntity = OrbEntityFactory.getInstance().spawnOrbEntity(new Location(world, location.getX(), location.getY(), location.getZ()), new ItemStack(Material.GOLD_BLOCK)); | ||
if (orbEntity == null) throw new IllegalStateException("Could not spawn orb entity!"); | ||
|
||
orbEntity.setDisplayName("&x&F&E&D&B&F&0My &x&C&B&A&F&C&0Nice &x&5&1&4&6&4&COrb"); | ||
orbEntity.setRightClickListener((player -> { | ||
player.sendMessage("right click " + (player.isSneaking() ? "(shifting)" : "")); | ||
return null; | ||
})); | ||
} | ||
|
||
private Location location; | ||
public void unLoad() { | ||
|
||
protected OrbBase(Location location){ | ||
this.location = location; | ||
} | ||
|
||
public boolean load(){ | ||
return false; | ||
public int getOrbId() { | ||
return orbId; | ||
} | ||
|
||
public void unLoad(){ | ||
|
||
public OrbEntity getOrbEntity() { | ||
return orbEntity; | ||
} | ||
|
||
public void changeLocation(Location newLocation){ | ||
this.location = newLocation; | ||
// todo teleport orb | ||
public String getWorld() { | ||
return world; | ||
} | ||
|
||
protected void tickAnimation(){ | ||
|
||
public String getDisplayName(){ | ||
return orbEntity.getName(); | ||
} | ||
|
||
public void setOrbId(int orbId) { | ||
this.orbId = orbId; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/model/Ownable.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,10 @@ | ||
package com.andrei1058.handyorbs.core.model; | ||
|
||
import java.util.UUID; | ||
|
||
public interface Ownable { | ||
|
||
UUID getOwner(); | ||
|
||
void setOwner(UUID uuid); | ||
} |
24 changes: 24 additions & 0 deletions
24
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/model/WheatOrb.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 com.andrei1058.handyorbs.core.model; | ||
|
||
import com.andrei1058.handyorbs.core.OrbBase; | ||
import com.andrei1058.handyorbs.core.region.IRegion; | ||
import org.bukkit.Location; | ||
|
||
import java.util.UUID; | ||
|
||
public class WheatOrb extends OrbBase implements Ownable { | ||
|
||
private UUID owner; | ||
|
||
public WheatOrb(Location location, IRegion region) { | ||
super(location, region); | ||
} | ||
|
||
public void setOwner(UUID owner) { | ||
this.owner = owner; | ||
} | ||
|
||
public UUID getOwner() { | ||
return owner; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/region/Cuboid.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,31 @@ | ||
package com.andrei1058.handyorbs.core.region; | ||
|
||
import org.bukkit.Location; | ||
|
||
public class Cuboid implements IRegion{ | ||
|
||
private final int minX, maxX; | ||
private final int minY, maxY; | ||
private final int minZ, maxZ; | ||
|
||
|
||
public Cuboid(int radius, Location center){ | ||
Location l1 = center.clone().subtract(radius, radius, radius); | ||
Location l2 = center.clone().add(radius, radius, radius); | ||
|
||
minX = Math.min(l1.getBlockX(), l2.getBlockX()); | ||
maxX = Math.max(l1.getBlockX(), l2.getBlockX()); | ||
|
||
minY = Math.min(l1.getBlockY(), l2.getBlockY()); | ||
maxY = Math.max(l1.getBlockY(), l2.getBlockY()); | ||
|
||
minZ = Math.min(l1.getBlockZ(), l2.getBlockZ()); | ||
maxZ = Math.max(l1.getBlockZ(), l2.getBlockZ()); | ||
|
||
} | ||
|
||
@Override | ||
public boolean isInRegion(Location l) { | ||
return (l.getBlockX() <= maxX && l.getBlockX() >= minX) && (l.getY() <= maxY && l.getY() >= minY) && (l.getBlockZ() <= maxZ && l.getBlockZ() >= minZ); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/region/IRegion.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,8 @@ | ||
package com.andrei1058.handyorbs.core.region; | ||
|
||
import org.bukkit.Location; | ||
|
||
public interface IRegion { | ||
|
||
boolean isInRegion(Location location); | ||
} |
10 changes: 0 additions & 10 deletions
10
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/CarrotOrb.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/FishingOrb.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/FlowerOrb.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/NetherWartOrb.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/PotatoOrb.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
handyorbs-core/src/main/java/com/andrei1058/handyorbs/core/types/RadiantPowerOrb.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.