Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

BlockHunt

Comments in 'Plugin Development' started by Skullex, Feb 7, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I've recently been playing with an abandoned plugin and I've found an error that I cannot locate. What have I done wrong??

    PHP:
    <?php

    use BlockHunt\BlockHunt;
    use 
    BlockHunt\ConfigC;
    use 
    BlockHunt\Storage;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    pocketmine\Player;

    class 
    MessageM {
        public 
    $plugin;

        public function 
    __construct(BlockHunt $plugin){
            
    $this->plugin $plugin;
        }
       
       public static function 
    sendMessage(Player $player$message$vars)
       {
         if (
    player == null) {
           
    $this->getLogger()->info(replaceAll(str_replace("%player%""Console"$message), $vars));
         } else {
           
    player.sendMessage(replaceAll(str_replace("%player%"player.getName(), $message), $vars));
         }
       }
       
       public static function 
    sendFMessage(Player $playerConfigC $location$vars)
       {
         if (
    $player == null) {
           
    Bukkit.getConsoleSender().sendMessage(replaceAll(str_replace("%player%""Console"$location->config->get($location->location)), vars));
         } else {
           
    player.sendMessage(replaceAll(
             
    location.config.getFile().get(location.location).toString()
             .
    replaceAll("%player%"player.getName()), vars));
         }
       }
       
       public static function 
    broadcastMessage(String messageString... vars)
       {
         for (
    Player player Bukkit.getServer().getOnlinePlayers()) {
           
    player.sendMessage(replaceAll(
             
    message.replaceAll("%player%"player.getName()), vars));
         }
         
    Bukkit.getConsoleSender().sendMessage(
           
    replaceAll(message.replaceAll("%player%""Console"), 
           
    vars));
       }
       
       public static function 
    broadcastFMessage(ConfigC locationString... vars)
       {
         for (
    Player player Bukkit.getServer().getOnlinePlayers()) {
           
    player.sendMessage(replaceAll(
             
    location.config.getFile().get(location.location).toString()
             .
    replaceAll("%player%"player.getName()), vars));
         }
            
    $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), replaceAll(location.config.getFile().get(location.location).toString().replaceAll("%player%""Console"), vars));
       }
       
       public static 
    String replaceAll($message$vars)
       {
         return 
    replaceColours(replaceColourVars(
           
    replaceVars(messagevars)));
       }
       
       public static 
    String replaceColours($message)
       {
         return 
    message.replaceAll("(&([a-fk-or0-9]))""§$2");
       }
       
       public static 
    String replaceColourVars($message)
       {
         
    message message.replaceAll("%N"CType.NORMAL());
         
    message message.replaceAll("%W"CType.WARNING());
         
    message message.replaceAll("%E"CType.ERROR());
         
    message message.replaceAll("%A"CType.ARG());
         
    message message.replaceAll("%H"CType.HEADER());
         
    message message.replaceAll("%TAG"CType.TAG());
         return 
    message;
       }
       
       public static 
    String replaceVars(String messageString... vars)
       {
         for (
    String var : vars)
         {
           
    String[] split = var.split("-");
           
    message message.replaceAll("%" split[0] + "%"split[1]);
         }
         return 
    message;
       }
       
       public static class 
    CType
       
    {
         public static 
    String NORMAL()
         {
           return (String)
    W.config.get(ConfigC.chat_normal);
         }
         
         public static 
    String WARNING()
         {
           return (String)
    W.config.get(ConfigC.chat_warning);
         }
         
         public static 
    String ERROR()
         {
           return (String)
    W.config.get(ConfigC.chat_error);
         }
         
         public static 
    String ARG()
         {
           return (String)
    W.config.get(ConfigC.chat_arg);
         }
         
         public static 
    String HEADER()
         {
           return (String)
    W.config.get(ConfigC.chat_header);
         }
         
         public static 
    String TAG()
         {
           return 
           
             (String)
    W.config.get(ConfigC.chat_header) + (String)W.config.get(ConfigC.chat_tag) + (String)W.config.get(ConfigC.chat_normal);
         }
       }
    }
    Screenshot_2016-02-07-13-40-13.png
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    namespace missing.
    Skullex likes this.
  3. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Thanks, I have a headache so I'm a bit sluggish.. sorry
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    ?! Those are Bukkit code.
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    I was thinking of that too lol
    Skullex likes this.
  6. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Ik ;) :p
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    But syntax is correct :D PHP believes that you are planning to use a constant Bukkit and a function called getConsoleCommandSender(), and a function called sendMessage(), and then concatenate them together.
    Legoboy0215 likes this.

Share This Page

Advertisement