-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closes Several Issues. #68
Closed
Closed
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f376de9
Issue #66 - Nucleus Permission Check
axle2005 336c4f9
Issue #63 Feature 3 Completed.
axle2005 bb73f49
Issue #63 Feature 2 Completed
axle2005 063ac85
Issue #63 Feature 1 Working - Not Customizable Yet.
axle2005 d74003e
Package 'discordcommands' was created incorrectly.
axle2005 6107963
Commented out unfinished command.
axle2005 956b97b
Update Authors
axle2005 5531f59
Once again fixing removal of previous package...
axle2005 0e9409f
Issue #50 - Added 'removeColor' method to ColorUtil.
axle2005 0b44d8f
Issue #54 - Adds Support for Boop.
axle2005 d743f3a
Moved Nucleus Staff Channel to 'hooks' package
axle2005 b9a6849
Removed Reference to not completed TPS Command
axle2005 10131c2
Issue #43 - Ban, Kick, TPS commands added.
axle2005 6021eb4
Changed to user Mohron's wonderful DiscordUtil
axle2005 3a73163
Added Twitter Listener - Able to Automatically Post Tweets to Channel.
axle2005 c2cf131
Version Bump - 2.5.1
axle2005 beafd38
Updated with Twitter Support
axle2005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
93 changes: 93 additions & 0 deletions
93
src/main/java/com/nguyenquyhy/discordbridge/discordcommands/CommandHandler.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.nguyenquyhy.discordbridge.discordcommands; | ||
|
||
import java.util.Optional; | ||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.command.CommandSource; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.text.Text; | ||
import org.spongepowered.api.text.format.TextColors; | ||
|
||
import com.nguyenquyhy.discordbridge.DiscordBridge; | ||
import com.nguyenquyhy.discordbridge.models.ChannelConfig; | ||
import com.nguyenquyhy.discordbridge.models.GlobalConfig; | ||
import com.nguyenquyhy.discordbridge.utils.ChannelUtil; | ||
import com.nguyenquyhy.discordbridge.utils.ErrorMessages; | ||
import de.btobastian.javacord.DiscordAPI; | ||
import de.btobastian.javacord.entities.Channel; | ||
import de.btobastian.javacord.entities.User; | ||
import de.btobastian.javacord.entities.message.Message; | ||
|
||
public class CommandHandler { | ||
|
||
private static String id = "discordbridge"; | ||
|
||
public static void handle(Optional<Player> player, String substring) { | ||
DiscordBridge mod = DiscordBridge.getInstance(); | ||
mod.getLogger().info("Working"); | ||
queueCommand(player, substring.toLowerCase().split(" ")); | ||
|
||
} | ||
|
||
public static void handle(Message message) { | ||
DiscordBridge mod = DiscordBridge.getInstance(); | ||
String content = message.getContent().substring(1); | ||
queueCommand(message.getAuthor(), message.getChannelReceiver(),mod, content.toLowerCase().split(" ")); | ||
} | ||
|
||
private static void queueCommand(Optional<Player> player, String[] strings) { | ||
if (!(strings.length > 1)) { | ||
sendMessageToSource(player, 0); | ||
return; | ||
} | ||
|
||
if (strings[0].equals("ban") && permCheck(player, id + "ban")) { | ||
|
||
} | ||
|
||
} | ||
private static void queueCommand(User user,Channel channel,DiscordBridge mod, String[] strings) { | ||
if(strings[0].equals("tps")) TpsCommand.run(mod); | ||
else if(strings[0].equals("players")) PlayerCommand.run(mod, channel); | ||
|
||
} | ||
|
||
private static boolean permCheck(Optional<Player> player, String permission) { | ||
if (!player.isPresent()) | ||
return true; | ||
else if (player.get().hasPermission(permission)) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
private static void sendMessageToSource(Optional<Player> player, int code) { | ||
CommandSource src; | ||
if (player.isPresent()) | ||
src = Sponge.getServer().getPlayer(player.get().getUniqueId()).get().getCommandSource().get(); | ||
else | ||
src = Sponge.getServer().getConsole(); | ||
|
||
if (code == 0) { | ||
src.sendMessage(Text.of(TextColors.RED, "Not enough arguments")); | ||
} | ||
|
||
} | ||
|
||
private static void runCommand(String substring) { | ||
DiscordBridge mod = DiscordBridge.getInstance(); | ||
GlobalConfig config = mod.getConfig(); | ||
|
||
DiscordAPI client = mod.getBotClient(); | ||
|
||
|
||
for (ChannelConfig channelConfig : config.channels) { | ||
Channel channel = client.getChannelById(channelConfig.discordId); | ||
if (channel == null) { | ||
ErrorMessages.CHANNEL_NOT_FOUND.log(channelConfig.discordId); | ||
return; | ||
} | ||
//ChannelUtil.banPlayer(channel, substring); | ||
} | ||
|
||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/nguyenquyhy/discordbridge/discordcommands/PlayerCommand.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.nguyenquyhy.discordbridge.database.discordcommands; | ||
|
||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
|
||
|
||
import com.nguyenquyhy.discordbridge.DiscordBridge; | ||
import com.nguyenquyhy.discordbridge.utils.ChannelUtil; | ||
|
||
import de.btobastian.javacord.entities.Channel; | ||
|
||
public class PlayerCommand { | ||
|
||
public static void PlayerCommand(){ | ||
|
||
} | ||
public static void run(DiscordBridge mod, Channel channel){ | ||
ChannelUtil.sendMessage(channel, "Players Currently Online: "); | ||
for(Player player : Sponge.getServer().getOnlinePlayers()){ | ||
ChannelUtil.sendMessage(channel, player.getName()); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One PR makes you an Author? Interesting...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly :P If he wants to deny this one commit, I don't care. The rest of the PR is good, but I'm still going to be hobbling along on this plugin anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just think it's funny when contributors add themselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time for another commit then: Instead of author, Grand Pumba of Randomness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LMAO.