Permalink
Browse files

Remove tab_complete_chat event (non-functional)

  • Loading branch information...
PseudoKnight committed Aug 10, 2018
1 parent 81c86b9 commit a348de6d0ed7582ec06a8c58a4ce710a847635b7
@@ -32,7 +32,6 @@
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCFishingState;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCGameMode;
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCTeleportCause;
import com.laytonsmith.abstraction.events.MCChatTabCompleteEvent;
import com.laytonsmith.abstraction.events.MCExpChangeEvent;
import com.laytonsmith.abstraction.events.MCFoodLevelChangeEvent;
import com.laytonsmith.abstraction.events.MCGamemodeChangeEvent;
@@ -72,7 +71,6 @@
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEditBookEvent;
import org.bukkit.event.player.PlayerEvent;
@@ -97,7 +95,6 @@
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -836,31 +833,6 @@ public MCGameMode getNewGameMode() {
}
}
public static class BukkitMCChatTabCompleteEvent extends BukkitMCPlayerEvent implements MCChatTabCompleteEvent {
PlayerChatTabCompleteEvent tc;
public BukkitMCChatTabCompleteEvent(PlayerChatTabCompleteEvent event) {
super(event);
this.tc = event;
}
@Override
public String getChatMessage() {
return tc.getChatMessage();
}
@Override
public String getLastToken() {
return tc.getLastToken();
}
@Override
public Collection<String> getTabCompletions() {
return tc.getTabCompletions();
}
}
public static class BukkitMCExpChangeEvent extends BukkitMCPlayerEvent implements MCExpChangeEvent {
PlayerExpChangeEvent ec;
@@ -2,7 +2,6 @@
import com.laytonsmith.abstraction.MCLocation;
import com.laytonsmith.abstraction.bukkit.BukkitMCLocation;
import com.laytonsmith.abstraction.bukkit.events.BukkitPlayerEvents.BukkitMCChatTabCompleteEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitPlayerEvents.BukkitMCExpChangeEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitPlayerEvents.BukkitMCFoodLevelChangeEvent;
import com.laytonsmith.abstraction.bukkit.events.BukkitPlayerEvents.BukkitMCGamemodeChangeEvent;
@@ -40,7 +39,6 @@
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
import org.bukkit.event.player.PlayerEditBookEvent;
import org.bukkit.event.player.PlayerExpChangeEvent;
import org.bukkit.event.player.PlayerFishEvent;
@@ -281,12 +279,6 @@ public void onGamemodeChange(PlayerGameModeChangeEvent event) {
EventUtils.TriggerListener(Driver.GAMEMODE_CHANGE, "gamemode_change", e);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onChatTab(PlayerChatTabCompleteEvent event) {
BukkitMCChatTabCompleteEvent e = new BukkitMCChatTabCompleteEvent(event);
EventUtils.TriggerListener(Driver.TAB_COMPLETE, "tab_complete_chat", e);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onExpChange(PlayerExpChangeEvent event) {
BukkitMCExpChangeEvent e = new BukkitMCExpChangeEvent(event);

This file was deleted.

Oops, something went wrong.
@@ -18,7 +18,6 @@
import com.laytonsmith.abstraction.enums.MCFishingState;
import com.laytonsmith.abstraction.enums.MCGameMode;
import com.laytonsmith.abstraction.enums.MCTeleportCause;
import com.laytonsmith.abstraction.events.MCChatTabCompleteEvent;
import com.laytonsmith.abstraction.events.MCExpChangeEvent;
import com.laytonsmith.abstraction.events.MCFoodLevelChangeEvent;
import com.laytonsmith.abstraction.events.MCGamemodeChangeEvent;
@@ -2261,92 +2260,6 @@ public Version since() {
}
}
@api
public static class tab_complete_chat extends AbstractEvent {
@Override
public String getName() {
return "tab_complete_chat";
}
@Override
public String docs() {
return "{player: <macro>}"
+ " Fires when a player asks for a list of completions to the current word in their chat message."
+ " Setting the completions to an empty array is this event's equivalent of cancel()."
+ " {player: the player asking for completion | message: the full message they have typed"
+ " | last: the partial word completion is asked for | completions}"
+ " {completions: the list of completions to send, default is player names containing the last text}"
+ " {}";
}
@Override
public boolean matches(Map<String, Construct> prefilter, BindableEvent e) throws PrefilterNonMatchException {
if(e instanceof MCChatTabCompleteEvent) {
Prefilters.match(prefilter, "player", ((MCChatTabCompleteEvent) e).getPlayer().getName(), PrefilterType.MACRO);
return true;
}
return false;
}
@Override
public BindableEvent convert(CArray manualObject, Target t) {
throw new CREBindException("Unsupported Operation", Target.UNKNOWN);
}
@Override
public Map<String, Construct> evaluate(BindableEvent e) throws EventException {
if(e instanceof MCChatTabCompleteEvent) {
MCChatTabCompleteEvent event = (MCChatTabCompleteEvent) e;
Target t = Target.UNKNOWN;
Map<String, Construct> ret = evaluate_helper(event);
ret.put("message", new CString(event.getChatMessage(), t));
ret.put("last", new CString(event.getLastToken(), t));
CArray completions = new CArray(t);
for(String c : event.getTabCompletions()) {
completions.push(new CString(c, t), t);
}
ret.put("completions", completions);
return ret;
} else {
throw new EventException("Could not convert to MCChatTabCompleteEvent.");
}
}
@Override
public boolean modifyEvent(String key, Construct value, BindableEvent event) {
if(event instanceof MCChatTabCompleteEvent) {
MCChatTabCompleteEvent e = (MCChatTabCompleteEvent) event;
if("completions".equals(key)) {
if(value instanceof CArray) {
e.getTabCompletions().clear();
if(((CArray) value).inAssociativeMode()) {
for(Construct k : ((CArray) value).keySet()) {
e.getTabCompletions().add(((CArray) value).get(k, value.getTarget()).val());
}
} else {
for(Construct v : ((CArray) value).asList()) {
e.getTabCompletions().add(v.val());
}
}
return true;
}
}
}
return false;
}
@Override
public Driver driver() {
return Driver.TAB_COMPLETE;
}
@Override
public Version since() {
return CHVersion.V3_3_1;
}
}
@api
public static class exp_change extends AbstractEvent {

0 comments on commit a348de6

Please sign in to comment.