-
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.
- Loading branch information
0 parents
commit e57d8db
Showing
26 changed files
with
1,435 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea | ||
*.iml | ||
target | ||
dependency-reduced-pom.xml |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Avicus Network | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,2 @@ | ||
# Scaffold | ||
A plugin for build servers. |
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,139 @@ | ||
<?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>com.minehut</groupId> | ||
<artifactId>scaffold</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
|
||
<repository> | ||
<id>avicus-repo</id> | ||
<url>https://repo.avicus.net/content/groups/public</url> | ||
</repository> | ||
</repositories> | ||
|
||
<distributionManagement> | ||
<snapshotRepository> | ||
<id>minehut-repo</id> | ||
<name>minehut repo</name> | ||
<url>http://repo.minehut.com:8081/nexus/content/repositories/snapshots</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
|
||
<dependencies> | ||
<!-- Provided Dependencies --> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.9-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>net.lingala.zip4j</groupId> | ||
<artifactId>zip4j</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.mashape.unirest</groupId> | ||
<artifactId>unirest-java</artifactId> | ||
<version>1.4.9</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.3.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpasyncclient</artifactId> | ||
<version>4.0.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpmime</artifactId> | ||
<version>4.3.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20140107</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>1.16.6</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.sk89q</groupId> | ||
<artifactId>command-framework-bukkit</artifactId> | ||
<version>0.6-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.sk89q</groupId> | ||
<artifactId>command-framework-core</artifactId> | ||
<version>0.6-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- Build Settings --> | ||
<build> | ||
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory> | ||
|
||
<!-- Resources --> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}/src/main/resources/</directory> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<!-- JAR creation plugin --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
|
||
<!-- shading --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.1</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/minehut/scaffold/NullChunkGenerator.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,13 @@ | ||
package com.minehut.scaffold; | ||
|
||
import org.bukkit.World; | ||
import org.bukkit.generator.ChunkGenerator; | ||
|
||
import java.util.Random; | ||
|
||
public class NullChunkGenerator extends ChunkGenerator { | ||
@Override | ||
public byte[] generate(World world, Random random, int x, int z) { | ||
return new byte[65536]; | ||
} | ||
} |
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,99 @@ | ||
package com.minehut.scaffold; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.minehut.scaffold.ScaffoldListener; | ||
import com.minehut.scaffold.ScaffoldWorld; | ||
import com.sk89q.bukkit.util.CommandsManagerRegistration; | ||
import com.sk89q.minecraft.util.commands.*; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.ConsoleCommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.*; | ||
|
||
public class Scaffold extends JavaPlugin implements TabCompleter { | ||
private static Scaffold instance; | ||
private CommandsManager<CommandSender> commands; | ||
private Map<ScaffoldWorld, Long> locked = new HashMap<>(); | ||
|
||
public static Scaffold instance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
instance = this; | ||
|
||
getServer().getPluginManager().registerEvents(new ScaffoldListener(), this); | ||
|
||
this.commands = new CommandsManager<CommandSender>() { | ||
@Override | ||
public boolean hasPermission(CommandSender sender, String perm) { | ||
return sender instanceof ConsoleCommandSender || sender.hasPermission(perm); | ||
} | ||
}; | ||
|
||
CommandsManagerRegistration cmds = new CommandsManagerRegistration(this, this.commands); | ||
cmds.register(ScaffoldCommands.class); | ||
|
||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { | ||
@Override | ||
public void run() { | ||
for (ScaffoldWorld wrapper : locked.keySet()) { | ||
if (wrapper.isOpen()) | ||
wrapper.getWorld().get().setFullTime(locked.get(wrapper)); | ||
} | ||
} | ||
}, 0, 20); | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { | ||
try { | ||
this.commands.execute(cmd.getName(), args, sender, sender); | ||
} catch (CommandPermissionsException e) { | ||
sender.sendMessage(ChatColor.RED + "You don't have permission."); | ||
} catch (MissingNestedCommandException e) { | ||
sender.sendMessage(ChatColor.RED + e.getUsage()); | ||
} catch (CommandUsageException e) { | ||
sender.sendMessage(ChatColor.RED + e.getMessage()); | ||
sender.sendMessage(ChatColor.RED + e.getUsage()); | ||
} catch (WrappedCommandException e) { | ||
if (e.getCause() instanceof NumberFormatException) { | ||
sender.sendMessage(ChatColor.RED + "Number expected, string received instead."); | ||
} else { | ||
sender.sendMessage(ChatColor.RED + "An error has occurred. See console."); | ||
e.printStackTrace(); | ||
} | ||
} catch (CommandException e) { | ||
sender.sendMessage(ChatColor.RED + e.getMessage()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public void sync(Runnable runnable) { | ||
getServer().getScheduler().runTask(this, runnable); | ||
} | ||
|
||
public void async(Runnable runnable) { | ||
getServer().getScheduler().runTaskAsynchronously(this, runnable); | ||
} | ||
|
||
public boolean toggleLock(ScaffoldWorld wrapper) { | ||
Preconditions.checkArgument(wrapper.isOpen(), "World not open."); | ||
Iterator<ScaffoldWorld> iterator = this.locked.keySet().iterator(); | ||
while (iterator.hasNext()) { | ||
ScaffoldWorld next = iterator.next(); | ||
if (next.getName().equals(wrapper.getName())) { | ||
iterator.remove(); | ||
return false; | ||
} | ||
} | ||
locked.put(wrapper, wrapper.getWorld().get().getFullTime()); | ||
return true; | ||
} | ||
} |
Oops, something went wrong.