Skip to content

Commit

Permalink
Reasons are now sortable
Browse files Browse the repository at this point in the history
  • Loading branch information
Tutorialwork committed Sep 2, 2019
1 parent 3484839 commit 0f27374
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 32 additions & 1 deletion .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 2 additions & 7 deletions src/de/tutorialwork/commands/Ban.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public class Ban extends Command {
public Ban(String name) {
Expand All @@ -27,13 +28,7 @@ public void execute(CommandSender sender, String[] args) {
ProxiedPlayer p = (ProxiedPlayer) sender;
if(p.hasPermission("professionalbans.ban") || p.hasPermission("professionalbans.*")){
if(args.length == 0 || args.length == 1){
for(int zaehler = 1;zaehler < BanManager.countReasons()+1;zaehler++) {
if(BanManager.isBanReason(zaehler)){
p.sendMessage("§7"+zaehler+" §8| §e"+BanManager.getReasonByID(zaehler));
} else {
p.sendMessage("§7"+zaehler+" §8| §e"+BanManager.getReasonByID(zaehler)+" §8(§cMUTE§8)");
}
}
BanManager.getBanReasonsList(p);
p.sendMessage(Main.Prefix+"/ban <Spieler> <Grund-ID>");
} else {
String UUID = UUIDFetcher.getUUID(args[0]);
Expand Down
2 changes: 2 additions & 0 deletions src/de/tutorialwork/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ private void MySQL() {
//SQL Update 2.2
mysql.update("ALTER TABLE bans ADD IF NOT EXISTS FIRSTLOGIN varchar(255);");
mysql.update("ALTER TABLE bans ADD IF NOT EXISTS LASTLOGIN varchar(255);");
//SQL Update 2.4
mysql.update("ALTER TABLE reasons ADD COLUMN SORTINDEX int(11)");
}

private void Commands() {
Expand Down
14 changes: 14 additions & 0 deletions src/de/tutorialwork/utils/BanManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ public static void createPlayer(String UUID, String Name){
}
}

public static void getBanReasonsList(ProxiedPlayer p){
try {
ResultSet rs = Main.mysql.query("SELECT * FROM reasons ORDER BY SORTINDEX ASC");
while(rs.next()){
int id = rs.getInt("ID");
if(BanManager.isBanReason(id)){
p.sendMessage("§7"+id+" §8| §e"+BanManager.getReasonByID(id));
} else {
p.sendMessage("§7"+id+" §8| §e"+BanManager.getReasonByID(id)+" §8(§cMUTE§8)");
}
}
} catch (SQLException exc){ }
}

public static String getNameByUUID(String UUID){
if(playerExists(UUID)){
try {
Expand Down

0 comments on commit 0f27374

Please sign in to comment.