001/* 002 * Trident - A Multithreaded Server Alternative 003 * Copyright 2014 The TridentSDK Team 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package net.tridentsdk.server.command; 019 020import net.tridentsdk.Console; 021import net.tridentsdk.entity.living.Player; 022import net.tridentsdk.registry.Registered; 023import net.tridentsdk.util.TridentLogger; 024 025public class TridentConsole implements Console { 026 private volatile String lastCommand; 027 private volatile String lastMessage; 028 029 @Override 030 public void invokeCommand(String message) { 031 Registered.commands().handle(message, this); 032 lastCommand = message; 033 } 034 035 @Override 036 public String lastCommand() { 037 return lastCommand; 038 } 039 040 @Override 041 public Player asPlayer() { 042 return null; 043 } 044 045 @Override 046 public void sendRaw(String... messages) { 047 // TODO: convert MessageBuilder json to console output 048 049 for (String s : messages) { 050 TridentLogger.get().log(s); 051 } 052 053 lastMessage = messages[messages.length - 1]; 054 } 055 056 @Override 057 public String lastMessage() { 058 return lastMessage; 059 } 060 061 @Override 062 public void grantPermission(String perm) { 063 } 064 065 @Override 066 public void revokePermission(String perm) { 067 } 068 069 @Override 070 public boolean ownsPermission(String perm) { 071 return true; // op 072 } 073 074 @Override 075 public boolean opped() { 076 return true; 077 } 078}