-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1af6c8
commit 89425b7
Showing
14 changed files
with
295 additions
and
23 deletions.
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
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
51 changes: 51 additions & 0 deletions
51
src/main/java/vip/floatationdevice/mgbridge/event/UserBoundEvent.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,51 @@ | ||
package vip.floatationdevice.mgbridge.event; | ||
|
||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Event that is fired when a Guilded user is bound to a Minecraft player. | ||
*/ | ||
public class UserBoundEvent extends Event | ||
{ | ||
private static final HandlerList handlers = new HandlerList(); | ||
private final String userId; | ||
private final UUID uuid; | ||
|
||
@Override | ||
public HandlerList getHandlers() | ||
{ | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() | ||
{ | ||
return handlers; | ||
} | ||
|
||
/** | ||
* Gets the user ID of the user bound to the Minecraft player. | ||
* @return The Guilded user ID. | ||
*/ | ||
public String getUserId() | ||
{ | ||
return userId; | ||
} | ||
|
||
/** | ||
* Gets the UUID of the Minecraft player bound to the user. | ||
* @return The UUID. | ||
*/ | ||
public UUID getPlayerUUID() | ||
{ | ||
return uuid; | ||
} | ||
|
||
public UserBoundEvent(String userId, UUID uuid) | ||
{ | ||
this.userId = userId; | ||
this.uuid = uuid; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/vip/floatationdevice/mgbridge/event/UserUnboundEvent.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,51 @@ | ||
package vip.floatationdevice.mgbridge.event; | ||
|
||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Event that is fired when a Guilded user or a Minecraft player is unbound. | ||
*/ | ||
public class UserUnboundEvent extends Event | ||
{ | ||
private static final HandlerList handlers = new HandlerList(); | ||
private final String userId; | ||
private final UUID uuid; | ||
|
||
@Override | ||
public HandlerList getHandlers() | ||
{ | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() | ||
{ | ||
return handlers; | ||
} | ||
|
||
/** | ||
* Gets the user ID of the user unbound from the Minecraft player. | ||
* @return The Guilded user ID. | ||
*/ | ||
public String getUserId() | ||
{ | ||
return userId; | ||
} | ||
|
||
/** | ||
* Gets the UUID of the Minecraft player unbound from the user. | ||
* @return The UUID. | ||
*/ | ||
public UUID getPlayerUUID() | ||
{ | ||
return uuid; | ||
} | ||
|
||
public UserUnboundEvent(String userId, UUID uuid) | ||
{ | ||
this.userId = userId; | ||
this.uuid = uuid; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/vip/floatationdevice/mgbridge/gce/Command_help.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,46 @@ | ||
package vip.floatationdevice.mgbridge.gce; | ||
|
||
import vip.floatationdevice.guilded4j.object.ChatMessage; | ||
import vip.floatationdevice.mgbridge.GuildedCommandExecutor; | ||
|
||
import static vip.floatationdevice.mgbridge.I18nUtil.translate; | ||
import static vip.floatationdevice.mgbridge.MGBridge.instance; | ||
|
||
public class Command_help implements GuildedCommandExecutor | ||
{ | ||
@Override | ||
public String getCommandName() | ||
{ | ||
return "help"; | ||
} | ||
|
||
@Override | ||
public String getDescription() | ||
{ | ||
return translate("g-cmd-help-desc"); | ||
} | ||
|
||
@Override | ||
public String getUsage() | ||
{ | ||
return "/mgb help"; | ||
} | ||
|
||
@Override | ||
public boolean execute(ChatMessage msg, String[] args) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
for(String gceName : instance.getGEventListener().getExecutors().keySet()) | ||
{ | ||
sb.append('`').append(gceName).append("`, "); | ||
} | ||
sb.deleteCharAt(sb.length() - 1).deleteCharAt(sb.length() - 1); | ||
instance.sendGuildedMessage( | ||
translate("g-cmd-help-msg").replace("%SUBCOMMANDS%", sb.toString()), | ||
msg.getId(), | ||
null, | ||
null | ||
); | ||
return true; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/vip/floatationdevice/mgbridge/gce/Command_helpof.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,58 @@ | ||
package vip.floatationdevice.mgbridge.gce; | ||
|
||
import vip.floatationdevice.guilded4j.object.ChatMessage; | ||
import vip.floatationdevice.mgbridge.GuildedCommandExecutor; | ||
|
||
import static vip.floatationdevice.mgbridge.I18nUtil.translate; | ||
import static vip.floatationdevice.mgbridge.MGBridge.instance; | ||
|
||
public class Command_helpof implements GuildedCommandExecutor | ||
{ | ||
@Override | ||
public String getCommandName() | ||
{ | ||
return "helpof"; | ||
} | ||
|
||
@Override | ||
public String getDescription() | ||
{ | ||
return translate("g-cmd-helpof-desc"); | ||
} | ||
|
||
@Override | ||
public String getUsage() | ||
{ | ||
return "/mgb helpof <SUBCOMMAND>"; | ||
} | ||
|
||
@Override | ||
public boolean execute(ChatMessage msg, String[] args) | ||
{ | ||
if(args.length == 1 && instance.getGEventListener().getExecutors().containsKey(args[0])) | ||
{ | ||
GuildedCommandExecutor gce = instance.getGEventListener().getExecutors().get(args[0]); | ||
String desc = null, usage = null; | ||
try | ||
{// GuildedCommandExecutor from MGB version 0.9.2 and older doesn't implement getDescription() and getUsage() | ||
desc = gce.getDescription(); | ||
usage = gce.getUsage(); | ||
} | ||
catch(AbstractMethodError e) | ||
{ | ||
instance.getLogger().warning("Guilded subcommand '" + args[0] + "' is made for old version of MGBridge. It's recommended to update it"); | ||
} | ||
instance.sendGuildedMessage( | ||
translate("g-cmd-helpof-msg") | ||
.replace("%SUBCOMMAND%", gce.getCommandName()) | ||
.replace("%DESCRIPTION%", desc != null ? desc : "???") | ||
.replace("%USAGE%", usage != null ? usage : "???"), | ||
msg.getId(), | ||
null, | ||
null | ||
); | ||
return true; | ||
} | ||
else return false; | ||
} | ||
} |
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
Oops, something went wrong.