Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- public class SignJoinJoin extends PluginListener
- {
- Logger log = Logger.getLogger("Minecraft");
- int i = 0;
- public boolean onSignChange(Player player, Sign sign)
- {
- Block b = sign.getBlock();
- World world = player.getWorld();
- if ((sign.getText(0).equals("[Join]")) &&
- (player.canUseCommand("/signadmin"))) {
- sign.setText(0, "[Join]");
- if (sign.getText(1).isEmpty()) sign.setText(1, "§4White List");
- if (sign.getText(2).isEmpty()) sign.setText(2, "§4add to Group:");
- if (sign.getText(3).isEmpty()) sign.setText(3, "default");
- player.sendMessage("§2Sign sucsessfully created.");
- return false;
- }
- if (sign.getText(0).equals("[Caste]")) {
- if ((!player.canUseCommand("/signadmin")) ||
- (sign.getText(1).isEmpty())) { player.notify("You have to fill in an group on line 2"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
- if (!etc.getDataSource().doesGroupExist(sign.getText(1))) { player.notify("The group on line 2 does not exist"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
- if (sign.getText(2).isEmpty()) { player.notify("You have to fill in an group on line 3"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
- if (!etc.getDataSource().doesGroupExist(sign.getText(2))) { player.notify("The group on line 3 does not exist"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
- if (sign.getText(3).isEmpty()) { player.notify("You have to fill in an price on line 4"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; } try {
- Double.parseDouble(sign.getText(3)); } catch (NumberFormatException nfe) { player.notify("Line 4 must be an number!"); world.setBlockAt(0, sign.getX(), sign.getY(), sign.getZ()); world.dropItem(b.getLocation(), 323); return true; }
- player.sendMessage("§2Sign sucsessfully created.");
- return false;
- }else{
- if (sign.getText(0).equals("[Exam]")){
- if (player.canUseCommand("/signadmin")){
- if (sign.getText(1).isEmpty()){sign.setText(1, "§4Right Click");}
- if (sign.getText(2).isEmpty()){sign.setText(2, "§4This Sign To");}
- if (!sign.getText(3).isEmpty()){
- char[] c = sign.getText(3).toCharArray();
- while(!isNumber(c[i])){
- i++;
- }
- String ccs = c[i]+"";
- int cc = Integer.parseInt(ccs);
- if (cc != 1 && cc != 2 && cc != 3){
- player.notify("Line 4 has to contain a number between 1 - 3");
- i = 0;
- return true;
- }else{
- player.sendMessage("§2Sign successfully created");
- i = 0;
- return false;
- }
- }else{
- sign.setText(3, "Do Exam 1"); i = 0; return false;
- }
- }else{ player.sendMessage("§cYou cant create those signs!");return true;}
- }
- }
- return false;
- }
- public boolean onBlockRightClick(Player player, Block bc, Item iih) {
- if ((bc.getType() == 63) || (bc.getType() == 68)) {
- Sign sign = (Sign)bc.getWorld().getComplexBlock(bc.getX(), bc.getY(), bc.getZ());
- if (sign.getText(0).equalsIgnoreCase("[Join]")) {
- if (player.canUseCommand("/signjoin")) {
- if (!etc.getDataSource().isUserOnWhitelist(player.getName())) {
- if ((player.getGroups()[0].equals("default")) || (player.getGroups()[0].equals("guest"))) {
- player.setGroups(new String[] { sign.getText(3) });
- etc.getDataSource().modifyPlayer(player);
- etc.getDataSource().addToWhitelist(player.getName());
- player.sendMessage("§2Your added to the whitelist and modified.");
- return false;
- }
- player.notify("You are already modified.");
- return true;
- }
- player.notify("You are already on the whitelist");
- }
- else {
- player.notify("You are not allowed to preform this command");
- return true;
- }
- }
- if (sign.getText(0).equals("[Caste]")) {
- if (sign.getText(1).equals(player.getGroups()[0])) {
- double money = ((Double)etc.getLoader().callCustomHook("dCBalance", new Object[] { "Player-Balance", player.getName() })).doubleValue();
- if (money < Double.parseDouble(sign.getText(3))) { player.notify("You dont have enough money to preform this action"); return true; }
- player.setGroups(new String[] { sign.getText(2) });
- etc.getDataSource().modifyPlayer(player);
- etc.getLoader().callCustomHook("dCBalance", new Object[] { "Player-Charge", player.getName(), Double.valueOf(Double.parseDouble(sign.getText(3))) });
- //newcode
- char[] c = sign.getText(2).toCharArray();
- while(!isNumber(c[i])){
- i++;
- }
- String[] cmd = player.getCommands();
- String teach = "/teach"+c[i];
- String[] tcmd;
- String t;
- t = etc.combineSplit(0, cmd, ",") + teach; tcmd = t.split(",");
- player.setCommands(tcmd);
- player.chat("/teach"+c[i]+" "+player.getName()+" PASS");
- player.setCommands(cmd);
- i = 0;
- //newcode
- player.sendMessage("§2You Changed from caste");
- return false;
- }
- player.notify("You can not change from your current caste to this caste");
- return true;
- }else{
- if (sign.getText(0).equals("[Exam]")){
- char[] c = sign.getText(3).toCharArray();
- while(!isNumber(c[i])){
- i++;
- }
- String CS = c[i]+"";
- int CI = Integer.parseInt(CS);
- if (ExStat(player.getName(), CI)){
- int x = bc.getX();
- int z = bc.getZ();
- int y = (int)player.getY()+1;
- int xpos = sign.getX(); int ypos = sign.getY(); int zpos = sign.getZ();
- switch (sign.getBlock().getData()) {
- case 2: zpos += 1; break; case 3: zpos -= 1; break; case 4:xpos += 1; break; case 5: xpos -= 1;
- }
- Block b = bc.getWorld().getBlockAt(xpos, ypos, zpos);
- if (b.getType() != 0){
- if (x - xpos == 1){
- player.teleportTo(x-3,y,z, 0, 0);
- }else
- if (x - xpos == -1){
- player.teleportTo(x+3,y,z,0,0);
- }else
- if(z - zpos == 1){
- player.teleportTo(x,y,z-3, 0,0);
- }else
- if (z - zpos == -1){
- player.teleportTo(x,y,z+3, 0,0);
- }
- }
- player.sendMessage("§2Your Exam started!");
- i = 0;
- return false;
- }else{
- player.notify("You are not registered for this exam !");
- i = 0;
- return true;
- }
- }
- }
- }
- return false;
- }
- public boolean isNumber(char c){try{Integer.parseInt(c+"");}catch(NumberFormatException nfe){return false;}
- return true;}
- @SuppressWarnings("deprecation")
- public boolean ExStat(String Name, int exam){
- boolean isReg = false;
- Connection conn = null;
- ResultSet rs = null;
- PreparedStatement ps = null;
- try{
- conn = etc.getSQLConnection();
- ps = conn.prepareStatement("SELECT E"+exam+"Status FROM ExamReg WHERE PlayerName = ?");
- ps.setString(1, Name);
- rs = ps.executeQuery();
- if (rs.next()){
- String check = rs.getString("E"+exam+"Status");
- if(check.matches("WAITING")){
- isReg = true;
- }
- }
- } catch (SQLException ex) {
- log.log(Level.SEVERE, "Could not access database:", ex);
- } finally {
- try {
- if (rs != null)
- rs.close();
- if (conn != null)
- conn.close();
- } catch (SQLException ex) {
- log.log(Level.SEVERE, "Could Not Close SQL Connection:", ex);
- }
- }
- return isReg;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment