Last active
December 21, 2015 15:39
-
-
Save bjornharrtell/6328528 to your computer and use it in GitHub Desktop.
bukkit test code
This file contains hidden or 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
package org | |
import org.bukkit.plugin.java.JavaPlugin | |
import com.mchange.v2.c3p0.ComboPooledDataSource | |
class ArkdesPlugin extends JavaPlugin { | |
val cpds = new ComboPooledDataSource() | |
cpds.setDriverClass("org.postgresql.Driver") | |
cpds.setJdbcUrl("jdbc:postgresql:test") | |
override def onEnable = { | |
val pm = getServer().getPluginManager() | |
val statement = cpds.getConnection().createStatement() | |
val resultSet = statement.executeQuery("select count(*) from parcel where a=0") | |
resultSet.next() | |
val count = resultSet.getInt(1) | |
pm.registerEvents(new BlockPlaceListener(), this); | |
} | |
} |
This file contains hidden or 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
package org | |
import org.bukkit.event.Listener | |
import org.bukkit.event.block.BlockPlaceEvent | |
import org.bukkit.event.EventHandler | |
class BlockPlaceListener extends Listener { | |
@EventHandler def callback(e: BlockPlaceEvent) { | |
val loc = e.getBlockPlaced().getLocation | |
val x = loc.getX | |
val z = loc.getZ | |
if (x > 730 && x < 735 && z > -435 && z < -430) | |
e.setBuild(true) | |
else | |
e.setBuild(false) | |
} | |
} |
This file contains hidden or 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
<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>arkdesplugin</groupId> | |
<artifactId>arkdesplugin</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<dependencies> | |
<dependency> | |
<groupId>postgresql</groupId> | |
<artifactId>postgresql</artifactId> | |
<version>9.1-901-1.jdbc4</version> | |
</dependency> | |
<dependency> | |
<groupId>com.mchange</groupId> | |
<artifactId>c3p0</artifactId> | |
<version>0.9.2.1</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<sourceDirectory>src/main/scala</sourceDirectory> | |
<plugins> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.0</version> | |
<configuration> | |
<source>1.6</source> | |
<target>1.6</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>net.alchim31.maven</groupId> | |
<artifactId>scala-maven-plugin</artifactId> | |
<version>3.1.5</version> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains hidden or 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
package org | |
import com.mchange.v2.c3p0.ComboPooledDataSource | |
object Test extends App { | |
val cpds = new ComboPooledDataSource() | |
cpds.setDriverClass( "org.postgresql.Driver" ) | |
cpds.setJdbcUrl( "jdbc:postgresql:test" ) | |
val statement = cpds.getConnection().createStatement() | |
val resultSet = statement.executeQuery("select count(*) from parcel where a=0") | |
resultSet.next() | |
val count = resultSet.getInt(1) | |
println(count) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment