Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .classpath

This file was deleted.

32 changes: 32 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
bin
target
*.glob
.*.glob
.classpath
.project
.settings
.idea/
*.iml
*.ipr
*.iws
dependency-reduced-pom.xml
/target/
/anvilstringcommand/target/
/common/target/
/v18r1/target/
/v18r2/target/
/v18r3/target/
/v19r1/target/
/v19r2/target/
*.class
.project
.classpath
/.settings/

/lib/
.settings
.git
17 changes: 0 additions & 17 deletions .project

This file was deleted.

12 changes: 0 additions & 12 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72 changes: 72 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!-- ScriptBlock Plugin build file -->

<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>scriptblock</groupId>
<artifactId>ScriptBlock</artifactId>
<version>0.8.72</version>
<name>ScriptBlock</name>

<!-- Properties -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<build.number>Unknown</build.number>
</properties>

<!-- Repositories -->
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>md_5-repo</id>
<url>http://repo.md-5.net/content/groups/public/</url>
</repository>
<repository>
<id>yeti-repo</id>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
</repository>
</repositories>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.9-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.5.6</version>
<scope>provided</scope>
</dependency>
</dependencies>

<!-- Build information -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
27 changes: 27 additions & 0 deletions src/main/java/scriptblock/BlockCoords.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package scriptblock;

public class BlockCoords {
public String world;
public int x;
public int y;
public int z;
private String coords;
private String fullCoords;

public BlockCoords(String world, int x, int y, int z) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.coords = x + "," + y + "," + z;
this.fullCoords = world + "," + this.coords;
}

public String getCoords() {
return this.coords;
}

public String getFullCoords() {
return this.fullCoords;
}
}
22 changes: 22 additions & 0 deletions src/main/java/scriptblock/SLAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package scriptblock;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class SLAPI {
public static void save(Object obj, String path) throws Exception {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(path));
oos.writeObject(obj);
oos.flush();
oos.close();
}

public static Object load(String path) throws Exception {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(path));
Object result = ois.readObject();
ois.close();
return result;
}
}
97 changes: 97 additions & 0 deletions src/main/java/scriptblock/ScriptBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package scriptblock;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Logger;

import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import scriptblock.listeners.PlayerInteractBlock;
import scriptblock.listeners.PlayerWalkBlock;
import scriptblock.managers.ScriptManager;

public class ScriptBlock extends JavaPlugin {
private static ScriptBlock instance;
public static Logger log;
private ArrayList<ScriptManager> scriptManagerList = new ArrayList<ScriptManager>();
private PlayerInteractBlock playerInteractBlock;
private PlayerWalkBlock playerWalkBlock;
private PluginManager pm;
private Permission perm;
private Economy eco;

public void onEnable() {
instance = this;
this.pm = this.getServer().getPluginManager();
log = this.getServer().getLogger();
this.hookVault();
this.playerInteractBlock = new PlayerInteractBlock(this);
this.playerWalkBlock = new PlayerWalkBlock(this);
this.register(this.playerInteractBlock, this);
this.register(this.playerWalkBlock, this);
log.info("[ScriptBlock] Enabled !!!");
}

public void onDisable() {
long t = System.currentTimeMillis();
Iterator<ScriptManager> var4 = (Iterator<ScriptManager>)this.scriptManagerList.iterator();

while(var4.hasNext()) {
ScriptManager scriptManager = (ScriptManager)var4.next();
scriptManager.getFileManager().saveDisabledTime(t);
}

instance = null;
log.info("[ScriptBlock] Disabled !!!");
}

public void register(ScriptManager scriptManager, JavaPlugin plugin) {
this.scriptManagerList.add(scriptManager);
this.pm.registerEvents(scriptManager, plugin);
}

public void hookVault() {
if(this.pm.isPluginEnabled("Vault")) {
RegisteredServiceProvider<Permission> permissionProvider = this.getServer().getServicesManager().getRegistration(Permission.class);
if(permissionProvider != null) {
this.perm = (Permission)permissionProvider.getProvider();
log.info("[ScriptBlock] " + this.perm.getName() + " found !");
} else {
log.info("[ScriptBlock] No Permissions Plugin found !");
log.info("[ScriptBlock] Do Not use (@bypass:\'group\') Option !");
}

RegisteredServiceProvider<Economy> economyProvider = this.getServer().getServicesManager().getRegistration(Economy.class);
if(economyProvider != null) {
this.eco = (Economy)economyProvider.getProvider();
log.info("[ScriptBlock] " + this.eco.getName() + " found !");
} else {
log.info("[ScriptBlock] NO Economy Plugin found !");
log.info("[ScriptBlock] Do not use \'$cost:\' Option");
}
} else {
log.info("[ScriptBlock] Vault is not Installed ! ");
log.info("[ScriptBlock] Permission, and Economy Options won\'t work !");
}

}

public Permission getPerm() {
return this.perm;
}

public Economy getEco() {
return this.eco;
}

public static ScriptBlock getInstance() {
return instance;
}

public ArrayList<ScriptManager> getScriptManagerList() {
return this.scriptManagerList;
}
}
80 changes: 80 additions & 0 deletions src/main/java/scriptblock/command/BindScript.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package scriptblock.command;

import java.util.LinkedList;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import scriptblock.BlockCoords;
import scriptblock.ScriptBlock;
import scriptblock.command.CommandCreate;
import scriptblock.command.CommandHandler;
import scriptblock.managers.FileManager;
import scriptblock.managers.MapManager;
import scriptblock.managers.PermManager;
import scriptblock.managers.ScriptManager;

public abstract class BindScript {
protected ScriptBlock scriptBlock;
protected Logger log;
protected JavaPlugin plugin;
protected ScriptManager scriptManager;
protected CommandHandler.CommandType commandType;
protected FileManager fileManager;
protected MapManager mapManager;
protected PermManager permManager;
protected Player commandSender;
protected String statusCancelled;
protected String[] noAccessPermMsg;

public BindScript(ScriptManager scriptManager, Player commandSender) {
this(scriptManager, commandSender, (CommandHandler.CommandType)null);
}

public BindScript(ScriptManager scriptManager, Player commandSender, CommandHandler.CommandType commandType) {
this.scriptBlock = ScriptBlock.getInstance();
this.log = ScriptBlock.log;
this.plugin = scriptManager.getPlugin();
this.scriptManager = scriptManager;
this.commandType = commandType;
this.mapManager = scriptManager.getMapManager();
this.fileManager = scriptManager.getFileManager();
this.permManager = scriptManager.getPermManager();
this.commandSender = commandSender;
this.statusCancelled = new String(ChatColor.RED + "[" + this.plugin.getName() + "] " + commandType.name() + " status cancelled !");
this.noAccessPermMsg = new String[]{this.permManager.noPermMsg, ChatColor.RED + "[" + this.plugin.getName() + "] You can\'t \"" + commandType.name() + "\" scripts you don\'t own!"};
}

public abstract boolean onEvent(BlockCoords var1);

protected boolean canAccessScript(BlockCoords blockCoords) {
LinkedList commandList = (LinkedList)this.mapManager.blocksMap.get(blockCoords.getFullCoords());
String perm = new String("modify." + this.commandType.name());
if(commandList == null) {
return true;
} else {
String firstLine = (String)commandList.getFirst();
if(firstLine.startsWith(CommandCreate.authorNode)) {
firstLine = firstLine.replaceFirst(CommandCreate.authorNode, "");
String[] scriptInfos = firstLine.split("/");
String authorName = scriptInfos[0];
String authorGroup = scriptInfos[1];
if(!this.commandSender.getName().equals(authorName) && !this.permManager.hasSBPerm(this.commandSender, perm + "." + authorGroup, false)) {
this.commandSender.sendMessage(this.noAccessPermMsg);
return false;
} else {
return true;
}
} else if(this.permManager.hasSBPerm(this.commandSender, perm, false)) {
return true;
} else {
this.commandSender.sendMessage(this.noAccessPermMsg);
return false;
}
}
}

public CommandHandler.CommandType getCommandType() {
return this.commandType;
}
}
Loading