Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split the project into 3 parts : Core, Bukkit and Sponge.
Core contains the main plugin logic, Bukkit stands for the Bukkit plugin and Sponge for the Sponge plugin.
- Loading branch information
Showing
86 changed files
with
6,348 additions
and
2,031 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,3 @@ | ||
plugins { | ||
id 'com.github.johnrengelman.shadow' version '2.0.4' | ||
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0' | ||
id 'java' | ||
id 'maven' | ||
} | ||
|
||
group = 'fr.skyost.serialkey' | ||
version = '0.4.1' | ||
|
||
sourceCompatibility = 1.8 | ||
|
||
bukkit { | ||
name = 'SerialKey' | ||
main = 'fr.skyost.serialkey.SerialKey' | ||
description = 'Lock your chests and doors.' | ||
author = 'Skyost' | ||
website = 'http://dev.bukkit.org/bukkit-plugins/serial-key/' | ||
apiVersion = '1.13' | ||
|
||
commands { | ||
serialkey { | ||
description = 'Main command of SerialKey.' | ||
aliases = ['serial-key', 'sk'] | ||
usage = '/serialkey getkey.' | ||
} | ||
} | ||
|
||
permissions { | ||
'serialkey.*' { | ||
setDefault('OP') | ||
description = 'Gives you all plugin\'s permissions' | ||
children = [ | ||
'serialkey.craft.key', | ||
'serialkey.craft.masterkey', | ||
'serialkey.craft.keyclone', | ||
'serialkey.craft.bunchofkeys', | ||
'serialkey.craft.padlockfinder', | ||
'serialkey.use.key', | ||
'serialkey.use.masterkey', | ||
'serialkey.use.bunchofkeys', | ||
'serialkey.use.padlockfinder', | ||
'serialkey.command.getkey', | ||
] | ||
} | ||
'serialkey.craft.key' { | ||
setDefault('TRUE') | ||
description = 'Allows you to craft a key.' | ||
} | ||
'serialkey.craft.masterkey' { | ||
setDefault('OP') | ||
description = 'Allows you to craft a master key.' | ||
} | ||
'serialkey.craft.keyclone' { | ||
setDefault('TRUE') | ||
description = 'Allows you to clone a key.' | ||
} | ||
'serialkey.craft.bunchofkeys' { | ||
setDefault('TRUE') | ||
description = 'Allows you to bunch of keys.' | ||
} | ||
'serialkey.craft.padlockfinder' { | ||
setDefault('TRUE') | ||
description = 'Allows you to craft a padlock finder.' | ||
} | ||
'serialkey.use.key' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a key.' | ||
} | ||
'serialkey.use.masterkey' { | ||
setDefault('OP') | ||
description = 'Allows you to use a master key.' | ||
} | ||
'serialkey.use.bunchofkeys' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a bunch of keys.' | ||
} | ||
'serialkey.use.padlockfinder' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a padlock finder.' | ||
} | ||
'serialkey.command.getkey' { | ||
setDefault('OP') | ||
description = 'Allows you to use /serialkey getkey.' | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } | ||
maven { url = 'http://nexus.hc.to/content/repositories/pub_releases' } | ||
maven { url = 'http://repo.bstats.org/content/repositories/releases/' } | ||
} | ||
|
||
dependencies { | ||
compileOnly 'org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT' | ||
compile 'org.bstats:bstats-bukkit-lite:1.2' | ||
} | ||
|
||
shadowJar { | ||
destinationDir = new File(rootProject.projectDir, 'build/release/') | ||
version = project.version | ||
configurations = [project.configurations.compile] | ||
mergeServiceFiles() | ||
relocate 'org.bstats.bukkit', 'fr.skyost.serialkey.util.bstats' | ||
subprojects { | ||
group = 'fr.skyost.serialkey' | ||
} |
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,105 @@ | ||
plugins { | ||
id 'com.github.johnrengelman.shadow' version '2.0.4' | ||
id 'net.minecrell.plugin-yml.bukkit' version '0.3.0' | ||
id 'java' | ||
id 'maven' | ||
} | ||
|
||
version = '1.0' | ||
sourceCompatibility = 1.8 | ||
|
||
bukkit { | ||
name = 'SerialKey' | ||
main = 'fr.skyost.serialkey.bukkit.SerialKey' | ||
description = 'Lock your chests and doors.' | ||
author = 'Skyost' | ||
website = 'http://dev.bukkit.org/bukkit-plugins/serial-key/' | ||
apiVersion = '1.13' | ||
|
||
commands { | ||
serialkey { | ||
description = 'Main command of SerialKey.' | ||
aliases = ['serial-key', 'sk'] | ||
usage = '/serialkey getkey.' | ||
} | ||
} | ||
|
||
permissions { | ||
'serialkey.*' { | ||
setDefault('OP') | ||
description = 'Gives you all plugin\'s permissions' | ||
children = [ | ||
'serialkey.craft.key', | ||
'serialkey.craft.masterkey', | ||
'serialkey.craft.keyclone', | ||
'serialkey.craft.bunchofkeys', | ||
'serialkey.craft.padlockfinder', | ||
'serialkey.use.key', | ||
'serialkey.use.masterkey', | ||
'serialkey.use.bunchofkeys', | ||
'serialkey.use.padlockfinder', | ||
'serialkey.command.getkey', | ||
] | ||
} | ||
'serialkey.craft.key' { | ||
setDefault('TRUE') | ||
description = 'Allows you to craft a key.' | ||
} | ||
'serialkey.craft.masterkey' { | ||
setDefault('OP') | ||
description = 'Allows you to craft a master key.' | ||
} | ||
'serialkey.craft.keyclone' { | ||
setDefault('TRUE') | ||
description = 'Allows you to clone a key.' | ||
} | ||
'serialkey.craft.bunchofkeys' { | ||
setDefault('TRUE') | ||
description = 'Allows you to bunch of keys.' | ||
} | ||
'serialkey.craft.padlockfinder' { | ||
setDefault('TRUE') | ||
description = 'Allows you to craft a padlock finder.' | ||
} | ||
'serialkey.use.key' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a key.' | ||
} | ||
'serialkey.use.masterkey' { | ||
setDefault('OP') | ||
description = 'Allows you to use a master key.' | ||
} | ||
'serialkey.use.bunchofkeys' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a bunch of keys.' | ||
} | ||
'serialkey.use.padlockfinder' { | ||
setDefault('TRUE') | ||
description = 'Allows you to use a padlock finder.' | ||
} | ||
'serialkey.command.getkey' { | ||
setDefault('OP') | ||
description = 'Allows you to use /serialkey getkey.' | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } | ||
maven { url = 'http://nexus.hc.to/content/repositories/pub_releases' } | ||
maven { url = 'http://repo.bstats.org/content/repositories/releases/' } | ||
} | ||
|
||
dependencies { | ||
implementation project(':core') | ||
compileOnly 'org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT' | ||
implementation 'org.bstats:bstats-bukkit-lite:1.2' | ||
} | ||
|
||
shadowJar { | ||
destinationDir = new File(rootProject.projectDir, 'build/release/') | ||
version = project.version | ||
mergeServiceFiles() | ||
relocate 'org.bstats.bukkit', 'fr.skyost.serialkey.bukkit.util.bstats' | ||
} |
116 changes: 116 additions & 0 deletions
116
bukkit/src/main/java/fr/skyost/serialkey/bukkit/BukkitTypeConverter.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,116 @@ | ||
package fr.skyost.serialkey.bukkit; | ||
|
||
import fr.skyost.serialkey.core.object.PersonIdentity; | ||
import fr.skyost.serialkey.core.object.SerialKeyLocation; | ||
import fr.skyost.serialkey.core.object.SerialKeyPerson; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
/** | ||
* A class that allows to convert core objects to Bukkit objects (and vice-versa). | ||
*/ | ||
|
||
public class BukkitTypeConverter { | ||
|
||
/** | ||
* Converts a SerialKey location to a Bukkit location. | ||
* | ||
* @param location The SerialKey location. | ||
* | ||
* @return The Bukkit location. | ||
*/ | ||
|
||
public static Location toBukkitLocation(final SerialKeyLocation location) { | ||
return new Location(Bukkit.getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ()); | ||
} | ||
|
||
/** | ||
* Converts a Bukkit location to a SerialKey location. | ||
* | ||
* @param location The Bukkit location. | ||
* | ||
* @return The SerialKey location. | ||
*/ | ||
|
||
public static SerialKeyLocation toSerialKeyLocation(final Location location) { | ||
return new SerialKeyLocation(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()); | ||
} | ||
|
||
/** | ||
* Converts a SerialKey person to a Bukkit command sender. | ||
* | ||
* @param person The SerialKey person. | ||
* | ||
* @return The Bukkit command sender. | ||
*/ | ||
|
||
public static CommandSender toBukkitPerson(final SerialKeyPerson person) { | ||
final PersonIdentity identity = person.getIdentity(); | ||
if(identity.getType() == PersonIdentity.Type.CONSOLE) { | ||
return Bukkit.getConsoleSender(); | ||
} | ||
|
||
return Bukkit.getPlayer(identity.getName()); | ||
} | ||
|
||
/** | ||
* Converts a Bukkit command sender to a SerialKey person. | ||
* | ||
* @param sender Bukkit command sender. | ||
* | ||
* @return The SerialKey person. | ||
*/ | ||
|
||
public static SerialKeyPerson toSerialKeyPerson(final CommandSender sender) { | ||
return new BukkitPerson(sender); | ||
} | ||
|
||
/** | ||
* Represents a Bukkit person. | ||
*/ | ||
|
||
private static class BukkitPerson implements SerialKeyPerson { | ||
|
||
/** | ||
* The sender instance. | ||
*/ | ||
|
||
private final CommandSender sender; | ||
|
||
/** | ||
* The identity. | ||
*/ | ||
|
||
private final PersonIdentity identity; | ||
|
||
/** | ||
* Creates a new Bukkit person instance. | ||
* | ||
* @param sender The sender instance. | ||
*/ | ||
|
||
BukkitPerson(final CommandSender sender) { | ||
this.sender = sender; | ||
this.identity = new PersonIdentity(sender instanceof Player ? PersonIdentity.Type.PLAYER : PersonIdentity.Type.CONSOLE, sender.getName()); | ||
} | ||
|
||
@Override | ||
public PersonIdentity getIdentity() { | ||
return identity; | ||
} | ||
|
||
@Override | ||
public void sendMessage(final String message) { | ||
sender.sendMessage(message); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(final String permission) { | ||
return sender.hasPermission(permission); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.