Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
dazza authored and dazza committed Mar 22, 2014
1 parent af3da56 commit f0f9c8a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/commands/CheckCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Integer (CommandSender sender, String[] args) {
}

}

//sdtsdfsdf
@command
public void Null (CommandSender sender, String[] args) {
String[] page1 = Utils.addInFront(args, "1");
Expand Down Expand Up @@ -98,6 +98,5 @@ public void claimed(CommandSender sender, String[] args) {





}
10 changes: 5 additions & 5 deletions src/commands/ModreqCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -45,7 +46,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
ticketsfromplayer = tickets.getTicketsFromPlayer(p, sender.getName(),Status.OPEN);
if(plugin.getConfig().getInt("maximum-open-tickets") > ticketsfromplayer) {
String message = Utils.join(args, " ", 0);
savereq(message, sender, ((Player) sender).getLocation());
savereq(message, sender, ((Player) sender).getLocation(), ((Player) sender).getServer());
sendMessageToAdmins(ChatColor.GREEN + sender.getName() + " " + ChatColor.AQUA + plugin.Messages.getString("submitted-mod", "submitted a moderator request"));
p.sendMessage(ChatColor.GREEN + plugin.Messages.getString("submitted-player", "You successfully submitted a help ticket, a moderator will help you soon"));
return true;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void sendMessageToAdmins(String message) {//sends a message to all online
}

}
public void savereq(String message, CommandSender sender, Location loc) {//save a ticket to the database
public void savereq(String message, CommandSender sender, Location loc, Server serv) {//save a ticket to the database
String timezone = plugin.getConfig().getString("timezone");
DateFormat df = new SimpleDateFormat(plugin.getConfig().getString("timeformat","YY-MM-dd HH:mm:ss"));
TimeZone tz = TimeZone.getTimeZone(timezone);
Expand All @@ -88,12 +89,11 @@ public void savereq(String message, CommandSender sender, Location loc) {//save
cal.add(Calendar.MILLISECOND,-(cal.getTimeZone().getRawOffset()));
cal.add(Calendar.MILLISECOND, tz.getRawOffset());
Date dt = new Date(cal.getTimeInMillis());

String call = df.format(dt) + " @" + timezone;
String location = loc.getWorld().getName()+" @ "+Math.round(loc.getX()) + " "+Math.round(loc.getY())+" "+Math.round(loc.getZ());

String serverr = serv.getServerName();
try {
tickets.addTicket( sender.getName(), message, call, Status.OPEN, location);
tickets.addTicket( sender.getName(), serverr, message, call, Status.OPEN, location);
} catch (SQLException e) {}
}

Expand Down
12 changes: 7 additions & 5 deletions src/managers/TicketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ private Connection getConnection() {

Connection conn = DriverManager.getConnection("jdbc:mysql://"+ip, user, pass);
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS requests (id INT, submitter TEXT, message TEXT, date TEXT, status TEXT, comment TEXT, location TEXT, staff TEXT)");
stat.execute("CREATE TABLE IF NOT EXISTS requests (id INT, submitter TEXT, message TEXT, date TEXT, status TEXT, comment TEXT, location TEXT, staff TEXT, server TEXT)");
return conn;
}
else {
Connection conn = DriverManager.getConnection("jdbc:sqlite:plugins/ModReq/DataBase.sql");
Statement stat = conn.createStatement();
stat.execute("CREATE TABLE IF NOT EXISTS requests (id int, submitter String, message String, date String, status String, comment String, location String, staff String)");
stat.execute("CREATE TABLE IF NOT EXISTS requests (id int, submitter String, message String, date String, status String, comment String, location String, staff String, server String)");
return conn;
}
} catch (Exception e) {
Expand Down Expand Up @@ -194,10 +194,10 @@ public int getTicketAmount(Status status) {
return 0;

}
public void addTicket(String submitter, String message, String date, Status status, String location) throws SQLException {//add a new ticket to the database
public void addTicket(String submitter, String serverr, String message, String date, Status status, String location) throws SQLException {//add a new ticket to the database
Connection conn = getConnection();

PreparedStatement prep = conn.prepareStatement("INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?,?,?)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO requests VALUES (?, ?, ?, ?, ?, ?,?,?,?)");
prep.setInt(1, getTicketCount() +1);
prep.setString(2, submitter);
prep.setString(3, message);
Expand All @@ -206,6 +206,7 @@ public void addTicket(String submitter, String message, String date, Status stat
prep.setString(6, "no comments yet");
prep.setString(7, location);
prep.setString(8, "no staff member yet");
prep.setString(9, serverr);
prep.addBatch();


Expand All @@ -228,7 +229,8 @@ public Ticket getTicketById(int i) {//returns the Ticket WHERE id=i
String message = result.getString(3);
String comment = result.getString(6);
String staff = result.getString(8);
Ticket ticket = new Ticket(plugin,i, submitter, message, date, Status.getByString(status), comment,location,staff);
String server = result.getString(9);
Ticket ticket = new Ticket(plugin,i, submitter, server, message, date, Status.getByString(status), comment,location,staff);
result.close();
conn.close();
return ticket;
Expand Down
12 changes: 11 additions & 1 deletion src/modreq/Ticket.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class Ticket
{
private int id;
private String submitter;
private String serverr;
private String serv;
private String message;
private String date;
private Status status;
Expand All @@ -29,8 +31,9 @@ public class Ticket
private String request;
private TicketHandler tickets;

public Ticket(modreq plugin,int idp, String submitt, String messa, String date, Status status, String comm, String loc, String sta) {
public Ticket(modreq plugin,int idp, String submitt, String serv, String messa, String date, Status status, String comm, String loc, String sta) {
submitter = submitt;
serverr = serv;
id = idp;
staff = sta;
this.date = date;
Expand All @@ -42,6 +45,7 @@ public Ticket(modreq plugin,int idp, String submitt, String messa, String date,
tickets = plugin.getTicketHandler();
this.loc = plugin.Messages.getString("ticket.location", "Location");
this.sub = plugin.Messages.getString("ticket.submitter", "Submitter");
this.serv = plugin.Messages.getString("ticket.serverr", "Server");
this.dt = plugin.Messages.getString("ticket.date", "Date of Request");
this.sta = plugin.Messages.getString("ticket.status", "Status");
this.com = plugin.Messages.getString("ticket.comment", "Comment");
Expand Down Expand Up @@ -70,6 +74,10 @@ public String getStaff() {
public String getSubmitter() {
return submitter;
}

public String getServer() {
return serverr;
}
/**
* This is used to get the date of the request
* @return
Expand Down Expand Up @@ -176,6 +184,7 @@ public void sendMessageToPlayer(Player p) {
if((( modreq )Bukkit.getPluginManager().getPlugin("ModReq")).getConfig().getString("use-nickname").equalsIgnoreCase("true")){
if(playerIsOnline()) {
submitter = Bukkit.getPlayer(submitter).getDisplayName();
serverr = Bukkit.getServerName();
}
}
p.sendMessage(ChatColor.GOLD + "---Info-about-ticket-#"+id+"---");
Expand All @@ -186,6 +195,7 @@ public void sendMessageToPlayer(Player p) {
p.sendMessage(ChatColor.AQUA + this.dt+": " + ChatColor.GRAY + date);
p.sendMessage(ChatColor.AQUA + this.request+": " + ChatColor.GRAY + message);
p.sendMessage(ChatColor.AQUA + this.com+": " + ChatColor.GRAY + comment);
p.sendMessage(ChatColor.AQUA + this.serv+": " + ChatColor.GRAY + serverr);
}

private boolean playerIsOnline() {
Expand Down

0 comments on commit f0f9c8a

Please sign in to comment.