-
Notifications
You must be signed in to change notification settings - Fork 65
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
Showing
7 changed files
with
115 additions
and
17 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
70 changes: 70 additions & 0 deletions
70
core/src/main/java/com/sekwah/advancedportals/core/tags/BungeeTag.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,70 @@ | ||
package com.sekwah.advancedportals.core.tags; | ||
|
||
import com.google.common.io.ByteArrayDataOutput; | ||
import com.google.common.io.ByteStreams; | ||
import com.google.inject.Inject; | ||
import com.sekwah.advancedportals.core.connector.containers.PlayerContainer; | ||
import com.sekwah.advancedportals.core.registry.TagTarget; | ||
import com.sekwah.advancedportals.core.repository.ConfigRepository; | ||
import com.sekwah.advancedportals.core.util.FriendlyDataOutput; | ||
import com.sekwah.advancedportals.core.util.Lang; | ||
import com.sekwah.advancedportals.core.warphandler.ActivationData; | ||
import com.sekwah.advancedportals.core.warphandler.Tag; | ||
|
||
import java.util.Random; | ||
|
||
public class BungeeTag implements Tag.Activation { | ||
|
||
public static final String PACKET_CHANNEL = "BungeeCord"; | ||
@Inject | ||
ConfigRepository configRepository; | ||
|
||
public static String TAG_NAME = "bungee"; | ||
|
||
private final TagType[] tagTypes = | ||
new TagType[] {TagType.PORTAL}; | ||
|
||
private final Random random = new Random(); | ||
|
||
@Override | ||
public TagType[] getTagTypes() { | ||
return tagTypes; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return TAG_NAME; | ||
} | ||
|
||
@Override | ||
public String[] getAliases() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return Lang.translate("tag.bungee.description"); | ||
} | ||
|
||
@Override | ||
public boolean preActivated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void postActivated(TagTarget target, PlayerContainer player, ActivationData activationData, String[] argData) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean activated(TagTarget target, PlayerContainer player, ActivationData activeData, String[] argData) { | ||
String selectedArg = argData[random.nextInt(argData.length)]; | ||
|
||
ByteArrayDataOutput outForSend = ByteStreams.newDataOutput(); | ||
outForSend.writeUTF("Connect"); | ||
outForSend.writeUTF(selectedArg); | ||
player.sendPacket(BungeeTag.PACKET_CHANNEL, outForSend.toByteArray()); | ||
activeData.setWarpStatus(ActivationData.WarpedStatus.WARPED); | ||
return true; | ||
} | ||
} |
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