Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
Added /ping
changed syntax of /vote
now /vote <yes/no>
added ability to restart server by vote
  • Loading branch information
BTELNYY committed Mar 20, 2022
1 parent 4e55fa9 commit b2ef6ef
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 65 deletions.
16 changes: 8 additions & 8 deletions Project/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ commands:
description: Starts a vote to punish a player.
usage: /vtp <player> <ban/kick>
permission: btelnyy.vote.start
voteno:
description: Vote no on current vote.
usage: /voteno
permission: btelnyy.vote
voteyes:
description: Vote yes on current vote.
usage: /voteyes
vote:
description: Vote on the current vote
usage: /vote <yes/no>
permission: btelnyy.vote
rules:
description: Print server rules.
Expand All @@ -30,4 +26,8 @@ commands:
voterestart:
description: Start a vote to restart the server.
usage: /voterestart
permission: btelnyy.vote.srvrestart
permission: btelnyy.vote.srvrestart
ping:
description: Get your ping to the server.
usage: /ping
permission: btelnyy.ping
20 changes: 20 additions & 0 deletions Project/src/btelnyy/plugin/Commands/CommandPing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package btelnyy.plugin.Commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
public class CommandPing implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String arg2, String[] args) {
if(sender instanceof Player) {
Player p = (Player) sender;
int ping = p.getPing();
sender.sendMessage(ChatColor.YELLOW + "Ping: " + ping + "ms");
return true;
}else {
sender.sendMessage(ChatColor.RED + "Error: You must be a player to run this command.");
return true;
}
}
}
4 changes: 0 additions & 4 deletions Project/src/btelnyy/plugin/VotingSystem/RestartServer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package btelnyy.plugin.VotingSystem;

import java.util.logging.Level;

import org.bukkit.BanList;
import org.bukkit.BanList.Type;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

public class VoteYes implements CommandExecutor{
public class Vote implements CommandExecutor{
public boolean onCommand(CommandSender sender, Command command, String arg2, String[] args) {
Player s = (Player) sender;
//not used
boolean override = false;
if(Utility.ArrayCounter(args) < 1) {
sender.sendMessage(ChatColor.RED + "Error: Invalid syntax.");
Expand All @@ -26,22 +27,11 @@ public boolean onCommand(CommandSender sender, Command command, String arg2, Str
sender.sendMessage(ChatColor.RED + "Error: No vote is active.");
return true;
}
try {
if(args[1] == "-o" && sender.hasPermission("btelnyy.vote.override")){
override = true;
}else if(args[1] == "-o" && !sender.hasPermission("btelnyy.vote.override")) {
sender.sendMessage(ChatColor.RED + "Error: You do not have permission to override votes.");
}
}catch(Exception e) {
e.printStackTrace();
}
switch(VoteOption) {
case "yes":
if(override) {
VoteGlobals.VoteYes += 999;
Bukkit.broadcastMessage(ChatColor.YELLOW + "The vote was overriden by " + sender.getName());
}else if(args[1] == "-o" && !sender.hasPermission("btelnyy.vote.override")) {
sender.sendMessage(ChatColor.RED + "Error: You do not have permission to override votes.");
}
for(Player p : VoteGlobals.VotedPlayers) {
if(p == s) {
Expand All @@ -52,7 +42,7 @@ public boolean onCommand(CommandSender sender, Command command, String arg2, Str
VoteGlobals.VoteYes += 1;
sender.sendMessage(ChatColor.GREEN + "Vote successful.");
VoteGlobals.VotedPlayers.add(s);
main.log(Level.INFO, "Player " + s.getName() + " has voted YES to " + VoteGlobals.VoteType + " player " + VoteGlobals.target.getName());
main.log(Level.INFO, "Player " + s.getName() + " has voted YES to " + VoteGlobals.VoteType);
return true;
case "no":
if(override) {
Expand All @@ -68,7 +58,7 @@ public boolean onCommand(CommandSender sender, Command command, String arg2, Str
VoteGlobals.VoteNo += 1;
sender.sendMessage(ChatColor.GREEN + "Vote successful.");
VoteGlobals.VotedPlayers.add(s);
main.log(Level.INFO, "Player " + s.getName() + " has voted NO to " + VoteGlobals.VoteType + " player " + VoteGlobals.target.getName());
main.log(Level.INFO, "Player " + s.getName() + " has voted NO to " + VoteGlobals.VoteType);
return true;
default:
sender.sendMessage(ChatColor.RED + "Error: Invalid vote option.");
Expand Down
33 changes: 0 additions & 33 deletions Project/src/btelnyy/plugin/VotingSystem/VoteNo.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import org.bukkit.command.CommandSender;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class VoteServerRestart implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String arg2, String[] args) {
Expand Down
10 changes: 6 additions & 4 deletions Project/src/btelnyy/plugin/main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

import MOTDHandler.MOTDHandle;
import btelnyy.plugin.Commands.CommandDisconnect;
import btelnyy.plugin.Commands.CommandPing;
import btelnyy.plugin.Commands.CommandRules;
import btelnyy.plugin.Commands.CommandSuicide;
import btelnyy.plugin.VotingSystem.CommandVTP;
import btelnyy.plugin.VotingSystem.VoteNo;
import btelnyy.plugin.VotingSystem.VoteYes;
import btelnyy.plugin.VotingSystem.Vote;
import btelnyy.plugin.VotingSystem.VoteServerRestart;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -42,8 +43,9 @@ public void onEnable() {
this.getCommand("dc").setExecutor(new CommandDisconnect());
this.getCommand("rules").setExecutor(new CommandRules());
this.getCommand("vtp").setExecutor(new CommandVTP());
this.getCommand("voteyes").setExecutor(new VoteYes());
this.getCommand("voteno").setExecutor(new VoteNo());
this.getCommand("vote").setExecutor(new Vote());
this.getCommand("ping").setExecutor(new CommandPing());
this.getCommand("voterestart").setExecutor(new VoteServerRestart());
}

// Fired when plugin is disabled
Expand Down

0 comments on commit b2ef6ef

Please sign in to comment.